Example usage for org.jfree.chart.plot Crosshair Crosshair

List of usage examples for org.jfree.chart.plot Crosshair Crosshair

Introduction

In this page you can find the example usage for org.jfree.chart.plot Crosshair Crosshair.

Prototype

public Crosshair(double value) 

Source Link

Document

Creates a new crosshair with the specified value.

Usage

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java

private PortHeatMapPlotPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes,
        EnumSet<IB_Depth> includedDepths) {
    super(new BorderLayout());

    // creates the main chart panel, which creates the PortHeatMapDataSet
    // (so all the data has been initialized here, available for all subsequent actions)
    overallDimension = new java.awt.Dimension(900, 500);
    heatPanel = (ChartPanel) createHeatPanel(history, includedNodes, includedDepths);
    heatPanel.setPreferredSize(overallDimension);

    // add the vertical and horizontal crosshairs
    CrosshairOverlay overlay = new CrosshairOverlay();
    TimeXhair = new Crosshair(0);
    TimeXhair.setPaint(TimeSliceColor); // vertical slice (single timestamp) for dataset1, SingleTimeChart plot 1, slider 2, etc
    PortXhair = new Crosshair(0);
    PortXhair.setPaint(PortSliceColor); // horizontal slice (single port) for dataset2, SinglePortChart, slider 1
    overlay.addDomainCrosshair(TimeXhair);
    overlay.addRangeCrosshair(PortXhair);
    heatPanel.addOverlay(overlay);//from   w  ww  .j  av  a  2 s. c o m
    TimeXhair.setLabelVisible(true);
    TimeXhair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    TimeXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));
    PortXhair.setLabelVisible(true);
    PortXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));

    add(heatPanel);

    JPanel PortSliderPanel = new JPanel(new BorderLayout());

    // all ports, single timestamp (right vertical plot) - uses TimeXhair and slider 2 from the horizontal panel (TimeSliderPanel)
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    SingleTimeChart = ChartFactory.createXYLineChart("Vertical Cross-section (all ports single timestamp)",
            PortAxisLabel, UtilizationAxisLabel, dataset1, PlotOrientation.HORIZONTAL, false, false, false);
    XYPlot plot1 = (XYPlot) SingleTimeChart.getPlot();
    plot1.getDomainAxis().setLowerMargin(0.0);
    plot1.getDomainAxis().setUpperMargin(0.0);
    plot1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot1.getRenderer().setSeriesPaint(0, TimeSliceColor);

    // this is the right
    ChartPanel SingleTimeChartPanel = new ChartPanel(SingleTimeChart);
    SingleTimeChartPanel.setMinimumDrawWidth(0);
    SingleTimeChartPanel.setMinimumDrawHeight(0);

    SingleTimeChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getWidth() / 3)));
    ((XYPlot) SingleTimeChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SingleTimeChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    // this slider panel holds the slider and the Single Time Snapshot of all ports, on the right or EAST (for use with plot2)
    PortSlider = new JSlider(0, 1, 0);
    PortSlider.addChangeListener(this);
    PortSlider.setOrientation(JSlider.VERTICAL);

    PortSliderPanel.add(SingleTimeChartPanel);
    PortSliderPanel.add(PortSlider, BorderLayout.WEST);

    TimeSliderPanel = new JPanel(new BorderLayout());

    // single port, all timestamps (lower horizontal plot) - uses PortXhair and slider 1 from the vertical panel (PortSliderPanel)
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    SinglePortChart = ChartFactory.createXYLineChart("Horizontal Cross-section (single port over time)",
            TimeAxisLabel, UtilizationAxisLabel, dataset2, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot2 = (XYPlot) SinglePortChart.getPlot();
    plot2.getDomainAxis().setLowerMargin(0.0);
    plot2.getDomainAxis().setUpperMargin(0.0);
    plot2.getRenderer().setSeriesPaint(0, PortSliceColor);

    ChartPanel SinglePortChartPanel = new ChartPanel(SinglePortChart);
    SinglePortChartPanel.setMinimumDrawWidth(0);
    SinglePortChartPanel.setMinimumDrawHeight(0);

    SinglePortChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getHeight() / 3)));
    ((XYPlot) SinglePortChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SinglePortChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    DepthPanel = new HeatMapDepthPanel(null);
    DepthPanel.setPreferredSize(
            new Dimension((int) (overallDimension.getWidth() / 4), (int) (overallDimension.getHeight() / 3)));
    TimeSliderPanel.add(DepthPanel, BorderLayout.EAST);

    // this slider panel holds the slider and the Single Port for all times, in the BOTTOM (for use with plot1)
    TimeSlider = new JSlider(0, 1, 0);
    TimeSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 200));
    TimeSlider.addChangeListener(this);

    TimeSliderPanel.add(SinglePortChartPanel);
    TimeSliderPanel.add(TimeSlider, BorderLayout.NORTH);
    add(PortSliderPanel, BorderLayout.EAST);
    add(TimeSliderPanel, BorderLayout.SOUTH);
    heatChart.setNotify(true);
}

From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java

private Crosshair createCroshair(Color crhColor, ImageCrosshairLabelGenerator lebelGenereator) {
    Crosshair crosshair = new Crosshair(0.0);
    crosshair.setPaint(crhColor);//from   www . j av  a  2s  .co  m
    if (lebelGenereator != null) {
        crosshair.setLabelGenerator(lebelGenereator);
    }
    crosshair.setLabelVisible(true);
    crosshair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    crosshair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));
    return crosshair;
}