Example usage for java.awt.geom Rectangle2D getWidth

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

Introduction

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

Prototype

public abstract double getWidth();

Source Link

Document

Returns the width of the framing rectangle in double precision.

Usage

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseReleased(MouseEvent e) {
    try {/*from  www .j a  v a  2  s  . c  om*/
        if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
            //            Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea(
            //                    (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY());
            JFreeChart jfc = _cp.getChart();
            XYPlot p = jfc.getXYPlot();
            CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis();
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea();

            double leftmostOnAxis = czna.getLowerBound();
            double rightmostOnAxis = czna.getUpperBound();
            double leftmostOnRange = this.coElutionRegion.getX();
            double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth();
            double leftmostonscreen = screenDataArea.getX();
            double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth();
            double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen);
            double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            shifted = false;
            MRMDialog ultimateParent = (MRMDialog) MRMAncestor();
            if (ultimateParent != null) {
                MRMTransition transition = ultimateParent.transitionOnPlot;
                MRMTransition mrmt = transition;
                if (mrmt != null) {
                    int row = mrmt.getTableRow();
                    _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f);
                    _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f);
                    _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno);
                    _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno);
                }
            }
            Graphics2D g2 = (Graphics2D) _cp.getGraphics();
            if (this.coElutionRegion != null)
                drawCoElutionRegion(g2);
            this.coElutionRegion = null;
            this.coElutionStart = null;
        } else {
            _cp.mouseReleased(e);
        }
    } catch (Exception ee) {
    }
}

From source file:org.deegree.portal.standard.wms.control.DynLegendListener.java

/**
 * takes in a HashMap holding the properties of the legend and returns the size of the legend to be
 * //  w  ww. ja va  2  s .  c  o m
 * @param map
 *            Hashmap holding the GetLegendGraphic properties
 * @return A rectangle holding the legend size
 */
private Rectangle calcLegendSize(HashMap<String, Object> map) {

    String[] layers = (String[]) map.get("NAMES");
    String[] titles = (String[]) map.get("TITLES");
    BufferedImage[] legs = (BufferedImage[]) map.get("IMAGES");

    int w = 0;
    int h = 0;
    for (int i = 0; i < layers.length; i++) {
        h += legs[i].getHeight() + 5;
        if (separator != null && i < layers.length - 1) {
            h += separator.getHeight() + 5;
        }
        Graphics g = legs[i].getGraphics();
        if (useLayerTitle && legs[i].getHeight() < maxNNLegendSize && !missing.contains(layers[i])) {
            Rectangle2D rect = g.getFontMetrics().getStringBounds(titles[i], g);
            g.dispose();
            if ((rect.getWidth() + legs[i].getWidth()) > w) {
                w = (int) rect.getWidth() + legs[i].getWidth();
            }
        } else {
            if (legs[i].getWidth() > w) {
                w = legs[i].getWidth();
            }
        }
    }
    w += 20;

    return new Rectangle(w, h);
}

From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java

/**
 * Draws the label for one radar axis./*from   w w w .ja  va2 s.  co  m*/
 *
 * @param g2 The graphics device.
 * @param chartArea The area for the radar chart.
 * @param data The data for the plot.
 * @param axis The axis (zero-based index).
 * @param startAngle The starting angle.
 */
protected void drawLabel(Graphics2D g2, Rectangle2D chartArea, String label, int axis, double labelX,
        double labelY) {

    // handle label drawing...
    FontRenderContext frc = g2.getFontRenderContext();
    Rectangle2D labelBounds = this.axisLabelFont.getStringBounds(label, frc);
    LineMetrics lm = this.axisLabelFont.getLineMetrics(label, frc);
    double ascent = lm.getAscent();

    if (labelX == chartArea.getCenterX())
        labelX -= labelBounds.getWidth() / 2;
    else if (labelX < chartArea.getCenterX())
        labelX -= labelBounds.getWidth();
    if (labelY > chartArea.getCenterY())
        labelY += ascent;

    g2.setPaint(this.axisLabelPaint);
    g2.setFont(this.axisLabelFont);
    g2.drawString(label, (float) labelX, (float) labelY);
}

From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java

public void calcGrids() {
    Rectangle2D rect = getBounds2D();
    double w = rect.getWidth();

    double h = rect.getHeight();

    if (h > 150 || w > 150) {
        Logger.getLogger("at.tuwien.ifs.somtoolbox").fine("Error: " + this);
        return;/*from  w w  w  . ja  v a 2 s .co m*/
    }

    int x = (int) rect.getX();
    int y = (int) rect.getY();

    int xSteps = (int) (w / (int) Grid.SIZE);
    int ySteps = (int) (h / (int) Grid.SIZE);

    for (int i = 0; i < xSteps; i++) {
        for (int j = 0; j < ySteps; j++) {
            Polygon p = new Polygon();
            p.addPoint((int) (x + i * Grid.SIZE), (int) (y + j * Grid.SIZE));
            p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + j * Grid.SIZE));
            p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE));
            p.addPoint((int) (x + i * Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE));
            if (this.contains(p.getBounds().x + Grid.SIZE / 2, p.getBounds().y + Grid.SIZE / 2)) {
                Pnt topLeft = new Pnt(x + i * Grid.SIZE, y + j * Grid.SIZE);
                Pnt bottomRight = new Pnt(x + i * Grid.SIZE + Grid.SIZE, y + Grid.SIZE + j * Grid.SIZE);
                Grid grid = new Grid(topLeft, bottomRight);
                grids.add(grid);
            }
        }
    }
}

From source file:org.jax.haplotype.analysis.visualization.SimplePhylogenyTreeImageFactory.java

/**
 * Get the border shape for the given label shape
 * @param labelShape/*from   www .jav  a2  s.c o  m*/
 *          the label shape that we're going to draw a border around
 * @return
 *          the border shape
 */
private Shape getLabelBorder(Shape labelShape) {
    Rectangle2D labelBounds = labelShape.getBounds2D();

    return new RoundRectangle2D.Double(labelBounds.getX() - LABEL_BORDER_ROUNDING_ARC_SIZE,
            labelBounds.getY() - LABEL_BORDER_ROUNDING_ARC_SIZE,
            labelBounds.getWidth() + (LABEL_BORDER_ROUNDING_ARC_SIZE * 2),
            labelBounds.getHeight() + (LABEL_BORDER_ROUNDING_ARC_SIZE * 2), LABEL_BORDER_ROUNDING_ARC_SIZE,
            LABEL_BORDER_ROUNDING_ARC_SIZE);
}

From source file:org.pentaho.di.core.gui.SwingGC.java

public SwingGC(Graphics2D gc, Rectangle2D rect, int iconsize, int xOffset, int yOffset) throws KettleException {
    this(null, gc, null, new Point((int) rect.getWidth(), (int) rect.getHeight()), iconsize, xOffset, yOffset);
}

From source file:org.squidy.designer.zoom.impl.DataTypeShape.java

/**
 * TODO [RR]: Needs refactoring for automatically computes visual hierarchy.
 *//* w w  w. j  a  v  a 2  s . c  o m*/
private void buildDataHierarchy() {

    PBounds bounds = getBoundsReference();
    Rectangle2D rectBounds = roundedRectangleShape.getBounds2D();

    DataItemShape iData = new DataItemShape(IData.class, true);
    iData.setBounds(rectBounds);
    iData.setOffset(bounds.getCenterX() - rectBounds.getCenterX(), 0);
    addChild(iData);

    Class<? extends IData>[] typesFirstRow = DataUtility.DATA_FIRST_LEVEL;
    int amount = typesFirstRow.length;
    double spacing = (bounds.getWidth() - (amount * rectBounds.getWidth())) / (amount - 1);
    for (int i = 0; i < amount; i++) {
        boolean selected = dataTypes.contains(typesFirstRow[i]);
        DataItemShape item = new DataItemShape(typesFirstRow[i], selected);
        item.setBounds(rectBounds);
        item.setOffset((i * rectBounds.getWidth()) + (i * spacing), rectBounds.getHeight() + 200);
        addChild(item);
    }

    Class<? extends IData>[] typesSecondRow = DataUtility.DATA_SECOND_LEVEL;
    amount = typesSecondRow.length;
    spacing = (bounds.getWidth() - (amount * rectBounds.getWidth())) / (amount - 1);
    for (int i = 0; i < amount; i++) {
        boolean selected = dataTypes.contains(typesSecondRow[i]);
        DataItemShape item = new DataItemShape(typesSecondRow[i], selected);
        item.setBounds(rectBounds);
        item.setOffset((i * rectBounds.getWidth()) + (i * spacing), (2 * rectBounds.getHeight()) + (2 * 200));
        addChild(item);
    }

    amount = 4;
    spacing = (bounds.getWidth() - (amount * rectBounds.getWidth())) / (amount - 1);
    boolean selected = dataTypes.contains(DataUtility.DATA_THIRD_LEVEL[0]);
    DataItemShape item = new DataItemShape(DataUtility.DATA_THIRD_LEVEL[0], selected);
    item.setBounds(rectBounds);
    item.setOffset((1 * rectBounds.getWidth()) + (1 * spacing), (3 * rectBounds.getHeight()) + (3 * 200));
    addChild(item);
}

From source file:Polygon2D.java

/**
 * Tests if the interior of this <code>Polygon</code> entirely
 * contains the specified <code>Rectangle2D</code>.
 * @param r the specified <code>Rectangle2D</code>
 * @return <code>true</code> if this <code>Polygon</code> entirely
 *                         contains the specified <code>Rectangle2D</code>;
 *                        <code>false</code> otherwise.
 * @see #contains(double, double, double, double)
 */// w w  w .jav a  2  s .  com
public boolean contains(Rectangle2D r) {
    return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
}

From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java

private AffineTransform createTransform(double x, double y, BufferedImage image, Rectangle2D dataArea) {
    int wi = image.getWidth();
    wi--;/* w  ww  .  j  av  a  2 s  .co  m*/
    int hi = image.getHeight();
    hi--;
    double wd = dataArea.getWidth();
    wd--;
    double hd = dataArea.getHeight();
    hd--;
    double a = wd / wi;
    double b = hd / hi;
    double m00 = a;
    double m01 = 0;
    double m02 = -x * a + x;
    double m10 = 0;
    double m11 = b;
    double m12 = -y * b + y;
    AffineTransform at = new AffineTransform(m00, m10, m01, m11, m02, m12);
    return at;
}

From source file:Polygon2D.java

/**
 * Tests if the interior of this <code>Polygon</code> intersects the
 * interior of a specified <code>Rectangle2D</code>.
 * @param r a specified <code>Rectangle2D</code>
 * @return <code>true</code> if this <code>Polygon</code> and the
 *                         interior of the specified <code>Rectangle2D</code>
 *                         intersect each other; <code>false</code>
 *                         otherwise.//ww  w  .j  a va  2 s .  co  m
 */
public boolean intersects(Rectangle2D r) {
    return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
}