org.jfree.ui.Layer Java Examples

The following examples show how to use org.jfree.ui.Layer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoryPlot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is 
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, 
                                 int index, Layer layer) {
                                             
    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    
    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }
    
}
 
Example #2
Source File: XYPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the dataset/renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #3
Source File: CategoryPlot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 *
 * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #4
Source File: CategoryPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 *
 * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #5
Source File: CategoryPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the range markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 *
 * @see #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea,
                                int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #6
Source File: XYPlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
@Test
public void testDomainMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second x axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);
    
    ValueMarker xMarker1 = new ValueMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
 
Example #7
Source File: AbstractXYItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #8
Source File: CategoryPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 *
 * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #9
Source File: XYPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the dataset/renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #10
Source File: AbstractXYItemRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #11
Source File: AbstractXYItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
@Override
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
        ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
        PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        int index = this.plot.getIndexOf(this);
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                index, info);
    }

}
 
Example #12
Source File: XYPlotTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);
    
    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
 
Example #13
Source File: XYPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);
    
    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
 
Example #14
Source File: CategoryPlotTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRangeMarkerIndices() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second axis
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(1, "R1", "C1");
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);
    
    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(
            yMarker1));
}
 
Example #15
Source File: XYPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test to reproduce a bug in serialization: the domain and/or range
 * markers for a plot are not being serialized.
 */
@Test
public void testSerialization4() {

    XYSeriesCollection dataset = new XYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart("Test Chart",
            "Domain Axis", "Range Axis", dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND);
    plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND);
    plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND);
    plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND);
    JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart);
    assertEquals(chart, chart2);
    try {
        chart2.createBufferedImage(300, 200);
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example #16
Source File: CategoryPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDomainMarkerIndices() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    
    // add a second dataset, plotted against a second x axis
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(1, "R1", "C1");
    plot.setDataset(99, dataset);    
    CategoryAxis xAxis2 = new CategoryAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);
    
    CategoryMarker xMarker1 = new CategoryMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
 
Example #17
Source File: CategoryPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This test ensures that a plot with markers is serialized correctly.
 */
@Test
public void testSerialization4() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createBarChart(
            "Test Chart", "Category Axis", "Value Axis",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.addRangeMarker(new ValueMarker(1.1), Layer.FOREGROUND);
    plot.addRangeMarker(new IntervalMarker(2.2, 3.3), Layer.BACKGROUND);
    JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart);
    assertEquals(chart, chart2);

    // now check that the chart is usable...
    try {
        chart2.createBufferedImage(300, 200);
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example #18
Source File: CategoryPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the renderer index.
 * @param layer  the layer (foreground or background).
 *
 * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }

    Collection markers = getDomainMarkers(index, layer);
    CategoryAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            CategoryMarker marker = (CategoryMarker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #19
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain markers (if any) for an axis and layer.  This method is
 * typically called from within the draw() method.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param index  the dataset/renderer index.
 * @param layer  the layer (foreground or background).
 */
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea,
                                 int index, Layer layer) {

    XYItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    // check that the renderer has a corresponding dataset (it doesn't
    // matter if the dataset is null)
    if (index >= getDatasetCount()) {
        return;
    }
    Collection markers = getDomainMarkers(index, layer);
    ValueAxis axis = getDomainAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawDomainMarker(g2, this, axis, marker, dataArea);
        }
    }

}
 
Example #20
Source File: cfCHART.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public void addDomainMarker(CategoryPlot plot, cfCHARTDOMAINMARKERData dmData) throws cfmRunTimeException {
	CategoryMarker domainMarker = new CategoryMarker(dmData.getValue());
	boolean drawAsLine = false;
	if (dmData.getShape().equals("line"))
		drawAsLine = true;
	domainMarker.setDrawAsLine(drawAsLine);
	domainMarker.setPaint(convertStringToColor(dmData.getColor()));
	if (dmData.getLabel() != null) {
		domainMarker.setLabel(dmData.getLabel());
		domainMarker.setLabelPaint(convertStringToColor(dmData.getLabelColor()));
		String labelPos = dmData.getLabelPosition();
		if (labelPos.equals("top_left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
		} else if (labelPos.equals("top")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP);
			domainMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
		} else if (labelPos.equals("top_right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
		} else if (labelPos.equals("left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
		} else if (labelPos.equals("center")) {
			domainMarker.setLabelAnchor(RectangleAnchor.CENTER);
			domainMarker.setLabelTextAnchor(TextAnchor.CENTER);
		} else if (labelPos.equals("right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
		} else if (labelPos.equals("bottom_left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
		} else if (labelPos.equals("bottom")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
			domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
		} else if (labelPos.equals("bottom_right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
		}
		domainMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
		domainMarker.setLabelFont(getFont(dmData.getFont(), dmData.getFontBold(), dmData.getFontItalic(), dmData.getFontSize()));
	}
	plot.addDomainMarker(domainMarker, Layer.BACKGROUND);
}
 
Example #21
Source File: CategoryPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new plot.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param domainAxis  the domain axis (<code>null</code> permitted).
 * @param rangeAxis  the range axis (<code>null</code> permitted).
 * @param renderer  the item renderer (<code>null</code> permitted).
 *
 */
public CategoryPlot(CategoryDataset dataset,
                    CategoryAxis domainAxis,
                    ValueAxis rangeAxis,
                    CategoryItemRenderer renderer) {

    super();

    this.orientation = PlotOrientation.VERTICAL;

    // allocate storage for dataset, axes and renderers
    this.domainAxes = new ObjectList();
    this.domainAxisLocations = new ObjectList();
    this.rangeAxes = new ObjectList();
    this.rangeAxisLocations = new ObjectList();
    
    this.datasetToDomainAxisMap = new ObjectList();
    this.datasetToRangeAxisMap = new ObjectList();

    this.renderers = new ObjectList();

    this.datasets = new ObjectList();
    this.datasets.set(0, dataset);
    if (dataset != null) {
        dataset.addChangeListener(this);
    }

    this.axisOffset = RectangleInsets.ZERO_INSETS;

    setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT, false);
    setRangeAxisLocation(AxisLocation.TOP_OR_LEFT, false);

    this.renderers.set(0, renderer);
    if (renderer != null) {
        renderer.setPlot(this);
        renderer.addChangeListener(this);
    }

    this.domainAxes.set(0, domainAxis);
    this.mapDatasetToDomainAxis(0, 0);
    if (domainAxis != null) {
        domainAxis.setPlot(this);
        domainAxis.addChangeListener(this);
    }
    this.drawSharedDomainAxis = false;

    this.rangeAxes.set(0, rangeAxis);
    this.mapDatasetToRangeAxis(0, 0);
    if (rangeAxis != null) {
        rangeAxis.setPlot(this);
        rangeAxis.addChangeListener(this);
    }
    
    configureDomainAxes();
    configureRangeAxes();

    this.domainGridlinesVisible = DEFAULT_DOMAIN_GRIDLINES_VISIBLE;
    this.domainGridlinePosition = CategoryAnchor.MIDDLE;
    this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE;
    this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT;

    this.rangeGridlinesVisible = DEFAULT_RANGE_GRIDLINES_VISIBLE;
    this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE;
    this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT;

    this.foregroundDomainMarkers = new HashMap();
    this.backgroundDomainMarkers = new HashMap();
    this.foregroundRangeMarkers = new HashMap();
    this.backgroundRangeMarkers = new HashMap();

    Marker baseline = new ValueMarker(0.0, new Color(0.8f, 0.8f, 0.8f, 
            0.5f), new BasicStroke(1.0f), new Color(0.85f, 0.85f, 0.95f, 
            0.5f), new BasicStroke(1.0f), 0.6f);
    addRangeMarker(baseline, Layer.BACKGROUND);

    this.anchorValue = 0.0;
    this.annotations = new java.util.ArrayList();

}
 
Example #22
Source File: YIntervalRendererTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = new YIntervalRenderer();
    assertEquals(r1, r2);

    // the following fields are inherited from the AbstractXYItemRenderer
    r1.setItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setToolTipGenerator(new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setToolTipGenerator(new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.setURLGenerator(new StandardXYURLGenerator());
    assertFalse(r1.equals(r2));
    r2.setURLGenerator(new StandardXYURLGenerator());
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
    assertTrue(r1.equals(r2));

    r1.setDefaultEntityRadius(99);
    assertFalse(r1.equals(r2));
    r2.setDefaultEntityRadius(99);
    assertTrue(r1.equals(r2));

    r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator(
            "{0} {1}"));
    assertFalse(r1.equals(r2));
    r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator(
            "{0} {1}"));
    assertTrue(r1.equals(r2));

    r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

}
 
Example #23
Source File: XYItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            ValueAxis domainAxis,
                            ValueAxis rangeAxis,
                            Layer layer,
                            PlotRenderingInfo info);
 
Example #24
Source File: XYItemRenderer.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 * 
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
public void drawAnnotations(Graphics2D g2, 
                            Rectangle2D dataArea, 
                            ValueAxis domainAxis, 
                            ValueAxis rangeAxis, 
                            Layer layer, 
                            PlotRenderingInfo info);
 
Example #25
Source File: XYItemRenderer.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            ValueAxis domainAxis,
                            ValueAxis rangeAxis,
                            Layer layer,
                            PlotRenderingInfo info);
 
Example #26
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Removes a marker for a specific dataset/renderer and sends a
 * {@link PlotChangeEvent} to all registered listeners.
 *
 * @param index the dataset/renderer index.
 * @param marker the marker.
 * @param layer the layer (foreground or background).
 *
 * @return A boolean indicating whether or not the marker was actually
 *         removed.
 *
 * @since 1.0.7
 */
public boolean removeDomainMarker(int index, Marker marker, Layer layer) {
    return removeDomainMarker(index, marker, layer, true);
}
 
Example #27
Source File: CategoryPlot.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a marker for display against the domain axis and sends a
 * {@link PlotChangeEvent} to all registered listeners.  Typically a marker
 * will be drawn by the renderer as a line perpendicular to the domain
 * axis, however this is entirely up to the renderer.
 *
 * @param marker  the marker (<code>null</code> not permitted).
 * @param layer  the layer (foreground or background) (<code>null</code>
 *               not permitted).
 *
 * @see #removeDomainMarker(Marker, Layer)
 */
public void addDomainMarker(CategoryMarker marker, Layer layer) {
    addDomainMarker(0, marker, layer);
}
 
Example #28
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds an annotation and sends a {@link RendererChangeEvent} to all
 * registered listeners.  The annotation is added to the foreground
 * layer.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation) {
    // defer argument checking
    addAnnotation(annotation, Layer.FOREGROUND);
}
 
Example #29
Source File: XYPlot.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the list of range markers (read only) for the specified layer.
 *
 * @param layer  the layer (foreground or background).
 *
 * @return The list of range markers.
 *
 * @see #getDomainMarkers(Layer)
 */
public Collection getRangeMarkers(Layer layer) {
    return getRangeMarkers(0, layer);
}
 
Example #30
Source File: XYPlot.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the list of domain markers (read only) for the specified layer.
 *
 * @param layer  the layer (foreground or background).
 *
 * @return The list of domain markers.
 *
 * @see #getRangeMarkers(Layer)
 */
public Collection getDomainMarkers(Layer layer) {
    return getDomainMarkers(0, layer);
}