Java Code Examples for org.jfree.chart.plot.XYPlot#getRangeAxisLocation()

The following examples show how to use org.jfree.chart.plot.XYPlot#getRangeAxisLocation() . 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: XYTitleAnnotation.java    From ECG-Viewer 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.
 */
@Override
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);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 2
Source File: XYTitleAnnotation.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 domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            domainAxisLocation, orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            rangeAxisLocation, orientation);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 3
Source File: XYImageAnnotation.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 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 4
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 5
Source File: XYTitleAnnotation.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 domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            domainAxisLocation, orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            rangeAxisLocation, orientation);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 6
Source File: XYTitleAnnotation.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);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX = 0.0;
    double anchorY = 0.0;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }
    
    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, 
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }
    
    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));
    
    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, 
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, 
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy, 
            		(float) size.width, (float) size.height), 
            		rendererIndex, toolTip, url);
        }
    }
}
 
Example 7
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 8
Source File: XYTitleAnnotation.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);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX = 0.0;
    double anchorY = 0.0;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 9
Source File: XYDataImageAnnotation.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 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 10
Source File: XYImageAnnotation.java    From ECG-Viewer 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.
 */
@Override
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 11
Source File: XYImageAnnotation.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 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 12
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 13
Source File: XYImageAnnotation.java    From SIMVA-SoS 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.
 */
@Override
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 14
Source File: XYTitleAnnotation.java    From SIMVA-SoS 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.
 */
@Override
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);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 15
Source File: XYDataImageAnnotation.java    From SIMVA-SoS 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.
 */
@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 16
Source File: XYImageAnnotation.java    From ccu-historian 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 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 17
Source File: XYTitleAnnotation.java    From ccu-historian 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 domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            domainAxisLocation, orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            rangeAxisLocation, orientation);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}
 
Example 18
Source File: XYDataImageAnnotation.java    From ccu-historian 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 19
Source File: XYImageAnnotation.java    From openstock 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 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 20
Source File: XYTitleAnnotation.java    From openstock 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 domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            domainAxisLocation, orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            rangeAxisLocation, orientation);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX, anchorY;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    }
    else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, 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;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(
            new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
            size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
            this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (info != null) {
        if (result instanceof EntityBlockResult) {
            EntityBlockResult ebr = (EntityBlockResult) result;
            info.getOwner().getEntityCollection().addAll(
                    ebr.getEntityCollection());
        }
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, new Rectangle2D.Float(xx, yy,
                    (float) size.width, (float) size.height),
                    rendererIndex, toolTip, url);
        }
    }
}