Example usage for java.awt.event MouseAdapter MouseAdapter

List of usage examples for java.awt.event MouseAdapter MouseAdapter

Introduction

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

Prototype

MouseAdapter

Source Link

Usage

From source file:medsavant.enrichment.app.OntologyAggregatePanel.java

public OntologyAggregatePanel(String page) {
    super(page);//from   w  w  w .  j a va2 s. co m
    setLayout(new GridBagLayout());

    chooser = new JComboBox(OntologyListItem.DEFAULT_ITEMS);
    chooser.setMaximumSize(new Dimension(400, chooser.getMaximumSize().height));
    progress = new JProgressBar();
    progress.setPreferredSize(new Dimension(600, progress.getMaximumSize().height));
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new GridBagLayout());
    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Ontology"));

    tree = new TreeTable();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    banner.add(chooser, gbc);
    gbc.anchor = GridBagConstraints.EAST;
    banner.add(progress, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    add(banner, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(tree), gbc);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (termFetcher != null) {
                termFetcher.cancel(true);
                termFetcher = null;
            }
            recalculate();
        }
    });

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}

From source file:de.tor.tribes.ui.views.DSWorkbenchMarkerFrame.java

private void buildMenu() {
    JXTaskPane editPane = new JXTaskPane();
    editPane.setTitle("Bearbeiten");
    JXButton showButton = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/eye_large.png")));

    showButton.setToolTipText("Blendet gewhlten Markierungen auf der Hauptkarte und der Minimap ein");
    showButton.addMouseListener(new MouseAdapter() {

        @Override//from   w w w  .j  a va  2  s.  c  o  m
        public void mouseReleased(MouseEvent e) {
            MarkerTableTab tab = getActiveTab();
            if (tab != null) {
                tab.changeVisibility(true);
            }
        }
    });
    editPane.getContentPane().add(showButton);
    JXButton hideButton = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/eye_forbidden_large.png")));

    hideButton.setToolTipText("Blendet gewhlten Markierungen auf der Hauptkarte und der Minimap aus");
    hideButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            MarkerTableTab tab = getActiveTab();
            if (tab != null) {
                tab.changeVisibility(false);
            }
        }
    });
    editPane.getContentPane().add(hideButton);

    centerPanel.setupTaskPane(editPane);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JPanCMTableArea.java

protected JTableInfoForCMFile getJTableInfoForCMFile() {
    if (jTableInfoForCMFile == null) {
        jTableInfoForCMFile = new JTableInfoForCMFile();
        jTableInfoForCMFile.addKeyListener(new KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent e) {
                keyReleasedAction(jTableInfoForCMFile);
            }//w ww .j  a v  a  2 s. co m
        });

        jTableInfoForCMFile.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                mouseClickedAction(jTableInfoForCMFile, e);
            }
        });
    }
    return jTableInfoForCMFile;
}

From source file:gtu.log.finder.ExceptionLogFinderUI.java

private void initGUI() {
    try {/*www .  j a v  a 2s .c o  m*/
        JCommonUtil.defaultLookAndFeel();
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("?log", null, jPanel1, null);
                {
                    jPanel4 = new JPanel();
                    jPanel1.add(jPanel4, BorderLayout.NORTH);
                    jPanel4.setPreferredSize(new java.awt.Dimension(689, 115));
                    {
                        isExceptionLogChkBox = new JCheckBox();
                        jPanel4.add(isExceptionLogChkBox);
                        isExceptionLogChkBox.setText("\u53ea\u627e\u932f\u8aa4");
                    }
                    {
                        jLabel1 = new JLabel();
                        jPanel4.add(jLabel1);
                        jLabel1.setText("\u8cbc\u4e0alog\u6a94\u8def\u5f91");
                    }
                    {
                        srcFilePathText = new JTextField();
                        jPanel4.add(srcFilePathText);
                        srcFilePathText.setPreferredSize(new java.awt.Dimension(292, 22));
                        srcFilePathText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                srcFilePathTextSetFileAction(evt);
                            }
                        });
                    }
                    {
                        jLabel3 = new JLabel();
                        jPanel4.add(jLabel3);
                        jLabel3.setText("\u524d\u7f6e\u884c\u6578");
                    }
                    {
                        preLineText = new JTextField();
                        jPanel4.add(preLineText);
                        preLineText.setText("5");
                        preLineText.setPreferredSize(new java.awt.Dimension(33, 22));
                    }
                    {
                        executeBtn = new JButton();
                        jPanel4.add(executeBtn);
                        executeBtn.setText("\u57f7\u884c\u89e3\u6790");
                        executeBtn.setPreferredSize(new java.awt.Dimension(107, 22));
                        executeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                executeBtnAction();
                            }
                        });
                    }
                    {
                        jLabel4 = new JLabel();
                        jPanel4.add(jLabel4);
                        jLabel4.setText("\u76f4\u63a5\u8a2d\u5b9a\u89e3\u6790\u6a94\u8def\u5f91");
                        jLabel4.setPreferredSize(new java.awt.Dimension(119, 15));
                    }
                    {
                        setParseFileText = new JTextField();
                        jPanel4.add(setParseFileText);
                        setParseFileText.setPreferredSize(new java.awt.Dimension(507, 22));
                        setParseFileText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                setParseFileBtnAction(evt);
                            }
                        });
                    }
                    {
                        jLabel2 = new JLabel();
                        jPanel4.add(jLabel2);
                        jLabel2.setText("\u641c\u5c0b\u95dc\u9375\u5b57");
                    }
                    {
                        searchText = new JTextField();
                        jPanel4.add(searchText);
                        searchText.setPreferredSize(new java.awt.Dimension(355, 22));
                    }
                    {
                        ignoreCaseCheckBox = new JCheckBox();
                        jPanel4.add(ignoreCaseCheckBox);
                        ignoreCaseCheckBox.setText("\u7121\u8996\u5927\u5c0f\u5beb");
                        ignoreCaseCheckBox.setSelected(true);
                    }
                    {
                        searchTextBtn = new JButton();
                        jPanel4.add(searchTextBtn);
                        searchTextBtn.setText("?");
                        searchTextBtn.setPreferredSize(new java.awt.Dimension(118, 22));
                        searchTextBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                searchTextBtnAction();
                            }
                        });
                    }
                    {
                        jLabel5 = new JLabel();
                        jPanel4.add(jLabel5);
                        jLabel5.setText(
                                "\u4ee5\u958b\u59cb\u7d50\u675f\u95dc\u9375\u5b57\u89e3\u6790\u6587\u4ef6");
                        jLabel5.setPreferredSize(new java.awt.Dimension(155, 15));
                    }
                    {
                        startStrText = new JTextField();
                        jPanel4.add(startStrText);
                        startStrText.setPreferredSize(new java.awt.Dimension(229, 22));
                    }
                    {
                        endStrText = new JTextField();
                        jPanel4.add(endStrText);
                        endStrText.setPreferredSize(new java.awt.Dimension(244, 22));
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(689, 391));
                    {
                        DefaultListModel searchMatchListModel = new DefaultListModel();
                        searchMatchList = new JList();
                        jScrollPane1.setViewportView(searchMatchList);
                        searchMatchList.setModel(searchMatchListModel);
                        searchMatchList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                searchMatchListMouseAction(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("", null, jPanel2, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(689, 484));
                    {
                        logDetailTextArea = new JTextArea();
                        jScrollPane2.setViewportView(logDetailTextArea);
                    }
                }
            }
        }
        pack();
        this.setSize(702, 538);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:de.mirkosertic.desktopsearch.DesktopSearch.java

@Override
public void start(Stage aStage) throws Exception {

    // This is our base directory
    File theBaseDirectory = new File(SystemUtils.getUserHome(), "FreeSearchIndexDir");
    theBaseDirectory.mkdirs();//from   w  ww. j  a v a 2s.  c o m

    configurationManager = new ConfigurationManager(theBaseDirectory);

    Notifier theNotifier = new Notifier();

    stage = aStage;

    // Create the known preview processors
    PreviewProcessor thePreviewProcessor = new PreviewProcessor();

    try {
        // Boot the search backend and set it up for listening to configuration changes
        backend = new Backend(theNotifier, configurationManager.getConfiguration(), thePreviewProcessor);
        configurationManager.addChangeListener(backend);

        // Boot embedded JSP container
        embeddedWebServer = new FrontendEmbeddedWebServer(aStage, backend, thePreviewProcessor,
                configurationManager);

        embeddedWebServer.start();
    } catch (BindException | LockReleaseFailedException | LockObtainFailedException e) {
        // In this case, there is already an instance of DesktopSearch running
        // Inform the instance to bring it to front end terminate the current process.
        URL theURL = new URL(FrontendEmbeddedWebServer.getBringToFrontUrl());
        // Retrieve the content, but it can be safely ignored
        // There must only be the get request
        Object theContent = theURL.getContent();

        // Terminate the JVM. The window of the running instance is visible now.
        System.exit(0);
    }

    aStage.setTitle("Free Desktop Search");
    aStage.setWidth(800);
    aStage.setHeight(600);
    aStage.initStyle(StageStyle.TRANSPARENT);

    FXMLLoader theLoader = new FXMLLoader(getClass().getResource("/scenes/mainscreen.fxml"));
    AnchorPane theMainScene = theLoader.load();

    final DesktopSearchController theController = theLoader.getController();
    theController.configure(this, backend, FrontendEmbeddedWebServer.getSearchUrl(), stage.getOwner());

    Undecorator theUndecorator = new Undecorator(stage, theMainScene);
    theUndecorator.getStylesheets().add("/skin/undecorator.css");

    Scene theScene = new Scene(theUndecorator);

    // Hacky, but works...
    theUndecorator.setStyle("-fx-background-color: rgba(0, 0, 0, 0);");

    theScene.setFill(Color.TRANSPARENT);
    aStage.setScene(theScene);

    aStage.getIcons().add(new Image(getClass().getResourceAsStream("/fds.png")));

    if (SystemTray.isSupported()) {
        Platform.setImplicitExit(false);
        SystemTray theTray = SystemTray.getSystemTray();

        // We need to reformat the icon according to the current tray icon dimensions
        // this depends on the underlying OS
        java.awt.Image theTrayIconImage = Toolkit.getDefaultToolkit()
                .getImage(getClass().getResource("/fds_small.png"));
        int trayIconWidth = new TrayIcon(theTrayIconImage).getSize().width;
        TrayIcon theTrayIcon = new TrayIcon(
                theTrayIconImage.getScaledInstance(trayIconWidth, -1, java.awt.Image.SCALE_SMOOTH),
                "Free Desktop Search");
        theTrayIcon.setImageAutoSize(true);
        theTrayIcon.setToolTip("FXDesktopSearch");
        theTrayIcon.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1) {
                    Platform.runLater(() -> {
                        if (stage.isIconified()) {
                            stage.setIconified(false);
                        }
                        stage.show();
                        stage.toFront();
                    });
                }
            }
        });
        theTray.add(theTrayIcon);

        aStage.setOnCloseRequest(aEvent -> stage.hide());
    } else {

        aStage.setOnCloseRequest(aEvent -> shutdown());
    }

    aStage.setMaximized(true);
    aStage.show();
}

From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java

/**
 * Initialize the work package calendar panel inclusive the listeners.
 *//*from  w  ww . ja  va 2 s.c om*/
private void init() {
    List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser()));

    Collections.sort(userWp, new APLevelComparator());

    dataset = createDataset(userWp);
    chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPopupMenu popup = new JPopupMenu();
    JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine()));
    miSave.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {

            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS
            chooser.setSelectedFile(new File("chart-" //NON-NLS
                    + System.currentTimeMillis() + ".jpg"));
            int returnVal = chooser.showSaveDialog(reference);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    File outfile = chooser.getSelectedFile();
                    ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(),
                            chartPanel.getWidth());
                    Controller.showMessage(
                            LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath()));
                } catch (IOException e) {
                    Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError());
                }
            }
        }

    });
    popup.add(miSave);

    chartPanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                popup.show(e.getComponent(), e.getX(), e.getY());
            }
        }

    });
    chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawWidth(9999);
    chartPanel.setPreferredSize(
            new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size()));

    chartPanel.setPopupMenu(null);

    this.setLayout(new BorderLayout());

    this.removeAll();

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    panel.add(chartPanel, constraints);

    panel.setBackground(Color.white);
    this.add(panel, BorderLayout.CENTER);

    GanttRenderer.setDefaultShadowsVisible(false);
    GanttRenderer.setDefaultBarPainter(new BarPainter() {

        @Override
        public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col,
                final RectangularShape rect, final RectangleEdge arg5) {

            String wpName = (String) dataset.getColumnKey(col);
            int i = 0;
            int spaceCount = 0;
            while (wpName.charAt(i++) == ' ' && spaceCount < 17) {
                spaceCount++;
            }

            g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15));
            g.fill(rect);
            g.setColor(Color.black);
            g.setStroke(new BasicStroke());
            g.draw(rect);
        }

        @Override
        public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2,
                final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) {

        }

    });

    ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() {
        private static final long serialVersionUID = -6078915091070733812L;

        public void drawItem(final Graphics2D g2, final CategoryItemRendererState state,
                final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis,
                final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column,
                final int pass) {
            super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
        }
    });

}

From source file:com.floreantpos.bo.ui.explorer.MenuItemExplorer.java

public MenuItemExplorer() {
    tableModel = new BeanTableModel<MenuItem>(MenuItem.class);
    tableModel.addColumn(POSConstants.ID.toUpperCase(), "id"); //$NON-NLS-1$
    tableModel.addColumn(POSConstants.NAME.toUpperCase(), "name"); //$NON-NLS-1$
    tableModel.addColumn(POSConstants.TRANSLATED_NAME.toUpperCase(), "translatedName"); //$NON-NLS-1$
    tableModel.addColumn(POSConstants.PRICE.toUpperCase() + " (" + CurrencyUtil.getCurrencySymbol() + ")", //$NON-NLS-1$//$NON-NLS-2$
            "price"); //$NON-NLS-1$
    tableModel.addColumn(Messages.getString("MenuItemExplorer.16"), "stockAmount"); //$NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.VISIBLE.toUpperCase(), "visible"); //$NON-NLS-1$
    tableModel.addColumn(POSConstants.FOOD_GROUP.toUpperCase(), "parent"); //$NON-NLS-1$
    tableModel.addColumn(POSConstants.TAX.toUpperCase(), "tax"); //$NON-NLS-1$
    tableModel.addColumn(Messages.getString("MenuItemExplorer.21"), "sortOrder"); //$NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(Messages.getString("MenuItemExplorer.23"), "buttonColor"); //$NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(Messages.getString("MenuItemExplorer.25"), "textColor"); //$NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.IMAGE.toUpperCase(), "imageData"); //$NON-NLS-1$

    List<MenuItem> findAll = MenuItemDAO.getInstance().getMenuItems();
    tableModel.addRows(findAll);/*from  ww  w .j  a v  a 2s.com*/
    table = new JXTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setDefaultRenderer(Object.class, new CustomCellRenderer());
    table.setRowHeight(60);

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    add(createButtonPanel(), BorderLayout.SOUTH);
    add(buildSearchForm(), BorderLayout.NORTH);
    resizeColumnWidth(table);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (me.getClickCount() == 2) {
                doEditSelectedMenuItem();
            }
        }
    });
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsOverviewPanel.java

public void refresh(final Instances dataSet, final int dateIdx) {
    final Instances gapsDescriptionsDataset = GapsUtil.buildGapsDescription(gcp, dataSet, dateIdx);

    final JXTable gapsDescriptionsTable = new JXTable();
    final InstanceTableModel gapsDescriptionsTableModel = new InstanceTableModel(false);
    gapsDescriptionsTableModel.setDataset(gapsDescriptionsDataset);
    gapsDescriptionsTable.setModel(gapsDescriptionsTableModel);
    gapsDescriptionsTable.setEditable(true);
    gapsDescriptionsTable.setShowHorizontalLines(false);
    gapsDescriptionsTable.setShowVerticalLines(false);
    gapsDescriptionsTable.setVisibleRowCount(5);
    gapsDescriptionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    gapsDescriptionsTable.setSortable(false);
    gapsDescriptionsTable.packAll();/* www .j  a va 2s .co  m*/

    gapsDescriptionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    gapsDescriptionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int modelRow = gapsDescriptionsTable.getSelectedRow();
                if (modelRow < 0)
                    modelRow = 0;

                final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString();
                final Attribute attr = dataSet.attribute(attrname);
                final int gapsize = (int) Double
                        .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString()).doubleValue();
                final int position = (int) Double
                        .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString()).doubleValue();

                try {
                    final ChartPanel cp = GapsUIUtil.buildGapChartPanel(dataSet, dateIdx, attr, gapsize,
                            position);

                    visualOverviewPanel.removeAll();
                    visualOverviewPanel.add(cp, BorderLayout.CENTER);

                    geomapPanel.removeAll();
                    geomapPanel.add(gcp.getMapPanel(Arrays.asList(attrname), new ArrayList<String>(), false));

                    jxp.updateUI();
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
            }
        }
    });

    gapsDescriptionsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(final MouseEvent e) {
            final InstanceTableModel instanceTableModel = (InstanceTableModel) gapsDescriptionsTable.getModel();
            final int row = gapsDescriptionsTable.rowAtPoint(e.getPoint());
            //final int row=gapsDescriptionsTable.getSelectedRow();
            final int modelRow = gapsDescriptionsTable.convertRowIndexToModel(row);
            //final int modelRow=(int)Double.valueOf(instanceTableModel.getValueAt(row,0).toString()).doubleValue();
            //System.out.println(row+" "+modelRow);

            final String attrname = instanceTableModel.getValueAt(modelRow, 1).toString();
            final Attribute attr = dataSet.attribute(attrname);
            final int gapsize = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 5).toString())
                    .doubleValue();
            final int position = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 6).toString())
                    .doubleValue();

            if (!e.isPopupTrigger()) {
                // nothing?
            } else {
                final JPopupMenu jPopupMenu = new JPopupMenu("feur");

                final JMenuItem interactiveFillMenuItem = new JMenuItem("Fill this gap (interactively)");
                interactiveFillMenuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final GapFillingFrame jxf = new GapFillingFrame(atv, dataSet, attr, dateIdx,
                                GapsUtil.getCountOfValuesBeforeAndAfter(gapsize), position, gapsize, gcp,
                                false);
                        jxf.setSize(new Dimension(900, 700));
                        //jxf.setExtendedState(Frame.MAXIMIZED_BOTH);                        
                        jxf.setLocationRelativeTo(jPopupMenu);
                        jxf.setVisible(true);
                        //jxf.setResizable(false);
                    }
                });
                jPopupMenu.add(interactiveFillMenuItem);

                final JMenuItem lookupInKnowledgeDBMenuItem = new JMenuItem(
                        "Show the most similar cases from KnowledgeDB");
                lookupInKnowledgeDBMenuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final double x = gcp.getCoordinates(attrname)[0];
                        final double y = gcp.getCoordinates(attrname)[1];
                        final String season = instanceTableModel.getValueAt(modelRow, 3).toString()
                                .split("/")[0];
                        final boolean isDuringRising = instanceTableModel.getValueAt(modelRow, 11).toString()
                                .equals("true");
                        try {
                            final Calendar cal = Calendar.getInstance();
                            final String dateAsString = instanceTableModel.getValueAt(modelRow, 2).toString()
                                    .replaceAll("'", "");
                            cal.setTime(FormatterUtil.DATE_FORMAT.parse(dateAsString));
                            final int year = cal.get(Calendar.YEAR);

                            new SimilarCasesFrame(dataSet, dateIdx, gcp, attrname, gapsize, position, x, y,
                                    year, season, isDuringRising);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                });
                jPopupMenu.add(lookupInKnowledgeDBMenuItem);

                final JMenuItem mExport = new JMenuItem("Export this table as CSV");
                mExport.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        final JFileChooser fc = new JFileChooser();
                        fc.setAcceptAllFileFilterUsed(false);
                        final int returnVal = fc.showSaveDialog(gapsDescriptionsTable);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                            try {
                                final File file = fc.getSelectedFile();
                                WekaDataAccessUtil.saveInstancesIntoCSVFile(gapsDescriptionsDataset, file);
                            } catch (Exception ee) {
                                ee.printStackTrace();
                            }
                        }
                    }
                });
                jPopupMenu.add(mExport);

                jPopupMenu.show(gapsDescriptionsTable, e.getX(), e.getY());
            }
        }
    });

    final int tableWidth = (int) gapsDescriptionsTable.getPreferredSize().getWidth() + 30;
    final JScrollPane scrollPane = new JScrollPane(gapsDescriptionsTable);
    scrollPane.setPreferredSize(new Dimension(Math.min(tableWidth, 500), 500));
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.tablePanel.removeAll();
    this.tablePanel.add(scrollPane, BorderLayout.CENTER);

    this.visualOverviewPanel.removeAll();

    /* automatically compute the most similar series and the 'rising' flag */
    new AbstractSimpleAsync<Void>(false) {
        @Override
        public Void execute() throws Exception {
            final int rc = gapsDescriptionsTableModel.getRowCount();
            for (int i = 0; i < rc; i++) {
                final int modelRow = i;

                try {
                    final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString();
                    final Attribute attr = dataSet.attribute(attrname);
                    final int gapsize = (int) Double
                            .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString())
                            .doubleValue();
                    final int position = (int) Double
                            .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString())
                            .doubleValue();

                    /* most similar */
                    gapsDescriptionsTableModel.setValueAt("...", modelRow, 7);
                    final int cvba = GapsUtil.getCountOfValuesBeforeAndAfter(gapsize);
                    Instances gapds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0,
                            dataSet.numAttributes() - 1, Math.max(0, position - cvba),
                            Math.min(position + gapsize + cvba, dataSet.numInstances() - 1));
                    final String mostsimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(gapds,
                            attr, WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(gapds), false);
                    gapsDescriptionsTableModel.setValueAt(mostsimilar, modelRow, 7);

                    /* 'rising' flag */
                    gapsDescriptionsTableModel.setValueAt("...", modelRow, 11);
                    final List<String> attributeNames = WekaDataStatsUtil.getAttributeNames(dataSet);
                    attributeNames.remove("timestamp");
                    final String nearestStationName = gcp.findNearestStation(attr.name(), attributeNames);
                    final Attribute nearestStationAttr = dataSet.attribute(nearestStationName);
                    //System.out.println(nearestStationName+" "+nearestStationAttr);
                    final boolean isDuringRising = GapsUtil.isDuringRising(dataSet, position, gapsize,
                            new int[] { dateIdx, attr.index(), nearestStationAttr.index() });
                    gapsDescriptionsTableModel.setValueAt(isDuringRising, modelRow, 11);

                    gapsDescriptionsTableModel.fireTableDataChanged();
                } catch (Exception e) {
                    gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 7);
                    gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 11);
                    e.printStackTrace();
                }
            }
            return null;
        }

        @Override
        public void onSuccess(Void result) {
        }

        @Override
        public void onFailure(Throwable caught) {
            caught.printStackTrace();
        }

    }.start();

    /* select the first row */
    gapsDescriptionsTable.setRowSelectionInterval(0, 0);
}

From source file:net.sourceforge.entrainer.jfreechart.UnitChart.java

private void init() {
    chart = new JFreeChart(getXYPlot());
    chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseClicked(ChartMouseEvent event) {
        }//w  w  w. j a  v  a2  s. c  o m

        public void chartMouseMoved(ChartMouseEvent event) {
            if (event.getEntity() != null
                    && (currentEntity == null || !currentEntity.equals(event.getEntity()))) {
                if (event.getEntity() instanceof XYItemEntity) {
                    showPopup((XYItemEntity) event.getEntity());
                }
            } else if (event.getEntity() == null && timer != null) {
                timer.dismiss();
                timer = null;
                currentEntity = null;
            }
        }
    });

    getContentPane().add(chartPanel);

    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.isControlDown() && e.getClickCount() == 1) {
                openBrowser(getLocalDocAddress());
            }
        }
    });
}

From source file:MenuTest.java

public MenuFrame() {
    setTitle("MenuTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    JMenu fileMenu = new JMenu("File");
    fileMenu.add(new TestAction("New"));

    // demonstrate accelerators

    JMenuItem openItem = fileMenu.add(new TestAction("Open"));
    openItem.setAccelerator(KeyStroke.getKeyStroke("ctrl O"));

    fileMenu.addSeparator();//from   w w w .ja  v a 2s. c  o  m

    saveAction = new TestAction("Save");
    JMenuItem saveItem = fileMenu.add(saveAction);
    saveItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));

    saveAsAction = new TestAction("Save As");
    fileMenu.add(saveAsAction);
    fileMenu.addSeparator();

    fileMenu.add(new AbstractAction("Exit") {
        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });

    // demonstrate check box and radio button menus

    readonlyItem = new JCheckBoxMenuItem("Read-only");
    readonlyItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            boolean saveOk = !readonlyItem.isSelected();
            saveAction.setEnabled(saveOk);
            saveAsAction.setEnabled(saveOk);
        }
    });

    ButtonGroup group = new ButtonGroup();

    JRadioButtonMenuItem insertItem = new JRadioButtonMenuItem("Insert");
    insertItem.setSelected(true);
    JRadioButtonMenuItem overtypeItem = new JRadioButtonMenuItem("Overtype");

    group.add(insertItem);
    group.add(overtypeItem);

    // demonstrate icons

    Action cutAction = new TestAction("Cut");
    cutAction.putValue(Action.SMALL_ICON, new ImageIcon("cut.gif"));
    Action copyAction = new TestAction("Copy");
    copyAction.putValue(Action.SMALL_ICON, new ImageIcon("copy.gif"));
    Action pasteAction = new TestAction("Paste");
    pasteAction.putValue(Action.SMALL_ICON, new ImageIcon("paste.gif"));

    JMenu editMenu = new JMenu("Edit");
    editMenu.add(cutAction);
    editMenu.add(copyAction);
    editMenu.add(pasteAction);

    // demonstrate nested menus

    JMenu optionMenu = new JMenu("Options");

    optionMenu.add(readonlyItem);
    optionMenu.addSeparator();
    optionMenu.add(insertItem);
    optionMenu.add(overtypeItem);

    editMenu.addSeparator();
    editMenu.add(optionMenu);

    // demonstrate mnemonics

    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('H');

    JMenuItem indexItem = new JMenuItem("Index");
    indexItem.setMnemonic('I');
    helpMenu.add(indexItem);

    // you can also add the mnemonic key to an action
    Action aboutAction = new TestAction("About");
    aboutAction.putValue(Action.MNEMONIC_KEY, new Integer('A'));
    helpMenu.add(aboutAction);

    // add all top-level menus to menu bar

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(helpMenu);

    // demonstrate pop-ups

    popup = new JPopupMenu();
    popup.add(cutAction);
    popup.add(copyAction);
    popup.add(pasteAction);

    JPanel panel = new JPanel();
    panel.setComponentPopupMenu(popup);
    add(panel);

    // the following line is a workaround for bug 4966109
    panel.addMouseListener(new MouseAdapter() {
    });
}