private Shape buildFrame(RectangularShape shape, int index) { float x = -.5f; float y = -.5f; float diam = 1.f; diam += diam * index/2; x += x * index/2; y += y * index/2; shape.setFrame(x, y, diam, diam); return shape; }
private static Shape buildFrame(RectangularShape shape, int index) { float x = -.5f; float y = -.5f; float diam = 1.f; diam += diam * index / 2; x += x * index / 2; y += y * index / 2; shape.setFrame(x, y, diam, diam); return shape; }
rect.setFrame(transform(transform, frame, frame)); return rect;
/** * Set values from the passed component. * @param component the component used for rendering */ private void setComponent(Component component) { Dimension d = component.getSize(); if(d.width <= 0 || d.height <= 0) { d = component.getPreferredSize(); } float ewidth = d.width/1.5f; float eheight = d.height/1.5f; lensShape.setFrame(d.width/2-ewidth/2, d.height/2-eheight/2, ewidth, eheight); }
/** @param d the size used for the lens */ public void setSize(Dimension d) { Preconditions.checkNotNull(d); Preconditions.checkArgument(d.width > 0, "width must be > 0"); Preconditions.checkArgument(d.height > 0, "height must be > 0"); float width = d.width / 1.5f; float height = d.height / 1.5f; lensShape.setFrame((d.width - width) / 2, (d.height - height) / 2, width, height); }
public void updateGeometry(Attribute shapeAttribute) { RectangularShape shape = (RectangularShape)shapeAttribute.get(userVertex); if (shape != null) shape.setFrame(centerX - width / 2, centerY - height / 2, width, height); }
@Override public void setSize(int width, int height) { shape.setFrame(borderOffset, borderOffset, width - (double) borderOffset, height - (double) borderOffset); super.setSize(width + borderOffset, height + borderOffset); }
double setupVertexShape(double levelY) { if (vertex == null) return levelY; RectangularShape shape = getVertexShape(vertex); double height = shape.getHeight(); shape.setFrame(centerX - width / 2, levelY, width, height); return (levelY + height); } }
public void setViewCenter(Point2D viewCenter) { double width = lensShape.getWidth(); double height = lensShape.getHeight(); lensShape.setFrame(viewCenter.getX()-width/2, viewCenter.getY()-height/2, width, height); }
public void setCenter(Point2D viewCenter) { double width = lensShape.getWidth(); double height = lensShape.getHeight(); lensShape.setFrame( viewCenter.getX() - width / 2, viewCenter.getY() - height / 2, width, height); }
GradientXYBarPainter xyBarpainter = new GradientXYBarPainter() { @Override public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Rectangle2D rect = bar.getFrame(); rect.setRect(rect.getX(), rect.getY(), rect.getWidth() * widthMultiplier, rect.getHeight()); bar.setFrame(rect); super.paintBar(g2, renderer, row, column, bar, base); } }; StackedXYBarRenderer rend = new StackedXYBarRenderer(); rend.setBarPainter(xyBarpainter);
rv.setFrame(x, y, w, h);
public void setRadius(double viewRadius) { double x = lensShape.getCenterX(); double y = lensShape.getCenterY(); double viewRatio = getRatio(); lensShape.setFrame( x - viewRadius / viewRatio, y - viewRadius, 2 * viewRadius / viewRatio, 2 * viewRadius); }
public void setViewRadius(double viewRadius) { double x = lensShape.getCenterX(); double y = lensShape.getCenterY(); double viewRatio = getRatio(); lensShape.setFrame(x-viewRadius/viewRatio, y-viewRadius, 2*viewRadius/viewRatio, 2*viewRadius); }
mouseSelectedArea.setFrame(ox, oy, 0, 0);
/** * Resizes a rectangle. This works for real rectangles and produces funny results for RoundRects etc .. * * @param rectangularShape * the rectangle * @param width * the new width of the rectangle * @param height * the new height of the rectangle. * @return the resized rectangle. */ public static Shape resizeRect( final RectangularShape rectangularShape, final double width, final double height ) { final RectangularShape retval = (RectangularShape) rectangularShape.clone(); retval.setFrame( retval.getX(), retval.getY(), width, height ); return retval; }
/** * Moves this rectangle by a given x- and y-offset * @param r the rectangle to move * @param dx the x-offset * @param dy the y-offset */ public static void translate(RectangularShape r, double dx, double dy) { r.setFrame(r.getX() + dx, r.getY() + dy, r.getWidth(), r.getHeight()); }
/** * Translates a se. Special care is taken to preserve the shape's original class, if the shape is a rectangle or a * line. * * @param s * the shape * @param x * the x coordinate where the shape is translated to * @param y * the y coordinate where the shape is translated to * @return the translated shape */ public static Shape translateShape( final Shape s, final double x, final double y ) { if ( s instanceof RectangularShape ) { final RectangularShape rect = (RectangularShape) s; final RectangularShape retval = (RectangularShape) rect.clone(); retval.setFrame( retval.getX() + x, retval.getY() + y, retval.getWidth(), retval.getHeight() ); return retval; } if ( s instanceof Line2D ) { final Line2D line = (Line2D) s; final Line2D retval = (Line2D) line.clone(); retval.setLine( retval.getX1() + x, retval.getY1() + y, retval.getX2() + x, retval.getY2() + y ); return retval; } final AffineTransform af = AffineTransform.getTranslateInstance( x, y ); return af.createTransformedShape( s ); }
/** * Calculates the BoundsOffsets used for setBounds() method * * Implemented because the canvas has no layout manager * */ public void updateBounds() { int newHeight = noteText.getPreferredSize().height; if (noteText.getHeight() < newHeight && newHeight >= noteText.getMinimumSize().height) { noteText.setSize(noteText.getWidth(), newHeight); } int rectWidth = noteText.getWidth() + GUIConstants.RESERVED_BORDER; int rectHeight = noteText.getHeight() + GUIConstants.RESERVED_BORDER; noteRect.setFrame(GUIConstants.RESERVED_BORDER / 2, GUIConstants.RESERVED_BORDER / 2, rectWidth, rectHeight); setSize(rectWidth + GUIConstants.ANNOTATION_SIZE_OFFSET, rectHeight + GUIConstants.ANNOTATION_SIZE_OFFSET); noteText.setLocation((int) noteRect.getX() + (rectWidth - noteText.getWidth()) / 2, (int) noteRect.getY() + (rectHeight - noteText.getHeight()) / 2); bounds.setBounds(model.getX() - 20, model.getY() - 20, rectWidth + GUIConstants.RESERVED_BORDER + GUIConstants.ANNOTATION_SIZE_OFFSET + 20, rectHeight + GUIConstants.RESERVED_BORDER + GUIConstants.ANNOTATION_SIZE_OFFSET + 20); setBounds(bounds); }