Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

In this page you can find the example usage for javax.swing JPanel setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:org.openmicroscopy.shoola.util.ui.search.SearchComponent.java

/**
 * Builds and lays out the tool bar./*w  ww  . ja v  a 2  s  .c o m*/
 * 
 * @return See above.
 */
private JPanel buildToolBar() {
    JPanel bar = new JPanel();
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.setBorder(null);
    bar.add(searchButton);
    bar.add(Box.createRigidArea(H_SPACER_SIZE));
    bar.add(cancelButton);
    JPanel p = UIUtilities.buildComponentPanel(bar);
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    return p;
}

From source file:org.openmicroscopy.shoola.util.ui.search.SearchComponent.java

/** 
 * Lays out the components indicating the status.
 * //from  w  ww.  j ava  2s .c  o m
 * @return See above.
 */
private JPanel buildStatusBar() {
    JPanel bar = new JPanel();
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS));
    bar.add(progressLabel);
    JPanel p = UIUtilities.buildComponentPanelCenter(busyLabel);
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.add(p);
    return bar;
}

From source file:org.openmicroscopy.shoola.util.ui.search.SearchComponent.java

/** 
 * Builds and lays out the UI. // w w w. jav a  2  s  .  c  o m
 * 
 * @param showControl   Pass <code>true</code> to display the buttons,
 *                   <code>false</code> otherwise.
 */
private void buildGUI(boolean showControl) {
    setBackground(UIUtilities.BACKGROUND_COLOR);
    double[][] size = { { TableLayout.PREFERRED }, { TableLayout.PREFERRED, TableLayout.PREFERRED,
            TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED } };
    setLayout(new TableLayout(size));
    int i = 0;
    String key = "0, ";
    add(uiDelegate, key + i);
    i++;
    if (showControl) {
        add(buildToolBar(), key + i);
    }
    i++;
    add(buildStatusBar(), key + i);
    resultPane = new JPanel();
    resultPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    resultPane.setLayout(new BoxLayout(resultPane, BoxLayout.Y_AXIS));
    JPanel sep = new SeparatorPane();
    sep.setBackground(UIUtilities.BACKGROUND_COLOR);
    i++;
    add(sep, key + i);
    i++;
    add(resultPane, key + i);
}

From source file:org.openstatic.irc.client.O5Client.java

public void addPanel(String panel_caption, Component panel) {
    final JPanel plugin_pane = new JPanel(new BorderLayout());
    plugin_pane.add(panel, BorderLayout.CENTER);
    plugin_pane.setForeground(Color.WHITE);
    plugin_pane.setBackground(Color.GRAY);
    JButton close_button = new JButton("Close Tab");
    close_button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tabbed.remove(plugin_pane);/* w ww. j  a v a  2  s  .co m*/
        }
    });

    /*
    JPanel sub_layout = new JPanel(new BorderLayout())
    {
    public void paintComponent(Graphics g)
    {
        g.drawImage(placebo_icon, 2, 2, 24, 24, null);
    }
    };
    sub_layout.add(close_button, BorderLayout.EAST);
    plugin_pane.add(sub_layout, BorderLayout.PAGE_END);
    */

    tabbed.addTab(panel_caption, null, plugin_pane, "");
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

public PreviewPane(final boolean init) {
    messages = new Messages(getLocale(), SwingPreviewModule.BUNDLE_NAME,
            ObjectUtilities.getClassLoader(SwingPreviewModule.class));
    sizeLimiter = new WindowSizeLimiter();
    zoomActions = new HashMap<ActionCategory, ZoomAction[]>();

    this.menus = PreviewPane.EMPTY_MENU;
    setLayout(new BorderLayout());

    zoomModel = new KeyedComboBoxModel();
    zoomModel.setAllowOtherValue(true);// w w  w.ja  va  2s .  c o  m
    zoom = PreviewPane.ZOOM_FACTORS[PreviewPane.DEFAULT_ZOOM_INDEX];

    final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
    minZoom = getMinimumZoom(configuration);
    maxZoom = getMaximumZoom(configuration);

    pageDrawable = new PageBackgroundDrawable();

    drawablePanel = new PreviewDrawablePanel();
    drawablePanel.setOpaque(false);
    drawablePanel.setBackground(null);
    drawablePanel.setDoubleBuffered(true);
    drawablePanel.setDrawableAsRawObject(pageDrawable);
    drawablePanel.addReportMouseListener(new HyperLinkEventProcessor());

    swingGuiContext = new PreviewGuiContext();

    final JPanel reportPaneHolder = new ScrollablePanel();
    reportPaneHolder.setOpaque(false);
    reportPaneHolder.setBackground(null);
    reportPaneHolder.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    reportPaneHolder.add(drawablePanel);

    reportPaneScrollPane = new JScrollPane(reportPaneHolder);
    reportPaneScrollPane.getVerticalScrollBar().setUnitIncrement(20);
    reportPaneScrollPane.setBackground(null);
    reportPaneScrollPane.setOpaque(false);
    reportPaneScrollPane.getViewport().setOpaque(false);
    ((JComponent) reportPaneScrollPane.getViewport().getView()).setOpaque(false);

    toolbarHolder = new JPanel();
    toolbarHolder.setLayout(new BorderLayout());

    outerReportControllerHolder = new JPanel();
    outerReportControllerHolder.setOpaque(false);
    outerReportControllerHolder.setBackground(null);
    outerReportControllerHolder.setLayout(new BorderLayout());
    outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
    outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
    add(outerReportControllerHolder, BorderLayout.CENTER);

    addPropertyChangeListener(new PreviewUpdateHandler());
    addPropertyChangeListener("zoom", new UpdateZoomHandler()); //$NON-NLS-1$
    statusListener = new PreviewPaneStatusListener();

    zoomSelectorBox = createZoomSelector(this);
    setReportController(new ParameterReportController());
    if (init) {
        initializeWithoutJob();
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

private void createDialog() {

    if (getParent() instanceof XulDialog) {
        Object parentObj = ((SwingDialog) getParent()).getDialog();
        dialog = new JDialog((Dialog) parentObj);
        centerComp = (Component) parentObj;
    } else if (getParent() instanceof XulWindow) {

        Object parentObj = getParent().getManagedObject();
        dialog = new JDialog((Frame) parentObj);
        centerComp = (Component) parentObj;
    } else {/*from  ww w. j  a  va2s.com*/

        Document doc = getDocument();
        Element rootElement = doc.getRootElement();
        XulWindow window = null;
        if (rootElement != this) { // dialog is root, no JFrame Parent
            window = (XulWindow) rootElement;
        }

        if (window != null) {
            frame = (JFrame) window.getManagedObject();
            dialog = new JDialog(frame);
            centerComp = frame;
        } else {

            final Object context = domContainer.getOuterContext();
            if (context instanceof JFrame) {
                frame = (JFrame) context;
                centerComp = (Component) context;
                dialog = new JDialog(frame);
            } else if (context instanceof JDialog) {
                dialog = new JDialog((JDialog) context);
                centerComp = (Component) context;
            } else if (context instanceof JComponent) {
                dialog = new JDialog();
                centerComp = (Component) context;
            } else {
                dialog = new JDialog();
            }
        }
    }

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setResizable(getResizable());
    dialog.setLayout(new BorderLayout());

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setOpaque(true);
    int pad = (this.getPadding() > -1) ? getPadding() : 3;
    mainPanel.setBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad));

    dialog.setTitle(title);
    dialog.setModal(isModal());
    dialog.add(mainPanel, BorderLayout.CENTER);
    mainPanel.add(container, BorderLayout.CENTER);
    container.setOpaque(false);

    if (this.header != null) {

        JPanel headerPanel = new JPanel(new BorderLayout());
        headerPanel.setBackground(Color.decode("#5F86C0"));
        headerPanel.setOpaque(true);
        JPanel headerPanelInner = new JPanel(new BorderLayout());
        headerPanelInner.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
        headerPanelInner.setOpaque(false);

        headerPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.decode("#8FB1E5"),
                Color.decode("#446CA9")));

        JLabel title = new JLabel(this.header.getTitle());

        title.setForeground(Color.white);
        headerPanelInner.add(title, BorderLayout.WEST);

        JLabel desc = new JLabel(this.header.getDescription());
        desc.setForeground(Color.white);
        headerPanelInner.add(desc, BorderLayout.EAST);

        headerPanel.add(headerPanelInner, BorderLayout.CENTER);

        mainPanel.add(headerPanel, BorderLayout.NORTH);
    }

    populateButtonPanel();
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setSize(new Dimension(getWidth(), getHeight()));
    dialog.setPreferredSize(new Dimension(getWidth(), getHeight()));
    dialog.setMinimumSize(new Dimension(getWidth(), getHeight()));

    if (this.getBgcolor() != null) {
        mainPanel.setBackground(Color.decode(this.getBgcolor()));
    }

}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    // No file selected before, popup a dialog and query the user which file to open.
    if (file == null) {
        String path = System.getProperty("user.home");
        if (AppContext.getLastSelectedFolder() != null) {
            path = AppContext.getLastSelectedFolder();
        }/*  ww  w  . ja v a  2s.c  om*/
        JFileChooser fc = new JFileChooser(path);
        fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name"));
        fc.setFileFilter(new FefaultFileFilter());
        int result = fc.showOpenDialog(win);
        if (result == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFile() == null)
                return;
            file = fc.getSelectedFile();
            AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath());
        } else {
            return;
        }
    }

    final JWindow topWindow = new JWindow();
    topWindow.setSize(390, 50);
    topWindow.setLayout(new BorderLayout());
    topWindow.setBackground(Color.WHITE);

    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    content.setBackground(Color.WHITE);
    final JLabel infoLabel = new JLabel(
            resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName());
    infoLabel.setVerticalAlignment(SwingConstants.CENTER);
    content.add(infoLabel, BorderLayout.SOUTH);

    final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content);
    busyPanel.setBusy(true);

    topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER);
    topWindow.setLocationRelativeTo(null);
    topWindow.add(busyPanel, BorderLayout.CENTER);

    final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {

        @Override
        protected Boolean doInBackground() {
            topWindow.setVisible(true);
            doOpen();
            return Boolean.valueOf(true);
        }

        @Override
        protected void done() {
            topWindow.setVisible(false);
            topWindow.dispose();
            for (Runnable r : postConfigurators) {
                SwingUtilities.invokeLater(r);
            }
        }
    };

    worker.execute();

}

From source file:org.processmining.framework.log.filter.LogEventLogFilterEnh.java

/**
 * Returns a Panel for the setting of parameters. When a LogFilter can be
 * added to a list in the framework. This panel is shown, and parameters can
 * be set. When the dialog is closed, a new instance of a LogFilter is
 * created by the framework by calling the <code>getNewLogFilter</code>
 * method of the dialog./*from ww w .  ja va 2  s.  co m*/
 * 
 * @param summary
 *            A LogSummary to be used for setting parameters.
 * @return JPanel
 */
public LogFilterParameterDialog getParameterDialog(LogSummary summary) {
    return new LogFilterParameterDialog(summary, LogEventLogFilterEnh.this) {

        LogEventCheckBoxEnh[] checks;
        JSpinner percTaskSpinner;
        JSpinner percPiSpinner;
        JComboBox choiceBox;

        /**
         * Keep the statistics for all the tasks
         */
        SummaryStatistics taskStatistics = null;

        /**
         * Keep the statistics for the occurrence of tasks in process
         * instances
         */
        SummaryStatistics piStatistics = null;

        public LogFilter getNewLogFilter() {
            LogEvents e = new LogEvents();
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    e.add(checks[i].getLogEvent());
                }
            }
            return new LogEventLogFilterEnh(e, getDoubleValueFromSpinner(percTaskSpinner.getValue()),
                    getDoubleValueFromSpinner(percPiSpinner.getValue()),
                    choiceBox.getSelectedItem().toString());
        }

        protected JPanel getPanel() {
            // add message to the test log for this plugin
            Message.add("<EnhEvtLogFilter>", Message.TEST);
            // statistics
            taskStatistics = SummaryStatistics.newInstance();
            piStatistics = SummaryStatistics.newInstance();
            // Set up an percentformatter
            NumberFormat percentFormatter = NumberFormat.getPercentInstance();
            percentFormatter.setMinimumFractionDigits(2);
            percentFormatter.setMaximumFractionDigits(2);
            // Instantiate the spinners
            percTaskSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            percPiSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            // generate the buttons that are needed
            JButton jButtonCalculate = new JButton("Calculate");
            JButton jButtonInvert = new JButton("Invert selection");
            // set up a choicebox to indicate whether the relationship
            // between the two
            // percentages is AND or OR.

            percTaskSpinner.setValue(new Double(percentageTask));
            percPiSpinner.setValue(new Double(percentagePI));

            choiceBox = new JComboBox();
            choiceBox.addItem("AND");
            choiceBox.addItem("OR");
            choiceBox.setSelectedItem(selectedItemComboBox);

            // Some values that are needed for the sequel.
            int size = summary.getLogEvents().size();
            // For the new log reader sumATEs should be calculated in
            // another way
            int sumATEs = 0;
            if (summary instanceof ExtendedLogSummary) {
                sumATEs = summary.getNumberOfAuditTrailEntries();
            } else if (summary instanceof LightweightLogSummary) {
                HashSet<ProcessInstance> pis = new HashSet<ProcessInstance>();
                Iterator logEvents = summary.getLogEvents().iterator();
                while (logEvents.hasNext()) {
                    LogEvent evt = (LogEvent) logEvents.next();
                    pis.addAll(summary.getInstancesForEvent(evt));
                }
                Iterator pis2 = pis.iterator();
                while (pis2.hasNext()) {
                    ProcessInstance pi = (ProcessInstance) pis2.next();
                    int simPis = MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
                    int numberATEs = pi.getAuditTrailEntryList().size();
                    sumATEs += simPis * numberATEs;
                    pi.isEmpty();
                }
            } else {

            }
            // calculate the number of process Instances, taking into
            // account
            // the number of similar instances
            int sumPIs = 0;
            if (summary instanceof LightweightLogSummary) {
                sumPIs = calculateSumPIs(summary);
            }
            checks = new LogEventCheckBoxEnh[size];

            // create panels and labels
            JPanel global = new JPanel(new BorderLayout());
            JPanel sub2 = new JPanel(new BorderLayout());
            sub2.setBackground(Color.white);
            JLabel labelPercTask = new JLabel("percentage task");
            JLabel labelPercPI = new JLabel("percentage PI");

            // create panel sub1 to put the checkboxes on
            JPanel sub1 = new JPanel(new SpringLayout());
            sub1.setBackground(Color.lightGray);

            // Get percentage of task in the log and percentage of in how
            // many
            // different PIs it appears.
            Iterator it = summary.getLogEvents().iterator();
            int i = 0;
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                double percent = 0.0;
                if (summary instanceof ExtendedLogSummary) {
                    percent = ((double) evt.getOccurrenceCount() / (double) sumATEs);
                } else if (summary instanceof LightweightLogSummary) {
                    Set instances = summary.getInstancesForEvent(evt);
                    // getFrequencyTasks(evt, instances)
                    percent = (double) getFrequencyTasks(evt, instances) / (double) sumATEs;
                } else {

                }
                // String percString = percentFormatter.format(percent);
                LogEventCheckBoxEnh check = new LogEventCheckBoxEnh(evt);
                check.setPercentageTask(percent * 100);
                // add percentage to the statistics for the tasks
                taskStatistics.addValue(percent);
                // Get percentage of in how many different PIs a task
                // appears,
                // taking into account whether the new or old logreader is
                // used
                if (summary instanceof LightweightLogSummary) {
                    Set<ProcessInstance> pis = summary.getInstancesForEvent(evt);
                    int numberInstancesTask = 0;
                    Iterator it2 = pis.iterator();
                    while (it2.hasNext()) {
                        ProcessInstance pi = (ProcessInstance) it2.next();
                        numberInstancesTask += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                    double fPI = (double) numberInstancesTask / (double) sumPIs;

                    check.setPercentagePI(fPI * 100);
                    // add percentage to the statistics for the PIs
                    piStatistics.addValue(fPI);
                } else if (summary instanceof ExtendedLogSummary) {
                    double percPIcheck = getPercentagePI(evt);
                    check.setPercentagePI(percPIcheck);
                    piStatistics.addValue(percPIcheck / 100);
                } else {
                    // raise exception, unknown logreader
                }
                // add to the checks array
                checks[i++] = check;
            }
            // fill sub1 with statistics information
            sub1.add(new JLabel(" Statistics    ( #tasks = " + taskStatistics.getN() + " )"));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" Arithmetic Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMean())));
            sub1.add(new JLabel(" Geometric Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getGeometricMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getGeometricMean())));
            sub1.add(new JLabel(" Standard Deviation "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getStandardDeviation())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getStandardDeviation())));
            sub1.add(new JLabel(" Min "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMin())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMin())));
            sub1.add(new JLabel(" Max "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMax())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMax())));
            sub1.add(new JLabel(" ------------------ "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" Tasks "));
            sub1.add(new JLabel(" percentage task "));
            sub1.add(new JLabel(" percentage PI "));
            // generate messages for the test case for this plugin
            Message.add("number tasks: " + taskStatistics.getN(), Message.TEST);
            Message.add("<percentage task>", Message.TEST);
            Message.add("arithmetic mean: " + taskStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + taskStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + taskStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + taskStatistics.getMin(), Message.TEST);
            Message.add("max: " + taskStatistics.getMax(), Message.TEST);
            Message.add("<percentage task/>", Message.TEST);
            Message.add("<percentage PI>", Message.TEST);
            Message.add("arithmetic mean: " + piStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + piStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + piStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + piStatistics.getMin(), Message.TEST);
            Message.add("max: " + piStatistics.getMax(), Message.TEST);
            Message.add("<percentage PI/>", Message.TEST);
            // add the checkboxes to the GUI.
            Arrays.sort(checks);
            for (i = 0; i < checks.length; i++) {
                sub1.add(checks[i]);
                if ((eventsToKeep != null) && (!eventsToKeep.contains(checks[i].getLogEvent()))) {
                    checks[i].setSelected(false);
                }
                // put the percentages on the GUI
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentageTask() / 100)));
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentagePI() / 100)));
            }
            //
            SpringUtilities util = new SpringUtilities();
            util.makeCompactGrid(sub1, checks.length + 8, 3, 3, 3, 8, 3);
            // put the contents on the respective panels
            global.add(sub2, java.awt.BorderLayout.CENTER);
            global.add(sub1, java.awt.BorderLayout.SOUTH);
            //
            JPanel sub21 = new JPanel(new SpringLayout());
            // sub21.setLayout(new BoxLayout(sub21, BoxLayout.PAGE_AXIS));
            sub2.setBackground(Color.red);
            JPanel textPanel = new JPanel(new BorderLayout());
            textPanel.setBackground(Color.yellow);
            JPanel sub221 = new JPanel(new FlowLayout());
            sub221.setBackground(Color.yellow);
            JPanel sub222 = new JPanel(new FlowLayout());
            sub222.setBackground(Color.yellow);
            // two different panels to be places on sub21
            // JPanel sub21First = new JPanel();
            // sub21First.setLayout(new BoxLayout(sub21First,
            // BoxLayout.LINE_AXIS));
            // sub21First.setMaximumSize(new Dimension(1000, 25));
            // sub21First.add(Box.createHorizontalGlue());
            // sub21First.add(labelPercTask);
            // sub21First.add(percTaskSpinner, null);
            // percTaskSpinner.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(jButtonCalculate);
            // jButtonCalculate.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(labelPercPI);
            // sub21First.add(percPiSpinner, null);
            // percPiSpinner.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(choiceBox);
            // choiceBox.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(Box.createHorizontalGlue());
            // JPanel sub21Second = new JPanel();
            // sub21Second.setLayout(new BoxLayout(sub21Second,
            // BoxLayout.LINE_AXIS));
            // sub21Second.setMaximumSize(new Dimension(1000, 25));
            // sub21Second.add(Box.createHorizontalGlue());
            // sub21Second.add(jButtonInvert);
            // sub21Second.add(Box.createHorizontalGlue());
            //
            // sub21.add(sub21First);
            // sub21.add(sub21Second);

            sub21.add(labelPercTask);
            sub21.add(percTaskSpinner, null);
            sub21.add(jButtonCalculate);
            sub21.add(labelPercPI);
            sub21.add(percPiSpinner, null);
            sub21.add(choiceBox);
            // add the invert button
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(jButtonInvert);
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.setMaximumSize(sub21.getPreferredSize());
            sub2.add(sub21, java.awt.BorderLayout.CENTER);
            sub2.add(textPanel, java.awt.BorderLayout.SOUTH);
            textPanel.add(new JLabel(
                    "The Calculate button needs to be clicked to calculate which tasks need to be selected!!!"),
                    java.awt.BorderLayout.CENTER);
            textPanel.add(
                    new JLabel("Clicking the OK button only accepts, but nothing is again calculated!!!!"),
                    java.awt.BorderLayout.SOUTH);
            util.makeCompactGrid(sub21, 2, 6, 3, 3, 8, 3);
            //

            // specify button action for the button ButtonPreview
            jButtonCalculate.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // The preview button is clicked
                    buttonClicked();
                    // end for
                }
            });

            // specify button action for the button Invert
            jButtonInvert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    invertButtonClicked();
                }
            });

            return global;

        }

        /**
         * When the preview button is clicked
         */
        public void buttonClicked() {
            for (int k = 0; k < checks.length; k++) {
                boolean firstCheck = false;
                boolean secondCheck = false;
                LogEventCheckBoxEnh c = checks[k];
                // check for the task in c whether its percentage is higher
                // than
                // perc
                firstCheck = checkTask(c, percTaskSpinner.getValue());

                // Also check whether the task occurs in more than percTr
                // percent of the traces
                secondCheck = checkPI(c, percPiSpinner.getValue());

                // Check whether for choiceBox OR or AND is selected
                boolean logicalResult = true;
                if (((String) choiceBox.getSelectedItem()).equals("AND")) {
                    logicalResult = firstCheck && secondCheck;
                } else if (((String) choiceBox.getSelectedItem()).equals("OR")) {
                    logicalResult = firstCheck || secondCheck;
                }
                // set the checkbox selected or not
                if (logicalResult == true) {
                    c.setSelected(true);
                } else {
                    c.setSelected(false);
                }
            }
            // add messages to the test log for this case
            int numberCheckedBoxes = 0;
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    numberCheckedBoxes++;
                }
            }
            Message.add("number of selected tasks: " + numberCheckedBoxes, Message.TEST);
            Message.add("<EnhEvtLogFilter/>", Message.TEST);
        }

        /**
         *
         */
        public void invertButtonClicked() {
            for (int i = 0; i < checks.length; i++) {
                checks[i].setSelected(!checks[i].isSelected());
            }
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in
         * the log than the percentage given by percTask.
         * 
         * @param c
         *            LogEventCheckBoxEnh the checkbox that contains the
         *            task.
         * @param percTask
         *            Object the percentage
         * @return boolean True if the percentage of which the task in c
         *         occurs in the log is greater or equal than percTaks,
         *         false otherwise.
         */
        private boolean checkTask(LogEventCheckBoxEnh c, Object percTask) {
            boolean returnBoolean = false;
            double percT = 0.0;
            percT = getDoubleValueFromSpinner(percTask);
            // check whether its percentage is higher than percT
            if (c.getPercentageTask() >= percT) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in
         * different process instances than the percentage given by
         * percTrace.
         * 
         * @param c
         *            LogEventCheckBoxEnh the checkbox that contains the
         *            task.
         * @param percTrace
         *            Object the percentage.
         * @return boolean True, if the percentage of which the task in
         *         different process instances occurs in the log is greater
         *         or equal than percTrace, false otherwise.
         */
        private boolean checkPI(LogEventCheckBoxEnh c, Object percPIobj) {
            boolean returnBoolean = false;
            double percPI = 0.0;

            percPI = getDoubleValueFromSpinner(percPIobj);
            // check whether its percentage is higher than percPI
            if (c.getPercentagePI() >= percPI) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Get the percentage of that this task occurs in different PIs
         * 
         * @param evt
         *            LogEvent the logEvent in which the task can be found
         * @return double the percentage of which this task in the log
         *         occurs
         */
        private double getPercentagePI(LogEvent evt) {
            double returnPercent = 0.0;
            HashMap mapping = ((ExtendedLogSummary) summary).getMappingAtesToNumberPIs();
            int numberPI = summary.getNumberOfProcessInstances();

            // Get the frequency of PI in which the task occurs
            Object value = null;
            Iterator it = mapping.keySet().iterator();
            while (it.hasNext()) {
                Object keyObj = it.next();
                String key = (String) keyObj;
                if (key.equals(
                        evt.getModelElementName().trim() + " " + "(" + evt.getEventType().trim() + ")")) {
                    value = mapping.get(keyObj);
                    break;
                }
            }

            if (value != null) {
                // calculate frequency
                returnPercent = (((Integer) value).doubleValue() / new Double(numberPI).doubleValue()) * 100;
            }

            return returnPercent;
        }

        private int getFrequencyTasks(LogEvent evt, Set instances) {
            int returnFrequency = 0;
            Iterator instIterator = instances.iterator();
            while (instIterator.hasNext()) {
                ProcessInstance pi = (ProcessInstance) instIterator.next();
                Iterator ates = pi.getAuditTrailEntryList().iterator();
                while (ates.hasNext()) {
                    AuditTrailEntry ate = (AuditTrailEntry) ates.next();
                    if (ate.getElement().trim().equals(evt.getModelElementName().trim())
                            && ate.getType().equals(evt.getEventType())) {
                        returnFrequency += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                }
            }
            return returnFrequency;
        }

        /**
         * Gets the double value of an object, provided that value is a
         * Double or Long object
         * 
         * @param value
         *            Object
         * @return double the double value
         */
        private double getDoubleValueFromSpinner(Object value) {
            double returnDouble = 0.0;

            if (value instanceof Long) {
                returnDouble = (((Long) value).doubleValue());
            } else if (value instanceof Double) {
                returnDouble = (((Double) value).doubleValue());
            }

            return returnDouble;
        }

        /**
         * Returns the number of process instances, taking into account the
         * number of similar instances
         * 
         * @param summary
         *            LogSummary the log summary
         * @return int the number of process instances
         */
        private int calculateSumPIs(LogSummary summary) {
            int returnSum = 0;
            HashSet pis = new HashSet<ProcessInstance>();
            Iterator it = summary.getLogEvents().iterator();
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                pis.addAll(summary.getInstancesForEvent(evt));
            }
            // for each process instance in pis, get the number of similar
            // instances
            Iterator it2 = pis.iterator();
            while (it2.hasNext()) {
                ProcessInstance pi = (ProcessInstance) it2.next();
                returnSum += MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
            }
            return returnSum;
        }

        protected boolean getAllParametersSet() {
            // calculate values
            // buttonClicked();
            return true;
        }

    };
}

From source file:org.prom5.framework.log.filter.LogEventLogFilterEnh.java

/**
 * Returns a Panel for the setting of parameters. When a LogFilter can be
 * added to a list in the framework. This panel is shown, and parameters can
 * be set. When the dialog is closed, a new instance of a LogFilter is
 * created by the framework by calling the <code>getNewLogFilter</code> method
 * of the dialog./*from   w w w  . j  a va  2  s  .c o  m*/
 *
 * @param summary A LogSummary to be used for setting parameters.
 * @return JPanel
 */
public LogFilterParameterDialog getParameterDialog(LogSummary summary) {
    return new LogFilterParameterDialog(summary, LogEventLogFilterEnh.this) {

        LogEventCheckBoxEnh[] checks;
        JSpinner percTaskSpinner;
        JSpinner percPiSpinner;
        JComboBox choiceBox;

        /**
         * Keep the statistics for all the tasks
         */
        SummaryStatistics taskStatistics = null;

        /**
         * Keep the statistics for the occurrence of tasks in process instances
         */
        SummaryStatistics piStatistics = null;

        public LogFilter getNewLogFilter() {
            LogEvents e = new LogEvents();
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    e.add(checks[i].getLogEvent());
                }
            }
            return new LogEventLogFilterEnh(e, getDoubleValueFromSpinner(percTaskSpinner.getValue()),
                    getDoubleValueFromSpinner(percPiSpinner.getValue()),
                    choiceBox.getSelectedItem().toString());
        }

        protected JPanel getPanel() {
            // add message to the test log for this plugin
            Message.add("<EnhEvtLogFilter>", Message.TEST);
            // statistics
            taskStatistics = SummaryStatistics.newInstance();
            piStatistics = SummaryStatistics.newInstance();
            // Set up an percentformatter
            NumberFormat percentFormatter = NumberFormat.getPercentInstance();
            percentFormatter.setMinimumFractionDigits(2);
            percentFormatter.setMaximumFractionDigits(2);
            // Instantiate the spinners
            percTaskSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            percPiSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            // generate the buttons that are needed
            JButton jButtonCalculate = new JButton("Calculate");
            JButton jButtonInvert = new JButton("Invert selection");
            // set up a choicebox to indicate whether the relationship between the two
            // percentages is AND or OR.

            percTaskSpinner.setValue(new Double(percentageTask));
            percPiSpinner.setValue(new Double(percentagePI));

            choiceBox = new JComboBox();
            choiceBox.addItem("AND");
            choiceBox.addItem("OR");
            choiceBox.setSelectedItem(selectedItemComboBox);

            // Some values that are needed for the sequel.
            int size = summary.getLogEvents().size();
            // For the new log reader sumATEs should be calculated in another way
            int sumATEs = 0;
            if (summary instanceof ExtendedLogSummary) {
                sumATEs = summary.getNumberOfAuditTrailEntries();
            } else if (summary instanceof LightweightLogSummary) {
                HashSet<ProcessInstance> pis = new HashSet<ProcessInstance>();
                Iterator logEvents = summary.getLogEvents().iterator();
                while (logEvents.hasNext()) {
                    LogEvent evt = (LogEvent) logEvents.next();
                    pis.addAll(summary.getInstancesForEvent(evt));
                }
                Iterator pis2 = pis.iterator();
                while (pis2.hasNext()) {
                    ProcessInstance pi = (ProcessInstance) pis2.next();
                    int simPis = MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
                    int numberATEs = pi.getAuditTrailEntryList().size();
                    sumATEs += simPis * numberATEs;
                    pi.isEmpty();
                }
            } else {

            }
            // calculate the number of process Instances, taking into account
            // the number of similar instances
            int sumPIs = 0;
            if (summary instanceof LightweightLogSummary) {
                sumPIs = calculateSumPIs(summary);
            }
            checks = new LogEventCheckBoxEnh[size];

            // create panels and labels
            JPanel global = new JPanel(new BorderLayout());
            JPanel sub2 = new JPanel(new BorderLayout());
            sub2.setBackground(Color.white);
            JLabel labelPercTask = new JLabel("percentage task");
            JLabel labelPercPI = new JLabel("percentage PI");

            // create panel sub1 to put the checkboxes on
            JPanel sub1 = new JPanel(new SpringLayout());
            sub1.setBackground(Color.lightGray);

            // Get percentage of task in the log and percentage of in how many
            // different PIs it appears.
            Iterator it = summary.getLogEvents().iterator();
            int i = 0;
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                double percent = 0.0;
                if (summary instanceof ExtendedLogSummary) {
                    percent = ((double) evt.getOccurrenceCount() / (double) sumATEs);
                } else if (summary instanceof LightweightLogSummary) {
                    Set instances = summary.getInstancesForEvent(evt);
                    // getFrequencyTasks(evt, instances)
                    percent = (double) getFrequencyTasks(evt, instances) / (double) sumATEs;
                } else {

                }
                //String percString = percentFormatter.format(percent);
                LogEventCheckBoxEnh check = new LogEventCheckBoxEnh(evt);
                check.setPercentageTask(percent * 100);
                // add percentage to the statistics for the tasks
                taskStatistics.addValue(percent);
                // Get percentage of in how many different PIs a task appears,
                // taking into account whether the new or old logreader is used
                if (summary instanceof LightweightLogSummary) {
                    Set<ProcessInstance> pis = summary.getInstancesForEvent(evt);
                    int numberInstancesTask = 0;
                    Iterator it2 = pis.iterator();
                    while (it2.hasNext()) {
                        ProcessInstance pi = (ProcessInstance) it2.next();
                        numberInstancesTask += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                    double fPI = (double) numberInstancesTask / (double) sumPIs;

                    check.setPercentagePI(fPI * 100);
                    // add percentage to the statistics for the PIs
                    piStatistics.addValue(fPI);
                } else if (summary instanceof ExtendedLogSummary) {
                    double percPIcheck = getPercentagePI(evt);
                    check.setPercentagePI(percPIcheck);
                    piStatistics.addValue(percPIcheck / 100);
                } else {
                    // raise exception, unknown logreader
                }
                // add to the checks array
                checks[i++] = check;
            }
            // fill sub1 with statistics information
            sub1.add(new JLabel(" Statistics    ( #tasks = " + taskStatistics.getN() + " )"));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" Arithmetic Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMean())));
            sub1.add(new JLabel(" Geometric Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getGeometricMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getGeometricMean())));
            sub1.add(new JLabel(" Standard Deviation "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getStandardDeviation())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getStandardDeviation())));
            sub1.add(new JLabel(" Min "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMin())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMin())));
            sub1.add(new JLabel(" Max "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMax())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMax())));
            sub1.add(new JLabel(" ------------------ "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" Tasks "));
            sub1.add(new JLabel(" percentage task "));
            sub1.add(new JLabel(" percentage PI "));
            // generate messages for the test case for this plugin
            Message.add("number tasks: " + taskStatistics.getN(), Message.TEST);
            Message.add("<percentage task>", Message.TEST);
            Message.add("arithmetic mean: " + taskStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + taskStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + taskStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + taskStatistics.getMin(), Message.TEST);
            Message.add("max: " + taskStatistics.getMax(), Message.TEST);
            Message.add("<percentage task/>", Message.TEST);
            Message.add("<percentage PI>", Message.TEST);
            Message.add("arithmetic mean: " + piStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + piStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + piStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + piStatistics.getMin(), Message.TEST);
            Message.add("max: " + piStatistics.getMax(), Message.TEST);
            Message.add("<percentage PI/>", Message.TEST);
            // add the checkboxes to the GUI.
            Arrays.sort(checks);
            for (i = 0; i < checks.length; i++) {
                sub1.add(checks[i]);
                if ((eventsToKeep != null) && (!eventsToKeep.contains(checks[i].getLogEvent()))) {
                    checks[i].setSelected(false);
                }
                // put the percentages on the GUI
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentageTask() / 100)));
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentagePI() / 100)));
            }
            //
            SpringUtilities util = new SpringUtilities();
            util.makeCompactGrid(sub1, checks.length + 8, 3, 3, 3, 8, 3);
            // put the contents on the respective panels
            global.add(sub2, java.awt.BorderLayout.CENTER);
            global.add(sub1, java.awt.BorderLayout.SOUTH);
            //
            JPanel sub21 = new JPanel(new SpringLayout());
            //sub21.setLayout(new BoxLayout(sub21, BoxLayout.PAGE_AXIS));
            sub2.setBackground(Color.red);
            JPanel textPanel = new JPanel(new BorderLayout());
            textPanel.setBackground(Color.yellow);
            JPanel sub221 = new JPanel(new FlowLayout());
            sub221.setBackground(Color.yellow);
            JPanel sub222 = new JPanel(new FlowLayout());
            sub222.setBackground(Color.yellow);
            // two different panels to be places on sub21
            //JPanel sub21First = new JPanel();
            //sub21First.setLayout(new BoxLayout(sub21First, BoxLayout.LINE_AXIS));
            //sub21First.setMaximumSize(new Dimension(1000, 25));
            //sub21First.add(Box.createHorizontalGlue());
            //sub21First.add(labelPercTask);
            //sub21First.add(percTaskSpinner, null);
            //percTaskSpinner.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(jButtonCalculate);
            //jButtonCalculate.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(labelPercPI);
            //sub21First.add(percPiSpinner, null);
            //percPiSpinner.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(choiceBox);
            //choiceBox.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(Box.createHorizontalGlue());
            //JPanel sub21Second = new JPanel();
            //sub21Second.setLayout(new BoxLayout(sub21Second, BoxLayout.LINE_AXIS));
            //sub21Second.setMaximumSize(new Dimension(1000, 25));
            //sub21Second.add(Box.createHorizontalGlue());
            //sub21Second.add(jButtonInvert);
            //sub21Second.add(Box.createHorizontalGlue());
            //
            //sub21.add(sub21First);
            //sub21.add(sub21Second);

            sub21.add(labelPercTask);
            sub21.add(percTaskSpinner, null);
            sub21.add(jButtonCalculate);
            sub21.add(labelPercPI);
            sub21.add(percPiSpinner, null);
            sub21.add(choiceBox);
            // add the invert button
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(jButtonInvert);
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.setMaximumSize(sub21.getPreferredSize());
            sub2.add(sub21, java.awt.BorderLayout.CENTER);
            sub2.add(textPanel, java.awt.BorderLayout.SOUTH);
            textPanel.add(new JLabel(
                    "The Calculate button needs to be clicked to calculate which tasks need to be selected!!!"),
                    java.awt.BorderLayout.CENTER);
            textPanel.add(
                    new JLabel("Clicking the OK button only accepts, but nothing is again calculated!!!!"),
                    java.awt.BorderLayout.SOUTH);
            util.makeCompactGrid(sub21, 2, 6, 3, 3, 8, 3);
            //

            // specify button action for the button ButtonPreview
            jButtonCalculate.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // The preview button is clicked
                    buttonClicked();
                    // end for
                }
            });

            // specify button action for the button Invert
            jButtonInvert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    invertButtonClicked();
                }
            });

            return global;

        }

        /**
         * When the preview button is clicked
         */
        public void buttonClicked() {
            for (int k = 0; k < checks.length; k++) {
                boolean firstCheck = false;
                boolean secondCheck = false;
                LogEventCheckBoxEnh c = checks[k];
                // check for the task in c whether its percentage is higher than
                // perc
                firstCheck = checkTask(c, percTaskSpinner.getValue());

                // Also check whether the task occurs in more than percTr
                // percent of the traces
                secondCheck = checkPI(c, percPiSpinner.getValue());

                // Check whether for choiceBox OR or AND is selected
                boolean logicalResult = true;
                if (((String) choiceBox.getSelectedItem()).equals("AND")) {
                    logicalResult = firstCheck && secondCheck;
                } else if (((String) choiceBox.getSelectedItem()).equals("OR")) {
                    logicalResult = firstCheck || secondCheck;
                }
                // set the checkbox selected or not
                if (logicalResult == true) {
                    c.setSelected(true);
                } else {
                    c.setSelected(false);
                }
            }
            // add messages to the test log for this case
            int numberCheckedBoxes = 0;
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    numberCheckedBoxes++;
                }
            }
            Message.add("number of selected tasks: " + numberCheckedBoxes, Message.TEST);
            Message.add("<EnhEvtLogFilter/>", Message.TEST);
        }

        /**
         *
         */
        public void invertButtonClicked() {
            for (int i = 0; i < checks.length; i++) {
                checks[i].setSelected(!checks[i].isSelected());
            }
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in the log
         * than the percentage given by percTask.
         * @param c LogEventCheckBoxEnh the checkbox that contains the task.
         * @param percTask Object the percentage
         * @return boolean True if the percentage of which the task in c occurs
         * in the log is greater or equal than percTaks, false otherwise.
         */
        private boolean checkTask(LogEventCheckBoxEnh c, Object percTask) {
            boolean returnBoolean = false;
            double percT = 0.0;
            percT = getDoubleValueFromSpinner(percTask);
            // check whether its percentage is higher than percT
            if (c.getPercentageTask() >= percT) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in different
         * process instances than the percentage given by percTrace.
         * @param c LogEventCheckBoxEnh the checkbox that contains the task.
         * @param percTrace Object the percentage.
         * @return boolean True, if the percentage of which the task in different
         * process instances occurs in the log is greater or equal than percTrace,
         * false otherwise.
         */
        private boolean checkPI(LogEventCheckBoxEnh c, Object percPIobj) {
            boolean returnBoolean = false;
            double percPI = 0.0;

            percPI = getDoubleValueFromSpinner(percPIobj);
            // check whether its percentage is higher than percPI
            if (c.getPercentagePI() >= percPI) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Get the percentage of that this task occurs in different PIs
         * @param evt LogEvent the logEvent in which the task can be found
         * @return double the percentage of which this task in the log occurs
         */
        private double getPercentagePI(LogEvent evt) {
            double returnPercent = 0.0;
            HashMap mapping = ((ExtendedLogSummary) summary).getMappingAtesToNumberPIs();
            int numberPI = summary.getNumberOfProcessInstances();

            // Get the frequency of PI in which the task occurs
            Object value = null;
            Iterator it = mapping.keySet().iterator();
            while (it.hasNext()) {
                Object keyObj = it.next();
                String key = (String) keyObj;
                if (key.equals(
                        evt.getModelElementName().trim() + " " + "(" + evt.getEventType().trim() + ")")) {
                    value = mapping.get(keyObj);
                    break;
                }
            }

            if (value != null) {
                // calculate frequency
                returnPercent = (((Integer) value).doubleValue() / new Double(numberPI).doubleValue()) * 100;
            }

            return returnPercent;
        }

        private int getFrequencyTasks(LogEvent evt, Set instances) {
            int returnFrequency = 0;
            Iterator instIterator = instances.iterator();
            while (instIterator.hasNext()) {
                ProcessInstance pi = (ProcessInstance) instIterator.next();
                Iterator ates = pi.getAuditTrailEntryList().iterator();
                while (ates.hasNext()) {
                    AuditTrailEntry ate = (AuditTrailEntry) ates.next();
                    if (ate.getElement().trim().equals(evt.getModelElementName().trim())
                            && ate.getType().equals(evt.getEventType())) {
                        returnFrequency += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                }
            }
            return returnFrequency;
        }

        /**
         * Gets the double value of an object, provided that value is a
         * Double or Long object
         * @param value Object
         * @return double the double value
         */
        private double getDoubleValueFromSpinner(Object value) {
            double returnDouble = 0.0;

            if (value instanceof Long) {
                returnDouble = (((Long) value).doubleValue());
            } else if (value instanceof Double) {
                returnDouble = (((Double) value).doubleValue());
            }

            return returnDouble;
        }

        /**
         * Returns the number of process instances, taking into account the
         * number of similar instances
         * @param summary LogSummary the log summary
         * @return int the number of process instances
         */
        private int calculateSumPIs(LogSummary summary) {
            int returnSum = 0;
            HashSet pis = new HashSet<ProcessInstance>();
            Iterator it = summary.getLogEvents().iterator();
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                pis.addAll(summary.getInstancesForEvent(evt));
            }
            // for each process instance in pis, get the number of similar instances
            Iterator it2 = pis.iterator();
            while (it2.hasNext()) {
                ProcessInstance pi = (ProcessInstance) it2.next();
                returnSum += MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
            }
            return returnSum;
        }

        protected boolean getAllParametersSet() {
            // calculate values
            //buttonClicked();
            return true;
        }

    };
}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the UI panel that contains the controls to filter the channel list.
 * // w  w w  .  j av  a2s .  c  om
 * @return  the UI component dealing with filtering
 */
private JComponent createFilterPanel() {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new BorderLayout(5, 5));
    filterPanel.setBackground(Color.white);
    filterPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel filterIconLabel = new JLabel(DataViewer.getIcon("icons/filter.gif"));
    filterPanel.add(filterIconLabel, BorderLayout.WEST);

    filterTextField = new JTextField();
    filterTextField.setToolTipText("Enter text here to filter the channel list");
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            treeModel.setFilter(filterTextField.getText());
        }

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

        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }
    });
    filterPanel.add(filterTextField, BorderLayout.CENTER);

    Action focusFilterAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -2443410059209958411L;

        public void actionPerformed(ActionEvent e) {
            filterTextField.requestFocusInWindow();
            filterTextField.selectAll();
        }
    };

    int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    filterTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F, modifier), "focusFilter");
    filterTextField.getActionMap().put("focusFilter", focusFilterAction);

    Action cancelFilterAction = new AbstractAction(null, DataViewer.getIcon("icons/cancel.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8913797349366699615L;

        public void actionPerformed(ActionEvent e) {
            treeModel.setFilter(null);
        }
    };
    cancelFilterAction.putValue(Action.SHORT_DESCRIPTION, "Cancel filter");

    filterTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelFilter");
    filterTextField.getActionMap().put("cancelFilter", cancelFilterAction);

    clearFilterButton = new JButton(cancelFilterAction);
    clearFilterButton.setBorderPainted(false);
    clearFilterButton.setVisible(false);
    filterPanel.add(clearFilterButton, BorderLayout.EAST);

    return filterPanel;
}