Example usage for java.awt Cursor CROSSHAIR_CURSOR

List of usage examples for java.awt Cursor CROSSHAIR_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor CROSSHAIR_CURSOR.

Prototype

int CROSSHAIR_CURSOR

To view the source code for java.awt Cursor CROSSHAIR_CURSOR.

Click Source Link

Document

The crosshair cursor type.

Usage

From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java

public TICPlot(final ActionListener listener) {

    super(null, true);

    // Initialize.
    visualizer = listener;/*from   w w w  .j a v  a2  s  . co m*/
    labelsVisible = 1;
    havePeakLabels = false;
    numOfDataSets = 0;
    numOfPeaks = 0;
    showSpectrumRequest = false;

    // Set cursor.
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    // Y-axis label.
    final String yAxisLabel;
    if (listener instanceof TICVisualizerWindow) {

        yAxisLabel = ((TICVisualizerWindow) listener).getPlotType() == PlotType.BASEPEAK ? "Base peak intensity"
                : "Total ion intensity";
    } else {

        yAxisLabel = "Base peak intensity";
    }

    // Initialize the chart by default time series chart from factory.
    final JFreeChart chart = ChartFactory.createXYLineChart("", // title
            "Retention time", // x-axis label
            yAxisLabel, // y-axis label
            null, // data set
            PlotOrientation.VERTICAL, // orientation
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );
    chart.setBackgroundPaint(Color.white);
    setChart(chart);

    // Title.
    chartTitle = chart.getTitle();
    chartTitle.setFont(TITLE_FONT);
    chartTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0);

    // Subtitle.
    chartSubTitle = new TextTitle();
    chartSubTitle.setFont(SUBTITLE_FONT);
    chartSubTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0);
    chart.addSubtitle(chartSubTitle);

    // Disable maximum size (we don't want scaling).
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // Legend constructed by ChartFactory.
    final LegendTitle legend = chart.getLegend();
    legend.setItemFont(LEGEND_FONT);
    legend.setFrame(BlockBorder.NONE);

    // Set the plot properties.
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(AXIS_OFFSET);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    // Set grid properties.
    plot.setDomainGridlinePaint(GRID_COLOR);
    plot.setRangeGridlinePaint(GRID_COLOR);

    // Set cross-hair (selection) properties.
    if (listener instanceof TICVisualizerWindow) {

        plot.setDomainCrosshairVisible(true);
        plot.setRangeCrosshairVisible(true);
        plot.setDomainCrosshairPaint(CROSS_HAIR_COLOR);
        plot.setRangeCrosshairPaint(CROSS_HAIR_COLOR);
        plot.setDomainCrosshairStroke(CROSS_HAIR_STROKE);
        plot.setRangeCrosshairStroke(CROSS_HAIR_STROKE);
    }

    // Set the x-axis (retention time) properties.
    final NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat());
    xAxis.setUpperMargin(AXIS_MARGINS);
    xAxis.setLowerMargin(AXIS_MARGINS);

    // Set the y-axis (intensity) properties.
    final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat());

    // Set default renderer properties.
    defaultRenderer = new TICPlotRenderer();
    defaultRenderer.setBaseShapesFilled(true);
    defaultRenderer.setDrawOutlines(false);
    defaultRenderer.setUseFillPaint(true);
    defaultRenderer.setBaseItemLabelPaint(LABEL_COLOR);

    // Set label generator
    final XYItemLabelGenerator labelGenerator = new TICItemLabelGenerator(this);
    defaultRenderer.setBaseItemLabelGenerator(labelGenerator);
    defaultRenderer.setBaseItemLabelsVisible(true);

    // Set toolTipGenerator
    final XYToolTipGenerator toolTipGenerator = new TICToolTipGenerator();
    defaultRenderer.setBaseToolTipGenerator(toolTipGenerator);

    // Set focus state to receive key events.
    setFocusable(true);

    // Register key handlers.
    GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("LEFT"), listener, "MOVE_CURSOR_LEFT");
    GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("RIGHT"), listener, "MOVE_CURSOR_RIGHT");
    GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), listener, "SHOW_SPECTRUM");
    GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('+'), this, "ZOOM_IN");
    GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('-'), this, "ZOOM_OUT");

    // Add items to popup menu.
    final JPopupMenu popupMenu = getPopupMenu();
    popupMenu.addSeparator();

    if (listener instanceof TICVisualizerWindow) {

        popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener));
        popupMenu.addSeparator();
        popupMenu.add(new AddFilePopupMenu((TICVisualizerWindow) listener));
        popupMenu.add(new RemoveFilePopupMenu((TICVisualizerWindow) listener));
        popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener));
        popupMenu.addSeparator();
    }

    GUIUtils.addMenuItem(popupMenu, "Toggle showing peak values", this, "SHOW_ANNOTATIONS");
    GUIUtils.addMenuItem(popupMenu, "Toggle showing data points", this, "SHOW_DATA_POINTS");

    if (listener instanceof TICVisualizerWindow) {
        popupMenu.addSeparator();
        GUIUtils.addMenuItem(popupMenu, "Show spectrum of selected scan", listener, "SHOW_SPECTRUM");
    }

    popupMenu.addSeparator();

    GUIUtils.addMenuItem(popupMenu, "Set axes range", this, "SETUP_AXES");

    if (listener instanceof TICVisualizerWindow) {

        GUIUtils.addMenuItem(popupMenu, "Set same range to all windows", this, "SET_SAME_RANGE");
    }
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java

/**
 * Creates new form Chromatogram2DViewerPanel
 *//*from  w  w  w  . j a  va  2 s. co m*/
public Chromatogram1DHeatmapViewerPanel(InstanceContent topComponentInstanceContent, Lookup tcLookup,
        ADataset2D<IChromatogram1D, IScan> ds) {
    initComponents();
    this.content = topComponentInstanceContent;
    this.lookup = tcLookup;
    chart = new JFreeChart(new XYPlot());
    chartPanel = new ContextAwareChartPanel(chart, true, true, true, true, true);
    Cursor crosshairCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
    chartPanel.setCursor(crosshairCursor);
    //        chart.addProgressListener(cdxpanel);
    chartPanel.setInitialDelay(100);
    chartPanel.setDismissDelay(30000);
    chartPanel.setReshowDelay(0);
    chartPanel.setFocusable(true);
    jPanel2.add(chartPanel, BorderLayout.CENTER);
    content.add(chartPanel);
    addKeyListener(this);
    dataRange = DatasetUtilities.findDomainBounds(ds);
}

From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java

/**
 * Constructor//from w  w  w .  j  av  a2s  .  c  o m
 * @param parent
 *          the parent frame
 * @param fitMaanovaResult
 *          the fitmaanova result that we'll plot residuals for
 */
public ResidualPlotPanel(JFrame parent, FitMaanovaResult fitMaanovaResult) {
    this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent);
    this.chartConfigurationDialog.addOkActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ResidualPlotPanel.this.updateDataPoints();
        }
    });

    this.fitMaanovaResult = fitMaanovaResult;
    this.dyeCount = this.fitMaanovaResult.getParentExperiment().getDyeCount();
    this.arrayCount = this.fitMaanovaResult.getParentExperiment().getMicroarrayCount();

    this.setLayout(new BorderLayout());

    JPanel chartAndControlPanel = new JPanel(new BorderLayout());
    this.add(chartAndControlPanel, BorderLayout.CENTER);

    this.chartPanel = new MaanovaChartPanel();
    this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    this.chartPanel.addComponentListener(this.chartComponentListener);
    this.chartPanel.addAreaSelectionListener(this.areaSelectionListener);
    this.chartPanel.addMouseListener(this.chartMouseListener);
    this.chartPanel.addMouseMotionListener(this.myMouseMotionListener);
    this.chartPanel.setLayout(null);
    chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER);

    ItemListener updateDataItemListener = new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            ResidualPlotPanel.this.forgetGraphState();
            ResidualPlotPanel.this.updateDataPoints();
        }
    };

    if (this.dyeCount <= 1) {
        this.controlPanel = null;
        this.dyeComboBox = null;
    } else {
        this.dyeComboBox = new JComboBox();
        for (int i = 0; i < this.dyeCount; i++) {
            this.dyeComboBox.addItem("Dye #" + (i + 1));
        }
        this.dyeComboBox.addItemListener(updateDataItemListener);

        this.controlPanel = new JPanel(new FlowLayout());
        this.controlPanel.add(this.dyeComboBox);
        chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH);
    }

    this.add(this.createMenu(), BorderLayout.NORTH);

    this.forgetGraphState();
    this.updateDataPoints();

    this.toolTip = new JToolTip();
}

From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java

/**
 * Constructor//from   w w w  . j  a v  a2 s .c om
 * @param parent
 *          the parent frame
 * @param experiment
 *          the microarray experiment that we're going to be plotting data
 *          for
 */
public ArrayScatterPlotPanel(JFrame parent, MicroarrayExperiment experiment) {
    this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent);
    this.chartConfigurationDialog.addOkActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ArrayScatterPlotPanel.this.updateDataPoints();
        }
    });

    this.experiment = experiment;
    this.dyeCount = experiment.getDyeCount();

    this.setLayout(new BorderLayout());

    JPanel chartAndControlPanel = new JPanel(new BorderLayout());
    this.add(chartAndControlPanel, BorderLayout.CENTER);

    this.chartPanel = new MaanovaChartPanel();
    this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    this.chartPanel.addMouseMotionListener(this.myMouseMotionListener);
    this.chartPanel.addMouseListener(this.chartMouseListener);
    this.chartPanel.addComponentListener(this.chartComponentListener);
    this.chartPanel.addAreaSelectionListener(this.areaSelectionListener);
    this.chartPanel.setLayout(null);
    chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER);

    ItemListener updateDataItemListener = new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            ArrayScatterPlotPanel.this.forgetGraphState();
            ArrayScatterPlotPanel.this.updateDataPoints();
        }
    };

    this.array1ComboBox = this.initializeArrayComboBox(this.dyeCount);
    this.array1ComboBox.addItemListener(updateDataItemListener);
    this.array2ComboBox = this.initializeArrayComboBox(this.dyeCount);
    this.array2ComboBox.setSelectedIndex(1);
    this.array2ComboBox.addItemListener(updateDataItemListener);

    this.controlPanel = new JPanel(new FlowLayout());
    this.controlPanel.add(this.array1ComboBox);
    this.controlPanel.add(new JLabel("vs."));
    this.controlPanel.add(this.array2ComboBox);
    chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH);

    this.add(this.createMenu(), BorderLayout.NORTH);

    this.forgetGraphState();
    this.updateDataPoints();

    this.toolTip = new JToolTip();
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java

@Override
public void leftPressed(final Point p) {
    m_warning = false;/*w w w .  j av  a 2 s  . com*/

    try {
        if (m_geometryBuilder == null)
            return;

        final IMapPanel mapPanel = getMapPanel();
        final Object newNode = checkNewNode(p);
        if (newNode == null)
            mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

        if (newNode instanceof IFE1D2DNode) {
            final GM_Point point = ((IFE1D2DNode) newNode).getPoint();
            m_currentMapPoint = MapUtilities.retransform(getMapPanel(), point);
            m_geometryBuilder.addPoint(point);
        } else {
            m_currentMapPoint = p;
            m_geometryBuilder.addPoint(MapUtilities.transform(mapPanel, p));
        }
        mapPanel.setCursor(Cursor.getDefaultCursor());

    } catch (final Exception e) {
        e.printStackTrace();
        final IStatus status = StatusUtilities.statusFromThrowable(e);
        KalypsoModel1D2DPlugin.getDefault().getLog().log(status);
        reinit();
    }
}

From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java

/**
 * Constructor//from w ww  .j a va  2s.c  o m
 * @param parent the parent frame
 * @param maanovaTestResult
 *          the test result to plot
 * @param initialTestIndex
 *          the initial test index to use
 * @param selectedIndices
 *          the initially selected indices
 */
public VolcanoPlotPanel(JFrame parent, MaanovaTestResult maanovaTestResult, int initialTestIndex,
        int[] selectedIndices) {
    selectedIndices = SequenceUtilities.uniqueInts(selectedIndices);

    this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent);
    this.chartConfigurationDialog.addOkActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            VolcanoPlotPanel.this.updateDataPoints();
        }
    });

    this.maanovaTestResult = maanovaTestResult;
    this.saveSelectedPointsMenuItem = new JMenuItem("Save Selected Points to Gene List");
    this.saveSelectedPointsMenuItem.setEnabled(selectedIndices != null && selectedIndices.length >= 1);
    this.saveSelectedPointsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VolcanoPlotPanel.this.saveSelectedPoints();
        }
    });

    this.displayTestResultsAction = new DisplayTestResultsAction("Show Results Table", maanovaTestResult);
    this.selectedIndices = selectedIndices;

    this.setLayout(new BorderLayout());

    JPanel chartAndControlPanel = new JPanel(new BorderLayout());
    this.add(chartAndControlPanel, BorderLayout.CENTER);

    this.chartPanel = new MaanovaChartPanel();
    this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    this.chartPanel.addComponentListener(this.chartComponentListener);
    this.chartPanel.addAreaSelectionListener(this.areaSelectionListener);
    this.chartPanel.addMouseListener(this.chartMouseListener);
    chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER);

    this.controlPanel = new JPanel(new FlowLayout());

    ItemListener updateDataItemListener = new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            VolcanoPlotPanel.this.forgetGraphState();
            VolcanoPlotPanel.this.updateDataPoints();
        }
    };

    this.statisticTypeComboBox = new JComboBox();
    for (MaanovaTestStatisticType testStatType : MaanovaTestStatisticType.values()) {
        this.statisticTypeComboBox.addItem(testStatType);
    }
    this.statisticTypeComboBox.addItemListener(updateDataItemListener);
    this.controlPanel.add(this.statisticTypeComboBox);

    List<MaanovaTestStatisticSubtype> availableTestSubtypes = new ArrayList<MaanovaTestStatisticSubtype>();
    this.statisticSubtypeComboBox = new JComboBox();
    MaanovaTestStatistics fStat = this.maanovaTestResult.getStatistics(MaanovaTestStatisticType.F_STAT);
    for (MaanovaTestStatisticSubtype statSubtype : MaanovaTestStatisticSubtype.values()) {
        if (fStat.hasTestStatistic(statSubtype)) {
            availableTestSubtypes.add(statSubtype);

            if (statSubtype != MaanovaTestStatisticSubtype.F_OBSERVED) {
                this.statisticSubtypeComboBox.addItem(statSubtype);
            }
        }
    }
    this.statisticSubtypeComboBox.addItemListener(updateDataItemListener);
    this.controlPanel.add(this.statisticSubtypeComboBox);

    int testStatCount = availableTestSubtypes.size() * MaanovaTestStatisticType.values().length;
    this.availableTestStatistics = new TestStatisticItem[testStatCount];
    for (int i = 0; i < MaanovaTestStatisticType.values().length; i++) {
        for (int j = 0; j < availableTestSubtypes.size(); j++) {
            int flatIndex = i * availableTestSubtypes.size() + j;
            this.availableTestStatistics[flatIndex] = new TestStatisticItem(
                    MaanovaTestStatisticType.values()[i], availableTestSubtypes.get(j));
        }
    }

    int testCount = fStat.getContrastCount();
    if (testCount == 1) {
        this.testNumberComboBox = null;
    } else {
        this.testNumberComboBox = new JComboBox();
        for (int i = 1; i <= testCount; i++) {
            this.testNumberComboBox.addItem("Test Number " + i);
        }
        this.testNumberComboBox.setSelectedIndex(initialTestIndex);
        this.testNumberComboBox.addItemListener(updateDataItemListener);
        this.controlPanel.add(this.testNumberComboBox);
    }

    chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH);

    JMenuBar menu = this.createMenu();
    this.add(menu, BorderLayout.NORTH);

    this.forgetGraphState();
    this.updateDataPoints();

    this.chartPanel.addMouseMotionListener(this.myMouseMotionListener);
    this.chartPanel.setLayout(null);

    this.toolTip = new JToolTip();
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

public Cursor selectCursor() {
    Cursor cursor = defaultCursor;
    switch (state) {
    case BAR_MOVE:
        cursor = new Cursor(Cursor.MOVE_CURSOR);
        break;//  w w  w .jav  a 2  s  .  c  o  m
    case LINK_CREATION:
        cursor = getLinkCursor();
        break;
    case LINK_SELECTION:
        cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
        break;
    }
    getGraph().setCursor(cursor);
    return cursor;
}

From source file:graphviewer.GraphCreate.java

/**
 * Create an instance of a directed graph
 *///from  w  w w  . ja  v a 2  s.  c  o m
public GraphCreate() {
    super("SCCFinder");
    this.graph = new DirectedSparseMultigraph<Integer, Integer>();
    this.layout = new StaticLayout<Integer, Integer>(this.graph, new Dimension(600, 600));
    final Transformer<Integer, Paint> redVertexPaint = new Transformer<Integer, Paint>() {
        public Paint transform(Integer i) {
            return Color.RED;
        }
    };

    this.vv = new VisualizationViewer<Integer, Integer>(this.layout);
    this.vv.setBackground(Color.white);
    this.vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>());
    this.vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    Container content = getContentPane();
    content.add(this.vv);
    this.vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint);

    // add listeners to our visual component
    Factory<Integer> vertexFactory = new VertexFactory();
    Factory<Integer> edgeFactory = new EdgeFactory();
    this.graphMouse = new EditingModalGraphMouse<Integer, Integer>(this.vv.getRenderContext(), vertexFactory,
            edgeFactory);
    this.vv.setGraphMouse(this.graphMouse);
    this.vv.addKeyListener(new MyKeyListener());
    final MouseListener[] mls = (MouseListener[]) (this.vv.getListeners(MouseListener.class));
    final MouseListener wrapper = new MyWrapperMouseListener(mls[1]);

    this.graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
    this.vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    this.controls = new JPanel();
    final ScalingControl scaler = new CrossoverScalingControl();
    // add some buttons
    this.plus = new JButton("+");
    this.plus.setToolTipText("Press this button or use the mouse wheel to zoom out");
    this.plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
            setFocusable(false);
        }
    });
    this.minus = new JButton("-");
    this.minus.setToolTipText("Press this button or use the mouse wheel to zoom in");
    this.minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
            setFocusable(false);
        }
    });
    this.edit = new JRadioButton("Editing");
    this.edit.setToolTipText("You can just press 'e' to select this radiobutton");
    this.edit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
            vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
            setFocusable(false);
        }
    });
    this.transform = new JRadioButton("Transforming");
    this.transform.setToolTipText("You can just press 't' to select this radiobutton");
    this.transform.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
            vv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            setFocusable(false);
        }
    });
    this.pick = new JRadioButton("Picking");
    this.pick.setToolTipText("You can just press 'p' to select this radiobutton");
    this.pick.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
            vv.setCursor(new Cursor(Cursor.HAND_CURSOR));
            setFocusable(false);
        }
    });
    GraphCreate.scc = new JButton("SCC");
    GraphCreate.scc.setToolTipText("Strongly Connected Components algorithm");
    GraphCreate.scc.setEnabled(false);
    GraphCreate.scc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            createMathgraph();
            GraphCreate.scc.setEnabled(false);
            edit.setEnabled(false);
            pick.setSelected(true);
            setFocusable(false);
            sccButtonPressed = true;
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
            vv.setCursor(new Cursor(Cursor.HAND_CURSOR));
            vv.removeMouseListener(mls[1]);
            vv.addMouseListener(wrapper);
        }
    });
    GraphCreate.clear = new JButton("Clear");
    GraphCreate.clear.setToolTipText("Clears our graph");
    GraphCreate.clear.setEnabled(false);
    GraphCreate.clear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int k = 0; k <= numberOfVertices; k++) {
                graph.removeVertex(k);
            }

            GraphCreate.scc.setEnabled(false);
            GraphCreate.clear.setEnabled(false);
            edit.setEnabled(true);
            edit.setSelected(true);
            setFocusable(false);
            graphMouse.setMode(ModalGraphMouse.Mode.EDITING);
            vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
            vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint);

            if (sccButtonPressed) {
                vv.removeMouseListener(wrapper);
                vv.addMouseListener(mls[1]);
            }

            vv.repaint();
            // calling garbage collector here
            Runtime r = Runtime.getRuntime();
            r.gc();
            GraphCreate.numberOfEdges = 0;
            GraphCreate.numberOfVertices = 0;
            sccButtonPressed = false;
        }
    });

    ButtonGroup actions = new ButtonGroup();
    actions.add(this.edit);
    actions.add(this.transform);
    actions.add(this.pick);
    this.edit.setSelected(true);
    this.controls.add(this.plus);
    this.controls.add(this.minus);
    this.controls.add(this.edit);
    this.controls.add(this.transform);
    this.controls.add(this.pick);
    this.controls.add(GraphCreate.scc);
    controls.add(GraphCreate.clear);
    this.help = new JButton("Help");
    this.help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, instructions);
            setFocusable(false);
        }
    });
    this.controls.add(this.help);
    content.add(this.controls, BorderLayout.SOUTH);
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.RefineFEGeometryWidget.java

@Override
public void moved(final Point p) {
    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;/*from w  ww .j  av  a2  s .c  o m*/

    final Object newNode = checkNewNode(p);
    if (newNode instanceof IFE1D2DNode) {
        final IFE1D2DNode candidateNode = (IFE1D2DNode) newNode;
        m_currentMapPoint = MapUtilities.retransform(getMapPanel(), candidateNode.getPoint());
    } else
        m_currentMapPoint = p;

    if (newNode == null)
        getMapPanel().setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    else
        getMapPanel().setCursor(Cursor.getDefaultCursor());

    repaintMap();

}

From source file:edu.umn.ecology.populus.plot.BasicPlotCanvas.java

private void jbInit() throws Exception {
    /*//from www.  j a va2 s  . co  m
    if( info != null ) {
       mainCaption = new HTMLLabel( info.getMainCaption() );
       xCaption = new HTMLLabel( info.getXCaptions()[0] );
       yCaption = new HTMLLabel( info.getYCaptions()[0] );
       yCaption.setDirection( HTMLLabel.DOWN_TO_UP );
    } else {
       mainCaption = new HTMLLabel( "Main Caption" );
       xCaption = new HTMLLabel( "X Caption" );
       yCaption = new HTMLLabel( "Y Caption" );
    }
     */
    //*
    if (info != null) {
        mainCaption = new HTMLMultiLabel(info.getMainCaption());
        xCaption = new HTMLMultiLabel(info.getXCaptions());
        yCaption = new HTMLMultiLabel(info.getYCaptions());
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    } else {
        mainCaption = new HTMLMultiLabel("Main Caption");
        xCaption = new HTMLMultiLabel("X Caption");
        yCaption = new HTMLMultiLabel("Y Caption");
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    }
    setLayout(borderLayout1);
    if (PopPreferencesStorage.isUseJFreeClass()) {
        NumberAxis yAxis = new NumberAxis(null);
        NumberAxis xAxis = new NumberAxis(null);
        xAxis.setAutoRangeIncludesZero(false);

        AbstractXYItemRenderer renderer = null;
        if (info.isBarChart) {
            renderer = new XYBarRenderer();
        } else {
            renderer = new XYLineAndShapeRenderer(true, false);
        }

        XYPlot plot = new XYPlot(null, xAxis, yAxis, renderer);
        plot.setOrientation(PlotOrientation.VERTICAL);

        JFreeChart jfchart = new JFreeChart(null, null, plot, false);
        jfchartpanel = new ChartPanel(jfchart);
        plot.setBackgroundPaint(ColorScheme.bG);

        info.styleJFree(jfchart);
        add(jfchartpanel, MacroLayout.CENTER);
    } else {
        chart = new JCChart(JCChart.PLOT);
        info.styleJC(chart);
        chart.setBackground(ColorScheme.bG);
        chart.setAllowUserChanges(true);
        chart.setTrigger(0, new EventTrigger(InputEvent.SHIFT_MASK, EventTrigger.CUSTOMIZE));
        chart.setTrigger(1, new EventTrigger(InputEvent.BUTTON1_MASK, EventTrigger.ZOOM));
        chart.setResetKey('r');
        chart.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                if ((e.getModifiers() & InputEvent.META_MASK) != 0) {
                    info.setAxis(chart);
                    chart.reset();
                }
            }
        });
        chart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
        chart.setWarningDialog(false);
        add(chart, MacroLayout.CENTER);
    }
    setBGColor();
    add(mainCaption, MacroLayout.NORTH);
    add(xCaption, MacroLayout.SOUTH);
    add(yCaption, MacroLayout.WEST);
}