Package se.kth.speech.skatta.util

Examples of se.kth.speech.skatta.util.ExtendedElement


    public void removeUpdate(DocumentEvent e) {
        insertUpdate(e);
    }

    public ExtendedElement save(ExtendedElement parent) {
        ExtendedElement e = parent.createChildWithName("udpReceiver");
        e.setAttribute("name", m_nameField.getText());
        e.setAttribute("port", m_portField.getValue().toString());
        return e;
    }
View Full Code Here


        return m_listComponent;
    }

    public ExtendedElement save(ExtendedElement parent) {
        if (!m_activeButton.isSelected()) return null;
        ExtendedElement e = parent.createChildWithName("emailNotification");
        e.setAttribute("server", m_serverField.getText());
        e.setAttribute("sender", m_senderField.getText());
        e.setAttribute("receiver", m_receiverField.getText());
        e.createChildWithNameAndText("subject", m_subjectField.getText());
        e.createChildWithNameAndText("message", m_messageField.getText());
        return e;
    }
View Full Code Here

     * @param source The XML Parser it will read detail data from
     */
    public SyncTest(ExtendedElement source, Dimension preferredSize) throws TestException {
        super(source, preferredSize);

        ExtendedElement main = source.child("timesyncTest");

        pageHeaderText = main.textChild("header");

        ExtendedElement pause = main.child("pause");
        if (pause != null) {
            int delay = pause.intAttribute("delay");
            m_pauseMessage = pause.text();
            if (pause.attribute("unit").equals("pages"))
                m_pausePages = delay;
            else m_pauseMinutes = delay;
        }

        backable = main.booleanAttribute("backable");
        cycling = main.booleanAttribute("looping");

        Vector<String> resultClassVector = new Vector<String>();
        resultClassVector.add("Stimuli");
        resultClassVector.add("time");

        ExtendedElement mouseRecorder = main.child("questions").child("mouseRecorder");
        if (mouseRecorder != null) {
            myMouseRecorder = new MouseRecorder(mouseRecorder);
            resultClassVector.add(mouseRecorder.attribute("name") + "X");
            resultClassVector.add(mouseRecorder.attribute("name") + "Y");
        } else myMouseRecorder = null;

        boolean useStopButton = false;
        boolean usePauseButton = false;
        ExtendedElement controlsSource = main.child("playControls");
        if (controlsSource != null) {
            useStopButton = controlsSource.booleanAttribute("stop");
            usePauseButton = controlsSource.booleanAttribute("pause");
        }

        int controls = ControlButtons.CONTROL_PLAY | (useStopButton ? ControlButtons.CONTROL_STOP : 0) | (usePauseButton ? ControlButtons.CONTROL_PAUSE : 0);

        int repetitions = main.intAttribute("repetitions");
        myFolderParser = new FolderParser(new Dimension(myPage.getPreferredSize().width, (int) (myPage.getPreferredSize().height * 0.6)), 1, repetitions, controls);
        if (!myFolderParser.setSource(myStimuliFolder))
            throw new TestException(myStimuliFolder.getAbsolutePath() + " Cannot be used as the source folder.");
        myFolderParser.setInnerStimuli(0);

        visitedPages = new boolean[myFolderParser.getInnerStimuliCount()];
        Arrays.fill(visitedPages, false);
        m_visitedPageCount = 0;

        myRecorderThread = new RecorderThread(this);

        ExtendedElement[] udpReceivers = main.child("questions").children("udpReceiver");
        if (udpReceivers.length != 0) {
            Vector<Integer> handledPorts = new Vector<Integer>();
            Vector<Vector<String>> names = new Vector<Vector<String>>();
            for (ExtendedElement udp : udpReceivers) {
                int port = udp.intAttribute("port");
                int portIndex = handledPorts.indexOf(port);
                if (portIndex == -1) {
                    handledPorts.add(port);
                    names.add(new Vector<String>());
                    names.get(0).add(udp.attribute("name"));
                } else {
                    names.get(portIndex).add(udp.attribute("name"));
                }
            }
            for (int i = 0; i < handledPorts.size(); ++i) {
                UdpReceiver udp = new UdpReceiver(names.get(i).toArray(new String[0]), handledPorts.get(i));
                myRecorderThread.add(udp);
                udp.start();
                resultClassVector.addAll(names.get(i));
            }
        }

        ExtendedElement nameSender = main.child("nameSender");
        if (nameSender != null) {
            String dest = nameSender.attribute("destination");
            int destPort = nameSender.intAttribute("port");
            myNameSender = new NameSender(this, dest, destPort);
        }

        myResultClasses = resultClassVector.toArray(new String[0]);

View Full Code Here

     *          If something is wrong with the test.
     */
    public DragDropTest(ExtendedElement source, Dimension preferredSize) throws TestException {
        super(source, preferredSize);

        ExtendedElement main = source.child("dragdropTest");

        ExtendedElement pause = main.child("pause");
        if (pause != null) {
            int delay = pause.intAttribute("delay");
            pauseMessage = pause.text();
            if (pause.attribute("unit").equals("pages"))
                pausePages = delay;
            else pauseMinutes = delay;
        }
        visitedPageCount = 1;

View Full Code Here

            passwordField.addActionListener(this);
        }
        head.add(quitButton);
        quitVisible = false;

        ExtendedElement buttonLabels = source.child("buttons");
        nextButton = new JButton(buttonLabels.attribute("next"));
        nextButton.setFocusable(false);
        nextButton.setActionCommand("next");
        nextButton.addActionListener(this);
        previousButton = new JButton(buttonLabels.attribute("previous"));
        previousButton.setFocusable(false);
        previousButton.setActionCommand("previous");
        previousButton.addActionListener(this);
        upButton = new JButton(buttonLabels.attribute("up"));
        upButton.setFocusable(false);
        upButton.setActionCommand("up");
        upButton.addActionListener(this);
        downButton = new JButton(buttonLabels.attribute("down"));
        downButton.setFocusable(false);
        downButton.setActionCommand("down");
        downButton.addActionListener(this);
        finishButton = new JButton(buttonLabels.attribute("start"));
        finishButton.setFocusable(false);
        finishButton.setActionCommand("finish");
        finishButton.addActionListener(this);
        finishButtonText = buttonLabels.attribute("end");
        foot.add(previousButton);
        foot.add(upButton);
        foot.add(downButton);
        foot.add(nextButton);
        foot.add(finishButton);

        int headHeight = head.getPreferredSize().height;
        int footHeight = foot.getPreferredSize().height;

        Dimension pageSize = new Dimension(preferredSize.width, preferredSize.height - (headHeight + footHeight));
        prePage = new PrePostPage(source.child("initial"), pageSize);
        postPage = new PrePostPage(source.child("final"), pageSize);
        if (postPage.getNames().length == 0)
            hasFinalQuestions = false;
        else hasFinalQuestions = true;
        headerTextLabel.setText(prePage.getHeaderText());

        myPage = new JPanel();
        myPage.setPreferredSize(pageSize);
        setLayout(new BorderLayout());
        add(head, BorderLayout.NORTH);

        add(prePage.currentPage(), BorderLayout.CENTER);

        add(foot, BorderLayout.SOUTH);
        phase = INITIAL;

        ExtendedElement emailNotification = source.child("emailNotification");
        if (emailNotification != null) {
          try {
            myEmailNotifier = new EmailNotifier(emailNotification);
          } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

     * @param source An ExtendedElement holding information about the test to be created.
     */
    public StandardTest(ExtendedElement source, Dimension preferredSize) throws TestException {
        super(source, preferredSize);

        ExtendedElement main = source.child("standardTest");

        ExtendedElement pause = main.child("pause");
        if (pause != null) {
            int delay = pause.intAttribute("delay");
            pauseMessage = pause.text();
            if (pause.attribute("unit").equals("pages"))
                pauseStimuli = delay;
            else pauseMinutes = delay;
        }

        pageHeaderText = main.textChild("header");

        // Create right order of stimuli/respons
        myPage.setLayout(new BoxLayout(myPage, BoxLayout.Y_AXIS));

        backable = main.booleanAttribute("backable");
        cycling = main.booleanAttribute("looping");

        int sequences = main.intAttribute("repetitions");

        int stimulusHeight = (main.intAttribute("stimulusHeight") * preferredSize.height) / 100;
        //System.out.println("w "+preferredSize.width + " h " +preferredSize.height + " sh " + stimulusHeight);
        int width = preferredSize.width;
        Dimension stimuliDimension = new Dimension(width, stimulusHeight);
        ExtendedElement controlsSource = main.child("playControls");
        boolean useStopButton = false;
        boolean usePauseButton = false;
        boolean autorepeat = false;
        if (controlsSource != null) {
            useStopButton = controlsSource.booleanAttribute("stop");
            usePauseButton = controlsSource.booleanAttribute("pause");
            autorepeat = controlsSource.booleanAttribute("autorepeat");
        }
        int controls = ControlButtons.CONTROL_PLAY | (useStopButton ? ControlButtons.CONTROL_STOP : 0) | (usePauseButton ? ControlButtons.CONTROL_PAUSE : 0) | (autorepeat ? ControlButtons.CONTROL_REPLAY : 0);
        int stimuliPerPage = main.intAttribute("stimuliPerPage");
        myFolderParser = new FolderParser(stimuliDimension, stimuliPerPage, sequences, controls);
        if (!myFolderParser.setSource(myStimuliFolder))
View Full Code Here

        Question nameQuestion = new Question(Question.FREETEXT, m_designer);
        Element nameElement = tempElement(Question.getTypeName(Question.FREETEXT));
        nameElement.setAttribute("name", "What is your name?");
        nameElement.setAttribute("required", "true");
        nameQuestion.load(new ExtendedElement(nameElement, null).addDefaults());
        m_questions.add(nameQuestion);

        Question dateQuestion = new Question(Question.DATE_SELECTION, m_designer);
        Element dateElement = tempElement(Question.getTypeName(Question.DATE_SELECTION));
        dateElement.setAttribute("name", "When where you born?");
        dateElement.setAttribute("required", "true");
        dateQuestion.load(new ExtendedElement(dateElement, null).addDefaults());
        m_questions.add(dateQuestion);

        QuestionGroup lockedGroup = new QuestionGroup(null, m_designer);
        lockedGroup.setReal(true);
        lockedGroup.setLocked(true);
View Full Code Here

            m_designer.show(Designer.MAIN_FORM);
        }
    }

    public ExtendedElement save(ExtendedElement parent) {
        ExtendedElement e = parent.createChildWithName("initial");
        e.createChildWithNameAndText("header", m_headerField.getText());
        m_questions.save(e);
        return e;
    }
View Full Code Here

            m_designer.show(Designer.FINAL_FORM);
        }
    }

    public ExtendedElement save(ExtendedElement parent) {
        ExtendedElement e = parent.getOrCreateChildWithName("timesyncTest");
        if (m_backButton.isSelected())
            e.setAttribute("backable", "true");
        if (m_loopButton.isSelected())
            e.setAttribute("looping", "true");
        if (((Integer) m_repeatField.getValue()).intValue() != 1)
            e.setAttribute("repetitions", m_repeatField.getValue().toString());
        if (m_stopButton.isSelected() || m_pauseButton.isSelected()) {
            ExtendedElement playControlElement = e.createChildWithName("playControls");
            if (m_stopButton.isSelected())
                playControlElement.setAttribute("stop", "true");
            if (m_pauseButton.isSelected())
                playControlElement.setAttribute("pause", "true");
        }

        ExtendedElement questions = m_questions.save(e);

        ExtendedElement lockedGroup = questions.child("questions");
        if (lockedGroup != null) {
            ExtendedElement senderNode = lockedGroup.child("nameSender");
            if (senderNode != null) {
                e.appendChild(senderNode);
                if (!lockedGroup.getElement().hasChildNodes()) {
                    lockedGroup.getParentNode().removeChild(lockedGroup.getElement());
                    lockedGroup = null;
                }
            }
        }
        if (lockedGroup != null) {
            ExtendedElement mouseNode = lockedGroup.child("mouseRecorder");
            if (mouseNode != null) {
                lockedGroup.getParentNode().appendChild(mouseNode.getElement());
                if (!lockedGroup.getElement().hasChildNodes()) {
                    lockedGroup.getParentNode().removeChild(lockedGroup.getElement());
                    lockedGroup = null;
                }
            }
View Full Code Here

    public void load(ExtendedElement e) {
        m_backButton.setSelected(e.booleanAttribute("backable"));
        m_loopButton.setSelected(e.booleanAttribute("looping"));
        m_repeatField.setValue(new Integer(e.intAttribute("repetitions")));
        ExtendedElement controls = e.child("playControls");
        if (controls != null) {
            m_stopButton.setSelected(controls.booleanAttribute("stop"));
            m_pauseButton.setSelected(controls.booleanAttribute("pause"));
        }
        m_questions.load(e.child("questions"));

        Question mouseQuestion;
        QuestionGroup lockedGroup;

        Iterator<Question> iter = m_questions.iterator();
        if (!iter.hasNext() || (mouseQuestion = iter.next()).getType() != Question.MOUSE_RECORDER) {
            mouseQuestion = new Question(Question.MOUSE_RECORDER, m_designer);
            m_questions.add(mouseQuestion);
        }

        lockedGroup = new QuestionGroup(null, m_designer);
        lockedGroup.setReal(true);

        Question senderQuestion = new Question(Question.NAME_SENDER, m_designer);
        ExtendedElement sender = e.child(Question.getTypeName(Question.NAME_SENDER));
        if (sender != null)
            senderQuestion.load(sender);

        m_questions.insert(senderQuestion, 0);
View Full Code Here

TOP

Related Classes of se.kth.speech.skatta.util.ExtendedElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.