Example usage for java.awt.event MouseEvent getSource

List of usage examples for java.awt.event MouseEvent getSource

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

public void mousePressed(MouseEvent event) {

    if (event.getSource() instanceof JLabel) {

    } else {/*from  w ww  .j a va 2s.c o  m*/
        if (SwingUtilities.isRightMouseButton(event)) {
            String columnName = table.getColumnModel().getColumn(table.columnAtPoint(event.getPoint()))
                    .getHeaderValue().toString();
            SwingUtilities.convertPointFromScreen(event.getPoint(), table);
            spreadsheetPopups.popupMenu(table, event.getX() + 10, event.getY() + 10, columnName);
        }

        if (SwingUtilities.isLeftMouseButton(event)) {
            startRow = table.rowAtPoint(event.getPoint());
            startCol = table.columnAtPoint(event.getPoint());
        }
    }
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;//from w  w  w.j a va  2 s. com
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }

    procReleased(e);
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;/*from  w w  w.  j a v a2 s.co  m*/
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }
    try {
        procReleased(e);
    } catch (Exception ee) {
    }
}

From source file:mt.listeners.InteractiveRANSAC.java

public void CardTable() {
    this.lambdaSB = new Scrollbar(Scrollbar.HORIZONTAL, this.lambdaInt, 1, MIN_SLIDER, MAX_SLIDER + 1);

    maxSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) maxSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    maxDistSB.setValue(/*from  w  w  w.  ja  va2  s . co m*/
            utility.Slicer.computeScrollbarPositionFromValue(maxDist, MIN_Gap, MAX_Gap, scrollbarSize));

    minInliersSB.setValue(utility.Slicer.computeScrollbarPositionFromValue(minInliers, MIN_Inlier, MAX_Inlier,
            scrollbarSize));
    maxErrorSB.setValue(
            utility.Slicer.computeScrollbarPositionFromValue(maxError, MIN_ERROR, MAX_ERROR, scrollbarSize));

    minSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) minSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    lambdaLabel = new Label("Linearity (fraction) = " + new DecimalFormat("#.##").format(lambda), Label.CENTER);
    maxErrorLabel = new Label("Maximum Error (px) = " + new DecimalFormat("#.##").format(maxError) + "      ",
            Label.CENTER);
    minInliersLabel = new Label(
            "Minimum No. of timepoints (tp) = " + new DecimalFormat("#.##").format(minInliers), Label.CENTER);
    maxDistLabel = new Label("Maximum Gap (tp) = " + new DecimalFormat("#.##").format(maxDist), Label.CENTER);

    minSlopeLabel = new Label("Min. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(minSlope),
            Label.CENTER);
    maxSlopeLabel = new Label("Max. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(maxSlope),
            Label.CENTER);
    maxResLabel = new Label(
            "MT is rescued if the start of event# i + 1 > start of event# i by px =  " + this.restolerance,
            Label.CENTER);

    CardLayout cl = new CardLayout();
    Object[] colnames = new Object[] { "Track File", "Growth velocity", "Shrink velocity", "Growth events",
            "Shrink events", "fcat", "fres", "Error" };

    Object[][] rowvalues = new Object[0][colnames.length];

    if (inputfiles != null) {
        rowvalues = new Object[inputfiles.length][colnames.length];
        for (int i = 0; i < inputfiles.length; ++i) {

            rowvalues[i][0] = inputfiles[i].getName();
        }
    }

    table = new JTable(rowvalues, colnames);

    table.setFillsViewportHeight(true);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.isOpaque();
    int size = 100;
    table.getColumnModel().getColumn(0).setPreferredWidth(size);
    table.getColumnModel().getColumn(1).setPreferredWidth(size);
    table.getColumnModel().getColumn(2).setPreferredWidth(size);
    table.getColumnModel().getColumn(3).setPreferredWidth(size);
    table.getColumnModel().getColumn(4).setPreferredWidth(size);
    table.getColumnModel().getColumn(5).setPreferredWidth(size);
    table.getColumnModel().getColumn(6).setPreferredWidth(size);
    table.getColumnModel().getColumn(7).setPreferredWidth(size);
    maxErrorField = new TextField(5);
    maxErrorField.setText(Float.toString(maxError));

    minInlierField = new TextField(5);
    minInlierField.setText(Float.toString(minInliers));

    maxGapField = new TextField(5);
    maxGapField.setText(Float.toString(maxDist));

    maxSlopeField = new TextField(5);
    maxSlopeField.setText(Float.toString(maxSlope));

    minSlopeField = new TextField(5);
    minSlopeField.setText(Float.toString(minSlope));

    maxErrorSB.setSize(new Dimension(SizeX, 20));
    minSlopeSB.setSize(new Dimension(SizeX, 20));
    minInliersSB.setSize(new Dimension(SizeX, 20));
    maxDistSB.setSize(new Dimension(SizeX, 20));
    maxSlopeSB.setSize(new Dimension(SizeX, 20));
    maxErrorField.setSize(new Dimension(SizeX, 20));
    minInlierField.setSize(new Dimension(SizeX, 20));
    maxGapField.setSize(new Dimension(SizeX, 20));
    minSlopeField.setSize(new Dimension(SizeX, 20));
    maxSlopeField.setSize(new Dimension(SizeX, 20));

    scrollPane = new JScrollPane(table);
    scrollPane.setMinimumSize(new Dimension(300, 200));
    scrollPane.setPreferredSize(new Dimension(300, 200));

    scrollPane.getViewport().add(table);
    scrollPane.setAutoscrolls(true);

    // Location
    panelFirst.setLayout(layout);
    panelSecond.setLayout(layout);
    PanelSavetoFile.setLayout(layout);
    PanelParameteroptions.setLayout(layout);
    Panelfunction.setLayout(layout);
    Panelslope.setLayout(layout);
    PanelCompileRes.setLayout(layout);
    PanelDirectory.setLayout(layout);

    panelCont.setLayout(cl);

    panelCont.add(panelFirst, "1");
    panelCont.add(panelSecond, "2");

    panelFirst.setName("Ransac fits for rates and frequency analysis");
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.BOTH;
    c.ipadx = 35;

    inputLabelT = new Label("Compute length distribution at time: ");
    inputLabelTcont = new Label("(Press Enter to start computation) ");
    inputFieldT = new TextField(5);
    inputFieldT.setText("1");

    c.gridwidth = 10;
    c.gridheight = 10;
    c.gridy = 1;
    c.gridx = 0;

    String[] Method = { "Linear Function only", "Linearized Quadratic function", "Linearized Cubic function" };
    JComboBox<String> ChooseMethod = new JComboBox<String>(Method);

    final Checkbox findCatastrophe = new Checkbox("Detect Catastrophies", this.detectCatastrophe);
    final Checkbox findmanualCatastrophe = new Checkbox("Detect Catastrophies without fit",
            this.detectmanualCatastrophe);
    final Scrollbar minCatDist = new Scrollbar(Scrollbar.HORIZONTAL, this.minDistCatInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Scrollbar maxRes = new Scrollbar(Scrollbar.HORIZONTAL, this.restoleranceInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Label minCatDistLabel = new Label("Min. Catastrophy height (tp) = " + this.minDistanceCatastrophe,
            Label.CENTER);
    final Button done = new Button("Done");
    final Button batch = new Button("Save Parameters for Batch run");
    final Button cancel = new Button("Cancel");
    final Button Compile = new Button("Compute rates and freq. till current file");
    final Button AutoCompile = new Button("Auto Compute Velocity and Frequencies");
    final Button Measureserial = new Button("Select directory of MTrack generated files");
    final Button WriteLength = new Button("Compute length distribution at framenumber : ");
    final Button WriteStats = new Button("Compute lifetime and mean length distribution");
    final Button WriteAgain = new Button("Save Velocity and Frequencies to File");

    PanelDirectory.add(Measureserial, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelDirectory.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelDirectory.setBorder(selectdirectory);
    PanelDirectory.setPreferredSize(new Dimension(SizeX, SizeY));
    panelFirst.add(PanelDirectory, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxerror = new SliderBoxGUI(errorstring, maxErrorSB, maxErrorField, maxErrorLabel,
            scrollbarSize, maxError, MAX_ERROR);

    PanelParameteroptions.add(combomaxerror.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomininlier = new SliderBoxGUI(inlierstring, minInliersSB, minInlierField, minInliersLabel,
            scrollbarSize, minInliers, MAX_Inlier);

    PanelParameteroptions.add(combomininlier.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxdist = new SliderBoxGUI(maxgapstring, maxDistSB, maxGapField, maxDistLabel,
            scrollbarSize, maxDist, MAX_Gap);

    PanelParameteroptions.add(combomaxdist.BuildDisplay(), new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(ChooseMethod, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
            GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(lambdaSB, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelParameteroptions.add(lambdaLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.setPreferredSize(new Dimension(SizeX, SizeY));
    PanelParameteroptions.setBorder(selectparam);
    panelFirst.add(PanelParameteroptions, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combominslope = new SliderBoxGUI(minslopestring, minSlopeSB, minSlopeField, minSlopeLabel,
            scrollbarSize, (float) minSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combominslope.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxslope = new SliderBoxGUI(maxslopestring, maxSlopeSB, maxSlopeField, maxSlopeLabel,
            scrollbarSize, (float) maxSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combomaxslope.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    Panelslope.add(findCatastrophe, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(findmanualCatastrophe, new GridBagConstraints(4, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDist, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDistLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.setBorder(selectslope);
    Panelslope.setPreferredSize(new Dimension(SizeX, SizeY));

    panelFirst.add(Panelslope, new GridBagConstraints(3, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(AutoCompile, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteLength, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(inputFieldT, new GridBagConstraints(3, 1, 3, 1, 0.1, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteStats, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.setPreferredSize(new Dimension(SizeX, SizeY));

    PanelCompileRes.setBorder(compileres);

    panelFirst.add(PanelCompileRes, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    if (inputfiles != null) {

        table.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() >= 1) {

                    if (!jFreeChartFrame.isVisible())
                        jFreeChartFrame = Tracking.display(chart, new Dimension(500, 500));
                    JTable target = (JTable) e.getSource();
                    row = target.getSelectedRow();
                    // do some action if appropriate column
                    if (row > 0)
                        displayclicked(row);
                    else
                        displayclicked(0);
                }
            }
        });
    }

    maxErrorSB.addAdjustmentListener(new ErrorListener(this, maxErrorLabel, errorstring, MIN_ERROR, MAX_ERROR,
            scrollbarSize, maxErrorSB));

    minInliersSB.addAdjustmentListener(new MinInlierListener(this, minInliersLabel, inlierstring, MIN_Inlier,
            MAX_Inlier, scrollbarSize, minInliersSB));

    maxDistSB.addAdjustmentListener(
            new MaxDistListener(this, maxDistLabel, maxgapstring, MIN_Gap, MAX_Gap, scrollbarSize, maxDistSB));

    ChooseMethod.addActionListener(new FunctionItemListener(this, ChooseMethod));
    lambdaSB.addAdjustmentListener(new LambdaListener(this, lambdaLabel, lambdaSB));
    minSlopeSB.addAdjustmentListener(new MinSlopeListener(this, minSlopeLabel, minslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, minSlopeSB));

    maxSlopeSB.addAdjustmentListener(new MaxSlopeListener(this, maxSlopeLabel, maxslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, maxSlopeSB));
    findCatastrophe.addItemListener(
            new CatastrophyCheckBoxListener(this, findCatastrophe, minCatDistLabel, minCatDist));
    findmanualCatastrophe.addItemListener(
            new ManualCatastrophyCheckBoxListener(this, findmanualCatastrophe, minCatDistLabel, minCatDist));
    minCatDist.addAdjustmentListener(new MinCatastrophyDistanceListener(this, minCatDistLabel, minCatDist));
    Measureserial.addActionListener(new MeasureserialListener(this));
    Compile.addActionListener(new CompileResultsListener(this));
    AutoCompile.addActionListener(new AutoCompileResultsListener(this));
    WriteLength.addActionListener(new WriteLengthListener(this));
    WriteStats.addActionListener(new WriteStatsListener(this));
    WriteAgain.addActionListener(new WriteRatesListener(this));
    done.addActionListener(new FinishButtonListener(this, false));
    batch.addActionListener(new RansacBatchmodeListener(this));
    cancel.addActionListener(new FinishButtonListener(this, true));
    inputFieldT.addTextListener(new LengthdistroListener(this));

    maxSlopeField.addTextListener(new MaxSlopeLocListener(this, false));
    minSlopeField.addTextListener(new MinSlopeLocListener(this, false));
    maxErrorField.addTextListener(new ErrorLocListener(this, false));
    minInlierField.addTextListener(new MinInlierLocListener(this, false));
    maxGapField.addTextListener(new MaxDistLocListener(this, false));

    panelFirst.setVisible(true);
    functionChoice = 0;

    cl.show(panelCont, "1");

    Cardframe.add(panelCont, BorderLayout.CENTER);

    setFunction();
    Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Cardframe.pack();
    Cardframe.setVisible(true);
    Cardframe.pack();

}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

/**
 * Populate the display area with a multiple rows of graphs representing
 * the loads on each ComputeBean object within the HashSet.
 * @param resource/*  www. ja v a  2 s  .  co m*/
 * @param chartType
 */
private JPanel createChartPanel() {

    JPanel chartPanel = new JPanel();

    if (CURRENT_CHARTTYPE.equals(ChartType.METER) || CURRENT_CHARTTYPE.equals(ChartType.PIE)) {

        chartPanel.setLayout(new GridLayout(resources.size(), 1));

        LoadType[] loadTypes;

        if (CURRENT_LOADTYPE.equals(LoadType.SUMMARY)) {
            loadTypes = LoadType.values();
        } else {
            loadTypes = new LoadType[1];
            loadTypes[0] = CURRENT_LOADTYPE;
        }

        for (ComputeBean resource : resources) {
            // create a row to insert in the chartPanel
            JPanel multiChartPanelRow = new JPanel();
            multiChartPanelRow.setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();

            // first part is name of the row
            c.weightx = 0;
            c.weighty = 0;
            c.gridx = 0;
            c.gridy = 0;
            c.fill = GridBagConstraints.NONE;
            multiChartPanelRow.add(new JLabel(resource.getName()));

            // chart row will take up the remainder of this panel.
            c.weightx = 1.0;
            c.weighty = 1.0;
            c.gridx = 0;
            c.gridy = 1;
            c.fill = GridBagConstraints.BOTH;

            JPanel chartRow = new JPanel();
            chartRow.setLayout(new GridLayout(1, (LoadType.values().length - 1)));

            for (int i = 0; i < ((loadTypes.length == 1) ? 1 : loadTypes.length - 1); i++) {
                JFreeChart chart = createChart(resource, CURRENT_CHARTTYPE, loadTypes[i]);

                ChartPanel cp = new ChartPanel(chart);

                cp.setPreferredSize(new Dimension(40, 45));

                cp.addMouseListener(new MouseListener() {
                    public void mouseClicked(MouseEvent event) {
                        // if they double click on the graph, then zoom in on it and
                        // make it the single display in the screen.
                        if (event.getClickCount() == 2) {
                            if (zoomOnSingleChart) {
                                zoomOnSingleChart = false;
                                setChartDisplayType(CURRENT_CHARTTYPE);
                            } else {
                                zoomOnSingleChart = true;
                                removeAll();
                                GridBagConstraints c = new GridBagConstraints();
                                c.weightx = 1.0;
                                c.weighty = 1.0;
                                c.gridx = 0;
                                c.gridy = 0;
                                c.fill = GridBagConstraints.BOTH;
                                add((ChartPanel) event.getSource(), c);
                                c.weightx = 0;
                                c.weighty = 0;
                                c.gridx = 0;
                                c.gridy = 1;
                                add(createSelectionBar(), c);
                                revalidate();
                            }
                        }

                    }

                    public void mousePressed(MouseEvent arg0) {
                    }

                    public void mouseReleased(MouseEvent arg0) {
                    }

                    public void mouseEntered(MouseEvent arg0) {
                    }

                    public void mouseExited(MouseEvent arg0) {
                    }
                });

                chartRow.add(cp);
            }
            multiChartPanelRow.add(chartRow, c);
            chartPanel.add(multiChartPanelRow);

        }
    } else {
        chartPanel.setLayout(new GridLayout(1, 1));
        JFreeChart chart = createChart(resources, CURRENT_CHARTTYPE, CURRENT_LOADTYPE);
        ChartPanel cp = new ChartPanel(chart);
        cp.setPreferredSize(new Dimension(40, 45));
        chartPanel.add(cp);
    }

    return chartPanel;

}

From source file:neg.JRViewer.java

/**
*//*from   w ww  . j  a  v  a  2  s.  co m*/
void hyperlinkClicked(MouseEvent evt) {
    JPanel link = (JPanel) evt.getSource();
    JRPrintHyperlink element = (JRPrintHyperlink) linksMap.get(link);
    hyperlinkClicked(element);
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Creates a new {@link AttributeStatisticsPanel} instance. Before displaying the panel, an
 * {@link AbstractAttributeStatisticsModel} should be set via
 * {@link #setModel(AbstractAttributeStatisticsModel, boolean)}.
 *
 *//*w w  w  .  jav  a 2s .  c o m*/
public AttributeStatisticsPanel() {
    listOfChartPanels = new LinkedList<>();

    // create listener which listens for hovering/enlarge mouse events on this panel
    enlargeAndHoverAndPopupMouseAdapter = new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            // only popup trigger for popup menu
            if (e.isPopupTrigger()) {
                handlePopup(e);
            }

            // only left mouse button to enlarge
            if (!SwingUtilities.isLeftMouseButton(e)) {
                return;
            }

            // little hack so hovering over the details button does not remove the hover effect
            // (because MouseExited is called)
            // but clicking the button is still possible and does not enlarge the panel
            if (e.getSource() instanceof JButton) {
                ((JButton) e.getSource()).doClick();
                return;
            }

            // change enlarged status
            if (getModel() != null) {
                getModel().setEnlarged(!getModel().isEnlarged());
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            if (SwingTools.isMouseEventExitedToChildComponents(AttributeStatisticsPanel.this, e)) {
                // we are still hovering over the ASP, just a child component
                return;
            }
            hovered = false;
            repaint();
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            hovered = true;
            repaint();
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            if (e.isPopupTrigger()) {
                handlePopup(e);
            }
        }

        /**
         * Handles the popup click event.
         *
         * @param e
         */
        private void handlePopup(final MouseEvent e) {
            if (model.getAttribute().isNumerical()) {
                popupAttributeNumericalStatPanel.show(e.getComponent(), e.getX(), e.getY());
            } else if (model.getAttribute().isNominal()) {
                popupAttributeNominalStatPanel.show(e.getComponent(), e.getX(), e.getY());
            } else if (model.getAttribute().isDateTime()) {
                popupAttributeDateTimeStatPanel.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };

    // create listener which listens for AttributeStatisticsEvents on the model
    listener = new AttributeStatisticsEventListener() {

        @Override
        public void modelChanged(final AttributeStatisticsEvent e) {
            switch (e.getEventType()) {
            case ALTERNATING_CHANGED:
                repaint();
                break;
            case ENLARGED_CHANGED:
                updateCharts();
                updateVisibilityOfChartPanels();
                if (AttributeStatisticsPanel.this.model.getAttribute().isNominal()) {
                    displayNominalValues();
                }
                break;
            case SHOW_CONSTRUCTION_CHANGED:
                panelStatsConstruction.setVisible(model.isShowConstruction());
                break;
            case STATISTICS_CHANGED:
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        AbstractAttributeStatisticsModel model = AttributeStatisticsPanel.this.model;
                        if (model.getAttribute().isNumerical()) {
                            updateNumericalElements(model);
                        } else if (model.getAttribute().isNominal()) {
                            updateNominalElements(model);
                        } else {
                            updateDateTimeElements(model);
                        }
                    }

                });
                break;
            default:
            }
        }
    };

    initGUI();
}

From source file:userinterface.properties.GUIGraphHandler.java

private void popUpTriggered(MouseEvent e) {
    if (e.getSource() == theTabs)//just show the background popup
    {// w  ww .j  a v a 2  s.  co  m
        int index = theTabs.indexAtLocation(e.getX(), e.getY());
        if (index != -1) {
            graphOptions.setEnabled(true);
            zoomMenu.setEnabled(true);

            exportMenu.setEnabled(true);
            importMenu.setEnabled(true);

            printGraph.setEnabled(true);
            deleteGraph.setEnabled(true);

            theTabs.setSelectedIndex(index);

            this.graphMenu.show(theTabs, e.getX(), e.getY());
        } else {
            graphOptions.setEnabled(false);
            zoomMenu.setEnabled(false);

            exportMenu.setEnabled(false);
            importMenu.setEnabled(true);

            printGraph.setEnabled(false);
            deleteGraph.setEnabled(false);

            this.graphMenu.show(theTabs, e.getX(), e.getY());
        }
        return;
    }

    for (int i = 0; i < models.size(); i++) {

        if (e.getSource() == models.get(i)) {

            graphOptions.setEnabled(true);
            zoomMenu.setEnabled(true);

            exportMenu.setEnabled(true);
            importMenu.setEnabled(true);

            printGraph.setEnabled(true);
            deleteGraph.setEnabled(true);

            exportImageEPS.setEnabled(true);
            exportMatlab.setEnabled(getModel(i) instanceof Graph);
            exportXML.setEnabled(getModel(i) instanceof Graph);

            theTabs.setSelectedIndex(i);
            this.graphMenu.show(models.get(i), e.getX(), e.getY());
            return;
        }
    }
}

From source file:userinterface.properties.GUIGraphHandler.java

public void mouseClicked(MouseEvent e) {
    // Zoom out on double click
    if (e.getClickCount() == 2) {
        if (e.getSource() instanceof Graph) {
            ((Graph) e.getSource()).restoreAutoBounds();
        }/*from   w  w w . j a va 2  s .  c  o m*/
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

/**
*///ww  w. j  a v a  2 s  . c  o m
void hyperlinkClicked(MouseEvent evt) {
    JPanel link = (JPanel) evt.getSource();
    JRPrintHyperlink element = linksMap.get(link);
    hyperlinkClicked(element);
}