org.jfree.chart.axis.AxisLocation Java Examples

The following examples show how to use org.jfree.chart.axis.AxisLocation. 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 SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent}
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 *
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location,
        boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.put(index, location);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #2
Source File: 1_CategoryPlot.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location, 
                                 boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.set(index, location);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #3
Source File: 1_CategoryPlot.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the edge for a range axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 */
public RectangleEdge getRangeAxisEdge(int index) {
    AxisLocation location = getRangeAxisLocation(index);
    RectangleEdge result = Plot.resolveRangeAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getRangeAxisEdge(0));
    }
    return result;
}
 
Example #4
Source File: CombinedRangeXYPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
 
Example #5
Source File: JGenProg2017_005_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a range axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 */
public RectangleEdge getRangeAxisEdge(int index) {
    AxisLocation location = getRangeAxisLocation(index);
    RectangleEdge result = Plot.resolveRangeAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getRangeAxisEdge(0));
    }
    return result;
}
 
Example #6
Source File: XYPlot.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the edge for a domain axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 * 
 * @see #getRangeAxisEdge(int)
 */
public RectangleEdge getDomainAxisEdge(int index) {
    AxisLocation location = getDomainAxisLocation(index);
    RectangleEdge result = Plot.resolveDomainAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getDomainAxisEdge());
    }
    return result;
}
 
Example #7
Source File: Nopol2017_005_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a range axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 */
public RectangleEdge getRangeAxisEdge(int index) {
    AxisLocation location = getRangeAxisLocation(index);
    RectangleEdge result = Plot.resolveRangeAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getRangeAxisEdge(0));
    }
    return result;
}
 
Example #8
Source File: Chart_19_CategoryPlot_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location, 
                                 boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.set(index, location);
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
 
Example #9
Source File: CategoryPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the edge for a domain axis.
 *
 * @param index  the axis index.
 *
 * @return The edge (never <code>null</code>).
 */
public RectangleEdge getDomainAxisEdge(int index) {
    RectangleEdge result;
    AxisLocation location = getDomainAxisLocation(index);
    if (location != null) {
        result = Plot.resolveDomainAxisLocation(location, this.orientation);
    } else {
        result = RectangleEdge.opposite(getDomainAxisEdge(0));
    }
    return result;
}
 
Example #10
Source File: jMutRepair_0030_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a range axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 */
public RectangleEdge getRangeAxisEdge(int index) {
    AxisLocation location = getRangeAxisLocation(index);
    RectangleEdge result = Plot.resolveRangeAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getRangeAxisEdge(0));
    }
    return result;
}
 
Example #11
Source File: jMutRepair_0021_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a domain axis.
 *
 * @param index  the axis index.
 *
 * @return The edge (never <code>null</code>).
 */
public RectangleEdge getDomainAxisEdge(int index) {
    RectangleEdge result = null;
    AxisLocation location = getDomainAxisLocation(index);
    if (location != null) {
        result = Plot.resolveDomainAxisLocation(location, this.orientation);
    }
    else {
        result = RectangleEdge.opposite(getDomainAxisEdge(0));
    }
    return result;
}
 
Example #12
Source File: AxisLocationTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the equals() method.
 */
public void testEquals() {
    assertEquals(AxisLocation.TOP_OR_RIGHT, AxisLocation.TOP_OR_RIGHT);
    assertEquals(
        AxisLocation.BOTTOM_OR_RIGHT, AxisLocation.BOTTOM_OR_RIGHT
    );    
    assertEquals(AxisLocation.TOP_OR_LEFT, AxisLocation.TOP_OR_LEFT);    
    assertEquals(AxisLocation.BOTTOM_OR_LEFT, AxisLocation.BOTTOM_OR_LEFT);
}
 
Example #13
Source File: Cardumen_00143_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location, 
                                 boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.set(index, location);
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
 
Example #14
Source File: CategoryPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent}
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 *
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location,
        boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.put(index, location);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #15
Source File: JGenProg2017_0081_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a range axis.
 *
 * @param index  the axis index.
 *
 * @return The edge.
 */
public RectangleEdge getRangeAxisEdge(int index) {
    AxisLocation location = getRangeAxisLocation(index);
    RectangleEdge result = Plot.resolveRangeAxisLocation(location, 
            this.orientation);
    if (result == null) {
        result = RectangleEdge.opposite(getRangeAxisEdge(0));
    }
    return result;
}
 
Example #16
Source File: CategoryPlot.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent}
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 *
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location,
        boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.put(index, location);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #17
Source File: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the edge for a domain axis.
 *
 * @param index  the axis index.
 *
 * @return The edge (never <code>null</code>).
 */
public RectangleEdge getDomainAxisEdge(int index) {
    RectangleEdge result = null;
    AxisLocation location = getDomainAxisLocation(index);
    if (location != null) {
        result = Plot.resolveDomainAxisLocation(location, this.orientation);
    }
    else {
        result = RectangleEdge.opposite(getDomainAxisEdge(0));
    }
    return result;
}
 
Example #18
Source File: Chart_14_CategoryPlot_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Sets the location for a range axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 *
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @see #getRangeAxisLocation(int)
 * @see #setDomainAxisLocation(int, AxisLocation, boolean)
 */
public void setRangeAxisLocation(int index, AxisLocation location, 
                                 boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.rangeAxisLocations.set(index, location);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #19
Source File: JGenProg2017_0081_t.java    From coming with MIT License 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 = new RectangleInsets(4.0, 4.0, 4.0, 4.0);

    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.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
    
    this.annotations = new java.util.ArrayList();

}
 
Example #20
Source File: Chart_14_CategoryPlot_s.java    From coming with MIT License 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 = new RectangleInsets(4.0, 4.0, 4.0, 4.0);

    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.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
    
    this.annotations = new java.util.ArrayList();

}
 
Example #21
Source File: XYDataImageAnnotation.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the annotation.  This method is called by the drawing code in the
 * {@link XYPlot} class, you don't normally need to call this method
 * directly.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
@Override
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis,
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    AxisLocation xAxisLocation = plot.getDomainAxisLocation();
    AxisLocation yAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation,
            orientation);
    RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation,
            orientation);
    float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge);
    float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge);
    float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w,
            dataArea, xEdge);
    float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h,
            dataArea, yEdge);
    float xx0 = 0.0f;
    float yy0 = 0.0f;
    float xx1 = 0.0f;
    float yy1 = 0.0f;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx0 = j2DY0;
        xx1 = j2DY1;
        yy0 = j2DX0;
        yy1 = j2DX1;
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        xx0 = j2DX0;
        xx1 = j2DX1;
        yy0 = j2DY0;
        yy1 = j2DY1;
    }
    // TODO: rotate the image when drawn with horizontal orientation?
    g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1),
            (int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null);
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0),
                (yy1 - yy0)), rendererIndex, toolTip, url);
    }
}
 
Example #22
Source File: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_s.java    From coming with MIT License 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.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
    
    this.annotations = new java.util.ArrayList();

}
 
Example #23
Source File: XYImageAnnotation.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the annotation.  This method is called by the drawing code in the
 * {@link XYPlot} class, you don't normally need to call this method
 * directly.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis,
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge
        = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation);
    RectangleEdge rangeEdge
        = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation);
    float j2DX
        = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
    float j2DY
        = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    float xx = 0.0f;
    float yy = 0.0f;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = j2DY;
        yy = j2DX;
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        xx = j2DX;
        yy = j2DY;
    }
    int w = this.image.getWidth(null);
    int h = this.image.getHeight(null);

    Rectangle2D imageRect = new Rectangle2D.Double(0, 0, w, h);
    Point2D anchorPoint = RectangleAnchor.coordinates(imageRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    g2.drawImage(this.image, (int) xx, (int) yy, null);

    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, new Rectangle2D.Float(xx, yy, w, h), rendererIndex,
                toolTip, url);
    }
}
 
Example #24
Source File: Plot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resolves a domain axis location for a given plot orientation.
 *
 * @param location  the location (<code>null</code> not permitted).
 * @param orientation  the orientation (<code>null</code> not permitted).
 *
 * @return The edge (never <code>null</code>).
 */
public static RectangleEdge resolveDomainAxisLocation(
        AxisLocation location, PlotOrientation orientation) {

    ParamChecks.nullNotPermitted(location, "location");
    ParamChecks.nullNotPermitted(orientation, "orientation");

    RectangleEdge result = null;
    if (location == AxisLocation.TOP_OR_RIGHT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.RIGHT;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.TOP;
        }
    }
    else if (location == AxisLocation.TOP_OR_LEFT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.LEFT;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.TOP;
        }
    }
    else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.RIGHT;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.BOTTOM;
        }
    }
    else if (location == AxisLocation.BOTTOM_OR_LEFT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.LEFT;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.BOTTOM;
        }
    }
    // the above should cover all the options...
    if (result == null) {
        throw new IllegalStateException("resolveDomainAxisLocation()");
    }
    return result;

}
 
Example #25
Source File: CategoryPlot.java    From ECG-Viewer with GNU General Public License v2.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 HashMap<Integer, CategoryAxis>();
    this.domainAxisLocations = new HashMap<Integer, AxisLocation>();
    this.rangeAxes = new HashMap<Integer, ValueAxis>();
    this.rangeAxisLocations = new HashMap<Integer, AxisLocation>();

    this.datasetToDomainAxesMap = new TreeMap();
    this.datasetToRangeAxesMap = new TreeMap();

    this.renderers = new HashMap<Integer, CategoryItemRenderer>();

    this.datasets = new HashMap<Integer, CategoryDataset>();
    this.datasets.put(0, dataset);
    if (dataset != null) {
        dataset.addChangeListener(this);
    }

    this.axisOffset = RectangleInsets.ZERO_INSETS;
    this.domainAxisLocations.put(0, AxisLocation.BOTTOM_OR_LEFT);
    this.rangeAxisLocations.put(0, AxisLocation.TOP_OR_LEFT);

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

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

    this.rangeAxes.put(0, rangeAxis);
    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.rangeZeroBaselineVisible = false;
    this.rangeZeroBaselinePaint = Color.black;
    this.rangeZeroBaselineStroke = new BasicStroke(0.5f);

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

    this.rangeMinorGridlinesVisible = false;
    this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE;
    this.rangeMinorGridlinePaint = Color.white;

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

    this.anchorValue = 0.0;

    this.domainCrosshairVisible = false;
    this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;

    this.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;

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

    this.rangePannable = false;
    this.shadowGenerator = null;
}
 
Example #26
Source File: Cardumen_00243_t.java    From coming with MIT License 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.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;
    
    this.annotations = new java.util.ArrayList();

}
 
Example #27
Source File: XYImageAnnotation.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the annotation.  This method is called by the drawing code in the 
 * {@link XYPlot} class, you don't normally need to call this method 
 * directly.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis, 
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge 
        = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation);
    RectangleEdge rangeEdge 
        = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation);
    float j2DX 
        = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
    float j2DY 
        = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    float xx = 0.0f;
    float yy = 0.0f;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = j2DY;
        yy = j2DX;
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        xx = j2DX;
        yy = j2DY;
    }
    int w = this.image.getWidth(null);
    int h = this.image.getHeight(null);
    
    Rectangle2D imageRect = new Rectangle2D.Double(0, 0, w, h);
    Point2D anchorPoint = (Point2D) RectangleAnchor.coordinates(imageRect, 
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    g2.drawImage(this.image, (int) xx, (int) yy, null);
    
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, new Rectangle2D.Float(xx, yy, w, h), rendererIndex, 
                toolTip, url);
    }
}
 
Example #28
Source File: Plot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Resolves a range axis location for a given plot orientation.
 *
 * @param location  the location (<code>null</code> not permitted).
 * @param orientation  the orientation (<code>null</code> not permitted).
 *
 * @return The edge (never <code>null</code>).
 */
public static RectangleEdge resolveRangeAxisLocation(
        AxisLocation location, PlotOrientation orientation) {

    if (location == null) {
        throw new IllegalArgumentException("Null 'location' argument.");
    }
    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }

    RectangleEdge result = null;

    if (location == AxisLocation.TOP_OR_RIGHT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.TOP;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.RIGHT;
        }
    }
    else if (location == AxisLocation.TOP_OR_LEFT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.TOP;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.LEFT;
        }
    }
    else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.BOTTOM;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.RIGHT;
        }
    }
    else if (location == AxisLocation.BOTTOM_OR_LEFT) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            result = RectangleEdge.BOTTOM;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            result = RectangleEdge.LEFT;
        }
    }

    // the above should cover all the options...
    if (result == null) {
        throw new IllegalStateException("resolveRangeAxisLocation()");
    }
    return result;

}
 
Example #29
Source File: Cardumen_006_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * Sets the location for a domain axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 * 
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @since 1.0.5
 * 
 * @see #getDomainAxisLocation(int)
 * @see #setRangeAxisLocation(int, AxisLocation, boolean)
 */
public void setDomainAxisLocation(int index, AxisLocation location, 
        boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.domainAxisLocations.set(index, location);
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}
 
Example #30
Source File: JGenProg2017_0081_t.java    From coming with MIT License 3 votes vote down vote up
/**
 * Sets the location for a domain axis and sends a {@link PlotChangeEvent} 
 * to all registered listeners.
 * 
 * @param index  the axis index.
 * @param location  the location.
 * @param notify  notify listeners?
 * 
 * @since 1.0.5
 * 
 * @see #getDomainAxisLocation(int)
 * @see #setRangeAxisLocation(int, AxisLocation, boolean)
 */
public void setDomainAxisLocation(int index, AxisLocation location, 
        boolean notify) {
    if (index == 0 && location == null) {
        throw new IllegalArgumentException(
                "Null 'location' for index 0 not permitted.");
    }
    this.domainAxisLocations.set(index, location);
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}