Example usage for java.awt.geom Rectangle2D getY

List of usage examples for java.awt.geom Rectangle2D getY

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getY.

Prototype

public abstract double getY();

Source Link

Document

Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.

Usage

From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java

/**
 * Creates a rectangle that is aligned to the frame.
 *
 * @param dimensions/*w w  w. ja va2 s  .  c  o m*/
 *          the dimensions for the rectangle.
 * @param frame
 *          the frame to align to.
 * @param hAlign
 *          the horizontal alignment.
 * @param vAlign
 *          the vertical alignment.
 * @return A rectangle.
 */
private static final Rectangle2D __createAlignedRectangle2D(final Size2D dimensions, final Rectangle2D frame,
        final HorizontalAlignment hAlign, final VerticalAlignment vAlign) {
    double x, y;

    x = y = Double.NaN;

    if (hAlign == HorizontalAlignment.LEFT) {
        x = frame.getX();
    } else if (hAlign == HorizontalAlignment.CENTER) {
        x = frame.getCenterX() - (dimensions.width / 2.0);
    } else if (hAlign == HorizontalAlignment.RIGHT) {
        x = frame.getMaxX() - dimensions.width;
    }
    if (vAlign == VerticalAlignment.TOP) {
        y = frame.getY();
    } else if (vAlign == VerticalAlignment.CENTER) {
        y = frame.getCenterY() - (dimensions.height / 2.0);
    } else if (vAlign == VerticalAlignment.BOTTOM) {
        y = frame.getMaxY() - dimensions.height;
    }

    return new Rectangle2D.Double(x, y, dimensions.width, dimensions.height);
}

From source file:ca.sqlpower.wabit.swingui.chart.WabitJFreeChartPanel.java

private float getXaxisBaseline() {
    Rectangle2D dataArea = getScreenDataArea();
    return (float) (dataArea.getY() + dataArea.getHeight());
}

From source file:edu.ucla.stat.SOCR.chart.gui.CircleDrawer.java

/**
 * Draws the circle./*w  ww  .ja  v  a 2 s. c  o  m*/
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY());
    Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(), area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:org.jfree.chart.demo.CircleDrawer.java

/**
 * Draws the circle./*from  www  .j  ava 2s. c  om*/
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(final Graphics2D g2, final Rectangle2D area) {
    final Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    final Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(),
            area.getMaxY());
    final Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(),
            area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:net.sf.jasperreports.customizers.shape.LineDotShapeCustomizer.java

@Override
protected Point getOffset(Rectangle2D bounds) {
    return new Point((int) (bounds.getWidth() / 2 + bounds.getX()),
            (int) (bounds.getHeight() / 2 + bounds.getY()));
}

From source file:com.rapidminer.gui.plotter.charts.WeightBasedSymbolAxis.java

/**
 * Draws the grid bands for the axis when it is at the top or bottom of the plot.
 * /*  www . j a  v a  2s  .  c o  m*/
 * @param g2
 *            the graphics device.
 * @param plotArea
 *            the area within which the chart should be drawn.
 * @param dataArea
 *            the area within which the plot should be drawn (a subset of the drawArea).
 * @param firstGridBandIsDark
 *            True: the first grid band takes the color of <CODE>gridBandPaint<CODE>.
 *                             False: the second grid band takes the
 *                             color of <CODE>gridBandPaint<CODE>.
 * @param ticks
 *            the ticks.
 */
@Override
protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
        boolean firstGridBandIsDark, List ticks) {
    double yy = dataArea.getY();
    double xx1, xx2;

    // gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() != null) {
        outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    } else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D band;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        int weightIndex = (int) tick.getValue();
        xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.BOTTOM);
        xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.BOTTOM);

        g2.setColor(PlotterAdapter.getWeightColor(this.weights[weightIndex], this.maxWeight));

        band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, xx2 - xx1,
                dataArea.getMaxY() - yy - outlineStrokeWidth);
        g2.fill(band);
    }
    g2.setPaintMode();
}

From source file:ucar.unidata.idv.control.chart.MyTimeSeriesPlot.java

/**
 * Override this method because it gets called after the graphics clip
 * has been reset.//w  ww .  j  a  v a 2s  .co m
 * TODO: We end up drawing the annotations twice. Figure something out to
 * only draw once.
 *
 * @param g2  the graphics
 * @param dataArea the data area
 */
public void drawOutline(Graphics2D g2, Rectangle2D dataArea) {
    super.drawOutline(g2, dataArea);
    Shape originalClip = g2.getClip();
    double y = dataArea.getY();
    Rectangle2D.Double newClip = new Rectangle2D.Double(dataArea.getX(), 0, dataArea.getWidth(),
            dataArea.getHeight() + y);

    g2.clip(newClip);
    drawAnnotations(g2, dataArea, null);
    g2.clip(originalClip);
}

From source file:grafix.telas.MolduraAreaDados.java

public void setPosicao(Rectangle2D rect) {
    this.setLocation((int) rect.getX(), (int) rect.getY());
    this.setSize((int) rect.getWidth(), (int) rect.getHeight());
}

From source file:ShowOff.java

protected float drawBoxedString(Graphics2D g2, String s, Color c1, Color c2, double x) {
    FontRenderContext frc = g2.getFontRenderContext();
    TextLayout subLayout = new TextLayout(s, mFont, frc);
    float advance = subLayout.getAdvance();

    GradientPaint gradient = new GradientPaint((float) x, 0, c1, (float) (x + advance), 0, c2);
    g2.setPaint(gradient);//from   www .  j  av a2 s.com
    Rectangle2D bounds = mLayout.getBounds();
    Rectangle2D back = new Rectangle2D.Double(x, 0, advance, bounds.getHeight());
    g2.fill(back);

    g2.setPaint(Color.white);
    g2.setFont(mFont);
    g2.drawString(s, (float) x, (float) -bounds.getY());
    return advance;
}

From source file:edu.uci.ics.jung.visualization.util.VertexShapeFactory.java

/**
 * Returns a <code>RoundRectangle2D</code> whose width and 
 * height are defined by this instance's size and
 * aspect ratio functions for this vertex.  The arc size is
 * set to be half the minimum of the height and width of the frame.
 *//*from  w  w  w .  j  a va 2 s. c  om*/
public RoundRectangle2D getRoundRectangle(V v) {
    Rectangle2D frame = getRectangle(v);
    float arc_size = (float) Math.min(frame.getHeight(), frame.getWidth()) / 2;
    theRoundRectangle.setRoundRect(frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight(), arc_size,
            arc_size);
    return theRoundRectangle;
}