Logo Search packages:      
Sourcecode: pauker version File versions  Download package

static void screenshots::Screenshots::doScreenShots ( Locale  locale,
String  path,
int  mainWindowWidth,
int  mainWindowHeight,
String  mainWindowFileName,
String  badFrontsideString,
String  badReversesideString,
String  frontsideString,
String  newCardDialogFileName,
String  learningLesson,
int  learningWidth,
int  learningHeight,
String  learningFileName,
String  fontDialogFileName,
String  strategiesFileName,
String  timesFileName,
String  miscFileName,
String  ultraShortTermLesson,
String  ultraShortTermFileName 
) throws Exception [inline, static]

creates all screenshots

Parameters:
locale the locale to use
path the path where to store the screenshots
mainWindowWidth the width of the main window to be used
mainWindowHeight the height of the main window to be used
mainWindowFileName the file name of the main window screen shot
badFrontsideString the file name of the bad front side screen shot
badReversesideString the file name of the bad reverse side screen shot
frontsideString the string to be used for the front side
newCardDialogFileName the file name of the new card dialog screen shot
learningLesson the lesson for the learning screen shot
learningWidth the width of the learning screenshot window
learningHeight the height of the learning screenshot window
learningFileName the file name for the learning screenshot
fontDialogFileName the file name for the font dialog screenshot
strategiesFileName the file name for the strategies screenshot
timesFileName the file name for the times screenshot
miscFileName the file name for the misc screenshot
ultraShortTermLesson the lesson to be used for the ultra short term memory screenshot
ultraShortTermFileName the file name for the ultra short term screenshot
Exceptions:
Exception if an exception occurs

settings dialog screenshots

main window screenshot

card dialog screenshot

learning screenshot

font dialog screenshot

ultra-shortterm memory screenshot

Definition at line 74 of file Screenshots.java.

                             {

        // make sure that path exists
        File directory = new File(path);
        if ((!directory.exists()) && (!directory.mkdir())) {
            throw new IOException("Could not create directory \"" + path + "\"");
        }

        Locale.setDefault(locale);
        ClassReference classReference = new ClassReference(
                "pauker.program.gui.swing.PaukerFrame");
        classReference.startApplication();
        JFrameOperator frameOperator = new JFrameOperator();
        JSplitPaneOperator splitPaneOperator = new JSplitPaneOperator(
                frameOperator, new NameComponentChooser("splitPane"));
        final JButtonOperator addCardButtonOperator = new JButtonOperator(
                frameOperator, new NameComponentChooser("addCardButton"));
        JMenuOperator fileMenuOperator = new JMenuOperator(
                frameOperator, new NameComponentChooser("fileMenu"));
        PaukerFrame paukerFrame = (PaukerFrame) frameOperator.getSource();

        /**
         * settings dialog screenshots
         */
        if ((strategiesFileName != null) ||
                (timesFileName != null) ||
                (miscFileName != null)) {
            final SettingsDialog settingsDialog = new SettingsDialog(paukerFrame);
            Thread thread = new Thread() {

                @Override
                public void run() {
                    // this is a blocking call, that's why it must be run in a thread
                    settingsDialog.setVisible(true);
                }
            };
            thread.start();
            JDialogOperator dialogOperator = new JDialogOperator(settingsDialog);
            JListOperator menuListOperator = new JListOperator(
                    dialogOperator, new NameComponentChooser("menuList"));
            if (strategiesFileName != null) {
                PNGEncoder.captureScreen(dialogOperator.getBounds(),
                        path + strategiesFileName + ".png", PNGEncoder.COLOR_MODE);
            }
            if (timesFileName != null) {
                menuListOperator.setSelectedIndex(1);
                PNGEncoder.captureScreen(dialogOperator.getBounds(),
                        path + timesFileName + ".png", PNGEncoder.COLOR_MODE);
            }
            if (miscFileName != null) {
                menuListOperator.setSelectedIndex(2);
                PNGEncoder.captureScreen(dialogOperator.getBounds(),
                        path + miscFileName + ".png", PNGEncoder.COLOR_MODE);
            }
            dialogOperator.setVisible(false);
        }

        /**
         * main window screenshot
         */
        // offset for KDE decorations
        int decorationOffsetX = 8;
        int decorationOffsetY = 27;
        splitPaneOperator.setDividerLocation(splitPaneOperator.getMinimumDividerLocation());
        frameOperator.resize(mainWindowWidth + decorationOffsetX, mainWindowHeight + decorationOffsetY);
        Thread.sleep(1000);
        if (mainWindowFileName != null) {
            PNGEncoder.captureScreen(frameOperator.getBounds(),
                    path + mainWindowFileName + ".png", PNGEncoder.COLOR_MODE);
        }

        /**
         * card dialog screenshot
         */
        if (newCardDialogFileName != null) {
            // fill in bad example card
            addCardButtonOperator.pushNoBlock();
            JDialogOperator dialogOperator = new JDialogOperator();
            JTextAreaOperator frontSideTextAreaOperator = new JTextAreaOperator(
                    dialogOperator, new NameComponentChooser("frontSideTextArea"));
            JTextAreaOperator reverseSideTextAreaOperator = new JTextAreaOperator(
                    dialogOperator, new NameComponentChooser("reverseSideTextArea"));
            JButtonOperator okButtonOperator = new JButtonOperator(
                    dialogOperator, new NameComponentChooser("okButton"));

            frontSideTextAreaOperator.setText(badFrontsideString);
            frontSideTextAreaOperator.setForeground(Color.RED);
            frontSideTextAreaOperator.setBackground(Color.BLUE);
            frontSideTextAreaOperator.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 19));
            reverseSideTextAreaOperator.setText(badReversesideString);
            reverseSideTextAreaOperator.setFont(new Font("Dialog", Font.PLAIN, 19));
            Tools.doClick(okButtonOperator);

            // start to fill another card
            addCardButtonOperator.pushNoBlock();
            dialogOperator = new JDialogOperator();
            frontSideTextAreaOperator = new JTextAreaOperator(
                    dialogOperator, new NameComponentChooser("frontSideTextArea"));
            reverseSideTextAreaOperator = new JTextAreaOperator(
                    dialogOperator, new NameComponentChooser("reverseSideTextArea"));
            JButtonOperator cancelButtonOperator = new JButtonOperator(
                    dialogOperator, new NameComponentChooser("cancelButton"));
            frontSideTextAreaOperator.setText(frontsideString);
            frontSideTextAreaOperator.setForeground(Color.BLACK);
            frontSideTextAreaOperator.setBackground(Color.WHITE);
            frontSideTextAreaOperator.setFont(new Font("Dialog", Font.PLAIN, 12));
            reverseSideTextAreaOperator.setFont(new Font("Dialog", Font.PLAIN, 12));
            Thread.sleep(1000);
            PNGEncoder.captureScreen(dialogOperator.getBounds(),
                    path + newCardDialogFileName + ".png", PNGEncoder.COLOR_MODE);
            Tools.doClick(cancelButtonOperator);
        }

        /**
         * learning screenshot
         */
        if (learningFileName != null) {
            fileMenuOperator.doClick();
            JMenuItemOperator openMenuItemOperator = new JMenuItemOperator(
                    frameOperator, new NameComponentChooser("openMenuItem"));
            openMenuItemOperator.push();
            JDialogOperator questionDialogOperator = new JDialogOperator();
            JButtonOperator dontSaveButtonOperator = new JButtonOperator(questionDialogOperator, 1);
            Tools.doClick(dontSaveButtonOperator);
            JDialogOperator openFileDialogOperator = new JDialogOperator();
            JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
            fileChooserOperator.setSelectedFile(new File(learningLesson));
            JButtonOperator openButtonOperator = new JButtonOperator(
                    openFileDialogOperator, new NameComponentChooser("openButton"));
            Tools.doClick(openButtonOperator);
            frameOperator.resize(learningWidth + decorationOffsetX, learningHeight + decorationOffsetY);
            Thread.sleep(1000);
            PNGEncoder.captureScreen(frameOperator.getBounds(),
                    path + learningFileName + ".png", PNGEncoder.COLOR_MODE);
        }

        /**
         * font dialog screenshot
         */
        if (fontDialogFileName != null) {
            final FontDialog fontDialog = new FontDialog(paukerFrame,
                    new Font("Dialog", Font.PLAIN, 13), Color.BLACK,
                    Color.WHITE, Card.Element.FRONT_SIDE);
            Thread thread = new Thread() {

                @Override
                public void run() {
                    // this is a blocking call, that's why it must be run in a thread
                    fontDialog.setVisible(true);
                }
            };
            thread.start();
            JDialogOperator dialogOperator = new JDialogOperator();
            PNGEncoder.captureScreen(dialogOperator.getBounds(),
                    path + fontDialogFileName + ".png", PNGEncoder.COLOR_MODE);
            dialogOperator.setVisible(false);
        }

        /**
         * ultra-shortterm memory screenshot
         */
        if (ultraShortTermFileName != null) {
            fileMenuOperator.doClick();
            JMenuItemOperator openMenuItemOperator = new JMenuItemOperator(
                    frameOperator, new NameComponentChooser("openMenuItem"));
            openMenuItemOperator.push();
            JDialogOperator questionDialogOperator = new JDialogOperator();
            JButtonOperator dontSaveButtonOperator = new JButtonOperator(questionDialogOperator, 1);
            Tools.doClick(dontSaveButtonOperator);
            JDialogOperator openFileDialogOperator = new JDialogOperator();
            JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
            fileChooserOperator.setSelectedFile(new File(ultraShortTermLesson));
            JButtonOperator openButtonOperator = new JButtonOperator(
                    openFileDialogOperator, new NameComponentChooser("openButton"));
            Tools.doClick(openButtonOperator);
            JButtonOperator learnNewCardsButtonOperator = new JButtonOperator(
                    frameOperator, new NameComponentChooser("learnNewCardsButton"));
            JButtonOperator nextNewCardButtonOperator = new JButtonOperator(
                    frameOperator, new NameComponentChooser("nextNewCardButton"));
            splitPaneOperator.setDividerLocation(splitPaneOperator.getMaximumDividerLocation());
            Tools.doClick(learnNewCardsButtonOperator);
            for (int i = 0; i < 10; i++) {
                Tools.doClick(nextNewCardButtonOperator);
            }
            Thread.sleep(10001);
            PNGEncoder.captureScreen(frameOperator.getBounds(),
                    path + ultraShortTermFileName + ".png", PNGEncoder.COLOR_MODE);
        }

        // finish
        frameOperator.setVisible(false);
    }


Generated by  Doxygen 1.6.0   Back to index