Java Code Examples for java.awt.geom.Rectangle2D#getMinY()

The following examples show how to use java.awt.geom.Rectangle2D#getMinY() . 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: EESGenerator.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
@Override
public RepresentationResponse producePresentation(DesignOptions options) throws GeneratorException {
    ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
    String chartUrl = createChart(options, renderingInfo);
    
    Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea();
    for (Axis axis : renderer.getAxisMapping().values()) {
        axis.setMaxY(plotArea.getMaxY());
        axis.setMinY(plotArea.getMinY());
    }

    ImageEntity[] entities = {};
    if (!this.isOverview) {
        LOGGER.debug("Produced EES diagram " + chartUrl);
        entities = createImageEntities(renderingInfo.getEntityCollection());
    } else {
        LOGGER.debug("Produced EES Overview diagram " + chartUrl);
    }

    Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(), plotArea.getMaxY());
    return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping());
}
 
Example 2
Source File: jMutRepair_001_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Utility method for drawing a line perpendicular to the range axis (used
 * for crosshairs).
 *
 * @param g2  the graphics device.
 * @param dataArea  the area defined by the axes.
 * @param value  the data value.
 * @param stroke  the line stroke (<code>null</code> not permitted).
 * @param paint  the line paint (<code>null</code> not permitted).
 */
protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea,
        double value, Stroke stroke, Paint paint) {

    double java2D = getRangeAxis().valueToJava2D(value, dataArea, 
            getRangeAxisEdge());
    Line2D line = null;
    if (this.orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, 
                dataArea.getMaxY());
    }
    else if (this.orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), java2D, 
                dataArea.getMaxX(), java2D);
    }
    g2.setStroke(stroke);
    g2.setPaint(paint);
    g2.draw(line);

}
 
Example 3
Source File: Cardumen_009_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a range crosshair.
 *
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 *
 * @since 1.0.4
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea,
        PlotOrientation orientation, double value, ValueAxis axis,
        Stroke stroke, Paint paint) {

    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            double xx = axis.valueToJava2D(value, dataArea,
                    RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx,
                    dataArea.getMaxY());
        }
        else {
            double yy = axis.valueToJava2D(value, dataArea,
                    RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy,
                    dataArea.getMaxX(), yy);
        }
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }

}
 
Example 4
Source File: Cardumen_006_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a range crosshair.
 * 
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 * 
 * @since 1.0.5
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, 
        PlotOrientation orientation, double value, ValueAxis axis, 
        Stroke stroke, Paint paint) {
    
    if (!axis.getRange().contains(value)) {
        return;
    }
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        double xx = axis.valueToJava2D(value, dataArea, 
                RectangleEdge.BOTTOM);
        line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                dataArea.getMaxY());
    }
    else {
        double yy = axis.valueToJava2D(value, dataArea, 
                RectangleEdge.LEFT);
        line = new Line2D.Double(dataArea.getMinX(), yy, 
                dataArea.getMaxX(), yy);
    }
    g2.setStroke(stroke);
    g2.setPaint(paint);
    g2.draw(line);
   
}
 
Example 5
Source File: StandardGlyphVector.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For each glyph return posx, posy, advx, advy, visx, visy, visw, vish.
 */
public float[] getGlyphInfo() {
    setFRCTX();
    initPositions();
    float[] result = new float[glyphs.length * 8];
    for (int i = 0, n = 0; i < glyphs.length; ++i, n += 8) {
        float x = positions[i*2];
        float y = positions[i*2+1];
        result[n] = x;
        result[n+1] = y;

        int glyphID = glyphs[i];
        GlyphStrike s = getGlyphStrike(i);
        Point2D.Float adv = s.strike.getGlyphMetrics(glyphID);
        result[n+2] = adv.x;
        result[n+3] = adv.y;

        Rectangle2D vb = getGlyphVisualBounds(i).getBounds2D();
        result[n+4] = (float)(vb.getMinX());
        result[n+5] = (float)(vb.getMinY());
        result[n+6] = (float)(vb.getWidth());
        result[n+7] = (float)(vb.getHeight());
    }
    return result;
}
 
Example 6
Source File: AbstractPolygon2D.java    From beast-mcmc with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected static Point2D intersectionPoint2D(Side side, Point2D p1, Point2D p2, Rectangle2D boundingBox) {

        if (side == Side.top) {
            final double topEdge = boundingBox.getMaxY();
            return new Point2D.Double(p1.getX() + (topEdge - p1.getY()) * (p2.getX() - p1.getX()) / (p2.getY() - p1.getY()), topEdge);
        } else if (side == Side.bottom) {
            final double bottomEdge = boundingBox.getMinY();
            return new Point2D.Double(p1.getX() + (bottomEdge - p1.getY()) * (p2.getX() - p1.getX()) / (p2.getY() - p1.getY()), bottomEdge);
        } else if (side == Side.right) {
            final double rightEdge = boundingBox.getMaxX();
            return new Point2D.Double(rightEdge, p1.getY() + (rightEdge - p1.getX()) * (p2.getY() - p1.getY()) / (p2.getX() - p1.getX()));
        } else if (side == Side.left) {
            final double leftEdge = boundingBox.getMinX();
            return new Point2D.Double(leftEdge, p1.getY() + (leftEdge - p1.getX()) * (p2.getY() - p1.getY()) / (p2.getX() - p1.getX()));
        }
        return null;
    }
 
Example 7
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Draws a horizontal line used to trace the mouse position to the vertical axis.
 * 
 * @param g2
 *            the graphics device.
 * @param y
 *            the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(Graphics2D g2, int y) {

	Rectangle2D dataArea = getScreenDataArea();

	g2.setXORMode(Color.orange);
	if ((int) dataArea.getMinY() < y && y < (int) dataArea.getMaxY()) {

		if (this.horizontalTraceLine != null) {
			g2.draw(this.horizontalTraceLine);
			this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
		} else {
			this.horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
		}
		g2.draw(this.horizontalTraceLine);
	}

	// Reset to the default 'overwrite' mode
	g2.setPaintMode();
}
 
Example 8
Source File: IntervalRectangle.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a {@code Rectangle2D} object to this rectangle.
 * The resulting rectangle is the union of the two {@code Rectangle2D} objects.
 *
 * @param  rect  the {@code Rectangle2D} to add to this rectangle.
 */
@Override
public final void add(final Rectangle2D rect) {
    double t;
    if ((t = rect.getMinX()) < xmin) xmin = t;
    if ((t = rect.getMaxX()) > xmax) xmax = t;
    if ((t = rect.getMinY()) < ymin) ymin = t;
    if ((t = rect.getMaxY()) > ymax) ymax = t;
}
 
Example 9
Source File: jMutRepair_0020_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Draws a grid line against the domain axis.
 * <P>
 * Note that this default implementation assumes that the horizontal axis
 * is the domain axis. If this is not the case, you will need to override
 * this method.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the Java2D value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis,
 *     Rectangle2D, double)
 *
 * @since 1.2.0
 */
public void drawDomainLine(Graphics2D g2, CategoryPlot plot,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument.");
    }
    if (stroke == null) {
        throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    Line2D line = null;
    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), value,
                dataArea.getMaxX(), value);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(value, dataArea.getMinY(), value,
                dataArea.getMaxY());
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 10
Source File: jKali_000_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Draws a grid line against the domain axis.
 * <P>
 * Note that this default implementation assumes that the horizontal axis
 * is the domain axis. If this is not the case, you will need to override
 * this method.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the Java2D value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis,
 *     Rectangle2D, double)
 *
 * @since 1.2.0
 */
public void drawDomainLine(Graphics2D g2, CategoryPlot plot,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    if (paint == null) {
        throw new IllegalArgumentException("Null 'paint' argument.");
    }
    if (stroke == null) {
        throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    Line2D line = null;
    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), value,
                dataArea.getMaxX(), value);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(value, dataArea.getMinY(), value,
                dataArea.getMaxY());
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 11
Source File: TabbedPaneTabCloseButtonPainter.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Create the gradient for the "x" drop shadow.
 *
 * @param  s the Shape for the gradient.
 *
 * @return the gradient paint.
 */
private Paint createGraphicDropShadowGradient(Shape s) {
    Rectangle2D b    = s.getBounds2D();
    float       midX = (float) b.getCenterX();
    float       y1   = (float) b.getMinY();
    float       y2   = (float) b.getMaxY();

    return createGradient(midX, y1, midX, y2, new float[] { 0f, 0.43f, 0.57f, 1f },
                          new Color[] { graphicDropShadow1, graphicDropShadow2, graphicDropShadow3, graphicDropShadow4 });
}
 
Example 12
Source File: ContourPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a vertical line on the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawDomainMarker(Graphics2D g2,
                             ContourPlot plot,
                             ValueAxis domainAxis,
                             Marker marker,
                             Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = domainAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double x = domainAxis.valueToJava2D(value, dataArea,
                RectangleEdge.BOTTOM);
        Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
                dataArea.getMaxY());
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
Example 13
Source File: PointerNeedle.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                          Point2D rotate, double angle) {

    GeneralPath shape1 = new GeneralPath();
    GeneralPath shape2 = new GeneralPath();
    float minX = (float) plotArea.getMinX();
    float minY = (float) plotArea.getMinY();
    float maxX = (float) plotArea.getMaxX();
    float maxY = (float) plotArea.getMaxY();
    float midX = (float) (minX + (plotArea.getWidth() / 2));
    float midY = (float) (minY + (plotArea.getHeight() / 2));

    shape1.moveTo(minX, midY);
    shape1.lineTo(midX, minY);
    shape1.lineTo(maxX, midY);
    shape1.closePath();

    shape2.moveTo(minX, midY);
    shape2.lineTo(midX, maxY);
    shape2.lineTo(maxX, midY);
    shape2.closePath();

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation huston, please spin me
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape1.transform(getTransform());
        shape2.transform(getTransform());
    }

    if (getFillPaint() != null) {
        g2.setPaint(getFillPaint());
        g2.fill(shape1);
    }

    if (getHighlightPaint() != null) {
        g2.setPaint(getHighlightPaint());
        g2.fill(shape2);
    }

    if (getOutlinePaint() != null) {
        g2.setStroke(getOutlineStroke());
        g2.setPaint(getOutlinePaint());
        g2.draw(shape1);
        g2.draw(shape2);
    }
}
 
Example 14
Source File: BarRenderer3D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the background for the plot.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area inside the axes.
 */
public void drawBackground(Graphics2D g2, CategoryPlot plot, 
                           Rectangle2D dataArea) {

    float x0 = (float) dataArea.getX();
    float x1 = x0 + (float) Math.abs(this.xOffset);
    float x3 = (float) dataArea.getMaxX();
    float x2 = x3 - (float) Math.abs(this.xOffset);

    float y0 = (float) dataArea.getMaxY();
    float y1 = y0 - (float) Math.abs(this.yOffset);
    float y3 = (float) dataArea.getMinY();
    float y2 = y3 + (float) Math.abs(this.yOffset);

    GeneralPath clip = new GeneralPath();
    clip.moveTo(x0, y0);
    clip.lineTo(x0, y2);
    clip.lineTo(x1, y3);
    clip.lineTo(x3, y3);
    clip.lineTo(x3, y1);
    clip.lineTo(x2, y0);
    clip.closePath();

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            plot.getBackgroundAlpha()));
    
    // fill background...
    Paint backgroundPaint = plot.getBackgroundPaint();
    if (backgroundPaint != null) {
        g2.setPaint(backgroundPaint);
        g2.fill(clip);
    }

    GeneralPath leftWall = new GeneralPath();
    leftWall.moveTo(x0, y0);
    leftWall.lineTo(x0, y2);
    leftWall.lineTo(x1, y3);
    leftWall.lineTo(x1, y1);
    leftWall.closePath();
    g2.setPaint(getWallPaint());
    g2.fill(leftWall);

    GeneralPath bottomWall = new GeneralPath();
    bottomWall.moveTo(x0, y0);
    bottomWall.lineTo(x1, y1);
    bottomWall.lineTo(x3, y1);
    bottomWall.lineTo(x2, y0);
    bottomWall.closePath();
    g2.setPaint(getWallPaint());
    g2.fill(bottomWall);

    // highlight the background corners...
    g2.setPaint(Color.lightGray);
    Line2D corner = new Line2D.Double(x0, y0, x1, y1);
    g2.draw(corner);
    corner.setLine(x1, y1, x1, y3);
    g2.draw(corner);
    corner.setLine(x1, y1, x3, y1);
    g2.draw(corner);
            
    // draw background image, if there is one...
    Image backgroundImage = plot.getBackgroundImage();
    if (backgroundImage != null) {
        Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() 
                + getXOffset(), dataArea.getY(), 
                dataArea.getWidth() - getXOffset(), 
                dataArea.getHeight() - getYOffset());
        plot.drawBackgroundImage(g2, adjusted);
    }
    
    g2.setComposite(originalComposite);

}
 
Example 15
Source File: clsClipPolygon2.java    From mil-sym-java with Apache License 2.0 4 votes vote down vote up
/**
 * for non-areas add points to the ends as necessary to make the algorithm work
 * @param polygon
 * @param clipBounds
 */
private static int AddBoundaryPointsForLines(ArrayList<Point2D> polygon,
        Rectangle2D clipBounds) {
    int result = 0;
    try {
        double ulx = 0, uly = 0, lrx = 0, lry = 0;
        ulx = clipBounds.getMinX();
        uly = clipBounds.getMinY();
        lrx = clipBounds.getMaxX();
        lry = clipBounds.getMaxY();
        //move these inside by 10 pixels so the algoithm will treat them as inside points
        Point2D ul = new Point2D.Double(ulx + 10, uly + 10);
        Point2D ur = new Point2D.Double(lrx - 10, uly + 10);
        Point2D ll = new Point2D.Double(ulx + 10, lry - 10);
        Point2D lr = new Point2D.Double(lrx - 10, lry - 10);

        Point2D pt0 = polygon.get(0);
        Point2D ptn = polygon.get(polygon.size() - 1);
        //double dist0 = 0, dist1 = 0;
        Boolean addToFront = false, addToEnd = false;
        //add a point to the begining of the array
        if (pt0.getY() < uly) //above the top clip
        {
            polygon.add(0, ul);
            addToFront = true;
        } else if (pt0.getX() < ulx) //outside the left clip
        {
            polygon.add(0, ul);
            addToFront = true;
        } else if (pt0.getX() > lrx) //outside the right clip
        {
            polygon.add(0, lr);
            addToFront = true;
        } else if (pt0.getY() > lry) //below the bottom clip
        {
            polygon.add(0, lr);
            addToFront = true;
        }

        //add a point to the end of the array
        if (ptn.getY() < uly) //above the top clip
        {
            polygon.add(ul);
            addToEnd = true;
        } else if (ptn.getX() < ulx) //outside the left clip
        {
            polygon.add(ul);
            addToEnd = true;
        } else if (ptn.getX() > lrx) //outside the right clip
        {
            polygon.add(lr);
            addToEnd = true;
        } else if (ptn.getY() > lry) //below the bottom clip
        {
            polygon.add(lr);
            addToEnd = true;
        }

        if (addToFront == false && addToEnd == false) {
            result = 0;
        }
        if (addToFront == true && addToEnd == false) {
            result = 1;
        }
        if (addToFront == false && addToEnd == true) {
            result = 2;
        }
        if (addToFront == true && addToEnd == true) {
            result = 3;
        }

    } catch (Exception exc) {
        ErrorLogger.LogException(_className, "AddBoundaryPointsForLines",
                new RendererException("Failed inside AddBoundaryPointsForLines", exc));
    }
    return result;
}
 
Example 16
Source File: clsClipQuad.java    From mil-sym-java with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated
 * @param polygon
 * @param clipBounds
 * @return 
 */
private static int AddBoundaryPointsForLines(ArrayList<Point2D> polygon,
        Rectangle2D clipBounds) {
    int result = 0;
    try {
        double ulx = 0, uly = 0, lrx = 0, lry = 0;
        ulx = clipBounds.getMinX();
        uly = clipBounds.getMinY();
        lrx = clipBounds.getMaxX();
        lry = clipBounds.getMaxY();
        //move these inside by 10 pixels so the algoithm will treat them as inside points
        Point2D ul = new Point2D.Double(ulx + 10, uly + 10);
        Point2D lr = new Point2D.Double(lrx - 10, lry - 10);

        Point2D pt0 = polygon.get(0);
        Point2D ptn = polygon.get(polygon.size() - 1);
        Boolean addToFront = false, addToEnd = false;            
        //add a point to the begining of the array
        if (pt0.getY() < uly) //above the top clip
        {
            polygon.add(0, ul);
            addToFront = true;
        } else if (pt0.getX() < ulx) //outside the left clip
        {
            polygon.add(0, ul);
            addToFront = true;
        } else if (pt0.getX() > lrx) //outside the right clip
        {
            polygon.add(0, lr);
            addToFront = true;
        } else if (pt0.getY() > lry) //below the bottom clip
        {
            polygon.add(0, lr);
            addToFront = true;
        }

        //add a point to the end of the array
        if (ptn.getY() < uly) //above the top clip
        {
            polygon.add(ul);
            addToEnd = true;
        } else if (ptn.getX() < ulx) //outside the left clip
        {
            polygon.add(ul);
            addToEnd = true;
        } else if (ptn.getX() > lrx) //outside the right clip
        {
            polygon.add(lr);
            addToEnd = true;
        } else if (ptn.getY() > lry) //below the bottom clip
        {
            polygon.add(lr);
            addToEnd = true;
        }

        if (addToFront == false && addToEnd == false) {
            result = 0;
        }
        if (addToFront == true && addToEnd == false) {
            result = 1;
        }
        if (addToFront == false && addToEnd == true) {
            result = 2;
        }
        if (addToFront == true && addToEnd == true) {
            result = 3;
        }

    } catch (Exception exc) {
        ErrorLogger.LogException(_className, "AddBoundaryPointsForLines",
                new RendererException("Failed inside AddBoundaryPointsForLines", exc));
    }
    return result;
}
 
Example 17
Source File: PointerNeedle.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 
                          Point2D rotate, double angle) {

    GeneralPath shape1 = new GeneralPath();
    GeneralPath shape2 = new GeneralPath();
    float minX = (float) plotArea.getMinX();
    float minY = (float) plotArea.getMinY();
    float maxX = (float) plotArea.getMaxX();
    float maxY = (float) plotArea.getMaxY();
    float midX = (float) (minX + (plotArea.getWidth() / 2));
    float midY = (float) (minY + (plotArea.getHeight() / 2));

    shape1.moveTo(minX, midY);
    shape1.lineTo(midX, minY);
    shape1.lineTo(maxX, midY);
    shape1.closePath();

    shape2.moveTo(minX, midY);
    shape2.lineTo(midX, maxY);
    shape2.lineTo(maxX, midY);
    shape2.closePath();

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation huston, please spin me
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape1.transform(getTransform());
        shape2.transform(getTransform());
    }

    if (getFillPaint() != null) {
        g2.setPaint(getFillPaint());
        g2.fill(shape1);
    }

    if (getHighlightPaint() != null) {
        g2.setPaint(getHighlightPaint());
        g2.fill(shape2);
    }

    if (getOutlinePaint() != null) {
        g2.setStroke(getOutlineStroke());
        g2.setPaint(getOutlinePaint());
        g2.draw(shape1);
        g2.draw(shape2);
    }
}
 
Example 18
Source File: 1_AbstractCategoryItemRenderer.java    From SimFix with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws a marker for the domain axis.
 *
 * @param g2  the graphics device (not <code>null</code>).
 * @param plot  the plot (not <code>null</code>).
 * @param axis  the range axis (not <code>null</code>).
 * @param marker  the marker to be drawn (not <code>null</code>).
 * @param dataArea  the area inside the axes (not <code>null</code>).
 *
 * @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
 *     Rectangle2D)
 */
public void drawDomainMarker(Graphics2D g2,
                             CategoryPlot plot,
                             CategoryAxis axis,
                             CategoryMarker marker,
                             Rectangle2D dataArea) {

    Comparable category = marker.getKey();
    CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this));
    int columnIndex = dataset.getColumnIndex(category);
    if (columnIndex < 0) {
        return;
    }

    final Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha()));

    PlotOrientation orientation = plot.getOrientation();
    Rectangle2D bounds = null;
    if (marker.getDrawAsLine()) {
        double v = axis.getCategoryMiddle(columnIndex,
                dataset.getColumnCount(), dataArea,
                plot.getDomainAxisEdge());
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            line = new Line2D.Double(dataArea.getMinX(), v,
                    dataArea.getMaxX(), v);
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            line = new Line2D.Double(v, dataArea.getMinY(), v,
                    dataArea.getMaxY());
        }
        g2.setPaint(marker.getPaint());
        g2.setStroke(marker.getStroke());
        g2.draw(line);
        bounds = line.getBounds2D();
    }
    else {
        double v0 = axis.getCategoryStart(columnIndex,
                dataset.getColumnCount(), dataArea,
                plot.getDomainAxisEdge());
        double v1 = axis.getCategoryEnd(columnIndex,
                dataset.getColumnCount(), dataArea,
                plot.getDomainAxisEdge());
        Rectangle2D area = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            area = new Rectangle2D.Double(dataArea.getMinX(), v0,
                    dataArea.getWidth(), (v1 - v0));
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            area = new Rectangle2D.Double(v0, dataArea.getMinY(),
                    (v1 - v0), dataArea.getHeight());
        }
        g2.setPaint(marker.getPaint());
        g2.fill(area);
        bounds = area;
    }

    String label = marker.getLabel();
    RectangleAnchor anchor = marker.getLabelAnchor();
    if (label != null) {
        Font labelFont = marker.getLabelFont();
        g2.setFont(labelFont);
        g2.setPaint(marker.getLabelPaint());
        Point2D coordinates = calculateDomainMarkerTextAnchorPoint(
                g2, orientation, dataArea, bounds, marker.getLabelOffset(),
                marker.getLabelOffsetType(), anchor);
        TextUtilities.drawAlignedString(label, g2,
                (float) coordinates.getX(), (float) coordinates.getY(),
                marker.getLabelTextAnchor());
    }
    g2.setComposite(savedComposite);
}
 
Example 19
Source File: CrosshairOverlay.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws a crosshair vertically on the plot.
 *
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param x  the x-value in Java2D space.
 * @param crosshair  the crosshair.
 */
protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea,
        double x, Crosshair crosshair) {

    if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) {
        Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
                dataArea.getMaxY());
        Paint savedPaint = g2.getPaint();
        Stroke savedStroke = g2.getStroke();
        g2.setPaint(crosshair.getPaint());
        g2.setStroke(crosshair.getStroke());
        g2.draw(line);
        if (crosshair.isLabelVisible()) {
            String label = crosshair.getLabelGenerator().generateLabel(
                    crosshair);
            RectangleAnchor anchor = crosshair.getLabelAnchor();
            Point2D pt = calculateLabelPoint(line, anchor, 5, 5);
            float xx = (float) pt.getX();
            float yy = (float) pt.getY();
            TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor);
            Shape hotspot = TextUtilities.calculateRotatedStringBounds(
                    label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
            if (!dataArea.contains(hotspot.getBounds2D())) {
                anchor = flipAnchorH(anchor);
                pt = calculateLabelPoint(line, anchor, 5, 5);
                xx = (float) pt.getX();
                yy = (float) pt.getY();
                alignPt = textAlignPtForLabelAnchorV(anchor);
                hotspot = TextUtilities.calculateRotatedStringBounds(
                       label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER);
            }
            g2.setPaint(crosshair.getLabelBackgroundPaint());
            g2.fill(hotspot);
            g2.setPaint(crosshair.getLabelOutlinePaint());
            g2.draw(hotspot);
            TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt);
        }
        g2.setPaint(savedPaint);
        g2.setStroke(savedStroke);
    }
}
 
Example 20
Source File: IntervalRectangle.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Intersects a {@link Rectangle2D} object with this rectangle.
 * The resulting* rectangle is the intersection of the two {@code Rectangle2D} objects.
 * Invoking this method is equivalent to invoking the following code, except that this
 * method behaves correctly with infinite values and {@link Envelope2D} implementation.
 *
 * {@preformat java
 *     Rectangle2D.intersect(this, rect, this);
 * }
 *
 * @param  rect  the {@code Rectangle2D} to intersect with this rectangle.
 *
 * @see #intersect(Rectangle2D, Rectangle2D, Rectangle2D)
 * @see #createIntersection(Rectangle2D)
 */
public final void intersect(final Rectangle2D rect) {
    double t;
    // Must use getMin/Max methods, not getX/Y/Width/Height, for inter-operability with Envelope2D.
    if ((t = rect.getMinX()) > xmin) xmin = t;
    if ((t = rect.getMaxX()) < xmax) xmax = t;
    if ((t = rect.getMinY()) > ymin) ymin = t;
    if ((t = rect.getMaxY()) < ymax) ymax = t;
}