Java 8 RectangularShape - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RectangularShape class.

This code example shows how to use the following methods:getHeight, getWidth, getX, getY
    public Rect(Rect r) {
        this(r.x, r.y, r.width, r.height);
    } 
 
    public Rect(java.awt.geom.Rectangle2D r) {
        this(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    } 
 
    public double getHeight() { 
        return height;
    } 
 
    public double getWidth() { 
        return width;
    } 
 
    public double getX() { 
        return x;
    } 
 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
     */ 
    public void write(final String tagName, final Object object, final XMLWriter writer,
                      final String mPlexAttribute, final String mPlexValue)
        throws IOException, XMLWriterException {
        final Rectangle2D rect = (Rectangle2D) object;
        final double x = rect.getX();
        final double y = rect.getY();
        final double w = rect.getWidth();
        final double h = rect.getHeight();
        final AttributeList attribs = new AttributeList(); 
        if (mPlexAttribute != null) {
            attribs.setAttribute(mPlexAttribute, mPlexValue);
        } 
        attribs.setAttribute("x", String.valueOf(x));
        attribs.setAttribute("y", String.valueOf(y));
        attribs.setAttribute("width", String.valueOf(w));
        attribs.setAttribute("height", String.valueOf(h));
        writer.writeTag(tagName, attribs, true);
    } 
     
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
        if (!(o instanceof Rectangle2D)) {
            throw new ObjectFactoryException("The given object is no java.awt.geom.Rectangle2D."); 
        } 
 
        final Rectangle2D rect = (Rectangle2D) o;
        final float x = (float) rect.getX();
        final float y = (float) rect.getY();
        final float w = (float) rect.getWidth();
        final float h = (float) rect.getHeight();
 
        setParameter("x", new Float(x));
        setParameter("y", new Float(y));
        setParameter("width", new Float(w));
        setParameter("height", new Float(h));
    } 
 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCenterX, getCenterY, getMaxX, getMaxY, getMinX
    public static void fitViewToBounds(Display display, Rectangle2D bounds,
            Point2D center, long duration)
    { 
        // init variables 
        double w = display.getWidth(), h = display.getHeight();
        double cx = (center==null? bounds.getCenterX() : center.getX());
        double cy = (center==null? bounds.getCenterY() : center.getY());
         
        // compute half-widths of final bounding box around 
        // the desired center point 
        double wb = Math.max(cx-bounds.getMinX(),
                             bounds.getMaxX()-cx);
        double hb = Math.max(cy-bounds.getMinY(),
                             bounds.getMaxY()-cy);
         
        // compute scale factor 
        //  - figure out if z or y dimension takes priority 
        //  - then balance against the current scale factor 
        double scale = Math.min(w/(2*wb),h/(2*hb)) / display.getScale();
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
    /** 
     * Set the clip contents, and set the status to valid and in use. 
     * @param r the clip contents to copy 
     */ 
    public void setClip(Rectangle2D r) {
        setClip(r.getX(),r.getY(),r.getWidth(),r.getHeight());
    } 
     
    /** 
     * Set the clip contents, and set the status to valid and in use. 
     * @param x the minimum x-coordinate 
     * @param y the minimum y-coorindate 
     * @param w the clip width 
     * @param h the clip height 
     */ 
    public void setClip(double x, double y, double w, double h) {
        status = INUSE;
        clip[0] = x;
        clip[1] = y;
        clip[6] = x+w;
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
     *  
     * @param bounds 
     * @return 
     */ 
    private Envelope toEnvelope(Rectangle2D bounds) {
        return new Envelope(bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY());
    } 
 
    /** 
     * Simple structure stored into the quadtree (keeping the item around helps 
     * in debugging) 
     *  
     * @author Andrea Aime 
     *  
     */ 
    static class InterferenceItem { 
        Envelope env;
 
        LabelCacheItem item;
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
     * @return the corrected anchor point 
     */ 
    protected Point2D correct(Point2D anchor, Rectangle2D bounds) {
        if ( anchor == null ) return anchor;
        double x = anchor.getX(), y = anchor.getY();
        double x1 = bounds.getMinX(), y1 = bounds.getMinY();
        double x2 = bounds.getMaxX(), y2 = bounds.getMaxY();
        x = (x < x1 ? x1 : (x > x2 ? x2 : x));
        y = (y < y1 ? y1 : (y > y2 ? y2 : y));
         
        m_tmp.setLocation(x,y);
        return m_tmp;
    } 
     
    /** 
     * Distorts an item's x-coordinate. 
     * @param x the undistorted x coordinate 
     * @param anchor the anchor or focus point of the display 
     * @param bounds the layout bounds 
     * @return the distorted x-coordinate 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHeight, getMaxX, getMaxY, getMinX, getMinY
    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);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
 
      int[]xs;
      int[]ys;
 
      int d = 5;
      if (p.x > rect.getMinX()-5 && p.x < rect.getMaxX()+5 ||
            p.y > rect.getMinY()-5 && p.y < rect.getMaxY()+5){
 
         xs = new int[3];
         ys = new int[3];
 
 
         xs[0] = (int) p.x;
         xs[1] = (int) corners.get(0).x;
         xs[2] = (int) corners.get(1).x;
 
         ys[0] = (int) p.y;
         ys[1] = (int) corners.get(0).y;
         ys[2] = (int) corners.get(1).y;
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCenterX, getCenterY
     * @param rectangle  the rectangle (<code>null</code> not permitted). 
     *  
     * @return The anchor point (never <code>null</code>).  
     */ 
    public Point2D getAnchorPoint(Rectangle2D rectangle) {
        ParamChecks.nullNotPermitted(rectangle, "rectangle");
        Point2D result = new Point2D.Double();
        if (this == RectangleAnchor.CENTER) {
            result.setLocation(rectangle.getCenterX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.TOP) {
            result.setLocation(rectangle.getCenterX(), rectangle.getMinY());
        } else if (this == RectangleAnchor.BOTTOM) {
            result.setLocation(rectangle.getCenterX(), rectangle.getMaxY());
        } else if (this == RectangleAnchor.LEFT) {
            result.setLocation(rectangle.getMinX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.RIGHT) {
            result.setLocation(rectangle.getMaxX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.TOP_LEFT) {
            result.setLocation(rectangle.getMinX(), rectangle.getMinY());
        } else if (this == RectangleAnchor.TOP_RIGHT) {

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 RectangularShape Methods: