List of usage examples for java.awt.geom Point2D.Float Point2D.Float
public Float(float x, float y)
From source file:Main.java
/** * Creates a nifty looking inner shadow for the window. * @param width The width of the shadow. * @param height The height of the shadow. * @return The translucent shadow that was created. *//*from ww w . j a v a2 s . c om*/ public static BufferedImage genInnerShadow(int width, int height) { BufferedImage shadowOuter = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics g = shadowOuter.getGraphics(); Graphics2D g2 = (Graphics2D) g; Point2D center = new Point2D.Float(width / 2, height / 2); float radius = width; Point2D focus = new Point2D.Float(width / 2, height / 2); float[] dist = { 0.0f, 1.0f }; Color[] colors = { new Color(0, 0, 0, 0), new Color(0, 0, 0, 220) }; RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE); g2.setPaint(p); g2.fillRect(0, 0, width, height); return shadowOuter; }
From source file:tufts.vue.LWComponent.java
/** Special setLocation to permit event notification during coordinate system changes for objects not yet added to the map */ protected void setLocation(float x, float y, LWComponent hearableEventSource, boolean issueMapLocationChangeCalls) { if (this.x == x && this.y == y) return;/*from w w w . j av a 2s . co m*/ final Point2D.Float oldValue = new Point2D.Float(this.x, this.y); takeLocation(x, y); //if (!linkNotificationDisabled) // updateConnectedLinks(); if (hearableEventSource != this) hearableEventSource.notifyProxy(new LWCEvent(hearableEventSource, this, LWKey.Location, oldValue)); else //if (hearableEventSource != null) // if null, skip event delivery notify(LWKey.Location, oldValue); // if (issueMapLocationChangeCalls && parent != null) { if (issueMapLocationChangeCalls) { // NEED TO DEAL WITH COORDINATE SYSTEM CHANGES // And need to be able to capture old map location from our OLD parent // during reparenting.... // reparenting may want to force a location in the new parent, at it's // current map location, but relative to the new parent's location, // even if it's about to be moved/laid-out elsewhere, so that once // we get here, the below code should always work. Or, we could // even have establishLocalCoordinates call us here with extra info... (oldMapX/oldMapY) // or, we could implement the general setMapLocation and have establishLocalCoords call that... // This code only works if we're moving within a single parent: no coordinate system changes! // Would be better to merge this somehow with notifyHierarchChanged? final double scale; if (parent != null) scale = parent.getMapScale(); // we move within the scale of our parent else scale = 1.0; if (DEBUG.LAYOUT) out("notifyMapLocationChanged: using scale " + scale); notifyMapLocationChanged(this, (x - oldValue.x) * scale, (y - oldValue.y) * scale); } else { // this always needs to happen no matter what, even during undo // (e.g., the shape of curves isn't stored anywhere -- always needs to be recomputed) //if (!linkNotificationDisabled) if (updatingLinks()) updateConnectedLinks(this); } }
From source file:tufts.vue.LWComponent.java
public Point2D getLocation() { return new Point2D.Float(getX(), getY()); }
From source file:tufts.vue.LWComponent.java
/** @return the center of this node in map coordinates */ public Point2D getMapCenter() { return new Point2D.Float(getMapCenterX(), getMapCenterY()); }
From source file:tufts.vue.LWComponent.java
/** @return the local lower right hand corner of the component: for rectangular shapes, this is just [width,height] * Non-rectangular shapes can override to do something fancier. */ protected Point2D getZeroSouthEastCorner() { return new Point2D.Float(getWidth(), getHeight()); }
From source file:tufts.vue.LWComponent.java
private Point2D.Float getSlideIconStackLocation() { final Point2D corner = getZeroSouthEastCorner(); float xoff = (float) corner.getX() - 60; float yoff = (float) corner.getY() - 60; // If shape is small, try and keep it from overlapping too much (esp the label) if (xoff < getWidth() / 2f) xoff = getWidth() / 2f;//from ww w .j a v a 2 s.c o m if (yoff < getHeight() * 0.75f) yoff = getHeight() * 0.75f; // todo: can reuse getZeroCorner point2D instead of creating anew... return new Point2D.Float(xoff, yoff); }
From source file:tufts.vue.LWComponent.java
private void drawDebugInfo(DrawContext dc, AffineTransform zeroTransform) { if (this instanceof LWLink) return;/*from w w w . j a v a 2 s .c o m*/ dc.g.setTransform(zeroTransform); dc.setAbsoluteStroke(1); //dc.g.setColor(Color.blue); //dc.g.draw(debugZeroRect); // scaling testing -- draw an exactly 8x8 pixel (rendered) box dc.g.setColor(Color.green); dc.g.drawRect(0, 0, 7, 7); // show the center-point to corner intersect line (debug slide icon placement): dc.g.setColor(Color.red); //dc.setAbsoluteStroke(1); dc.g.setStroke(STROKE_ONE); dc.g.draw(new Line2D.Float(new Point2D.Float(getWidth() / 2, getHeight() / 2), getZeroSouthEastCorner())); if (DEBUG.LINK && isSelected() && getLinks().size() > 0) { final Rectangle2D.Float pureFan = getFanBounds(); final Rectangle2D.Float fan = getCenteredFanBounds(); final float cx = getMapCenterX(); final float cy = getMapCenterY(); final Line2D xaxis = new Line2D.Float(fan.x, cy, fan.x + fan.width, cy); final Line2D yaxis = new Line2D.Float(cx, fan.y, cx, fan.y + fan.height); dc.setMapDrawing(); dc.setAbsoluteStroke(4); //dc.g.setColor(getRenderFillColor(dc)); dc.g.setColor(Color.blue); dc.g.draw(pureFan); dc.setAbsoluteStroke(2); dc.g.setColor(Color.red); dc.g.draw(fan); dc.g.draw(xaxis); dc.g.draw(yaxis); } }