List of usage examples for java.awt.geom Point2D setLocation
public abstract void setLocation(double x, double y);
From source file:edu.uci.ics.jung.algorithms.layout.ISOMLayout.java
private synchronized void adjust() { //Generate random position in graph space Point2D tempXYD = new Point2D.Double(); // creates a new XY data location tempXYD.setLocation(10 + Math.random() * getSize().getWidth(), 10 + Math.random() * getSize().getHeight()); //Get closest vertex to random position V winner = elementAccessor.getVertex(this, tempXYD.getX(), tempXYD.getY()); while (true) { try {//from w w w.j a va2 s . c o m for (V v : getGraph().getVertices()) { ISOMVertexData ivd = getISOMVertexData(v); ivd.distance = 0; ivd.visited = false; } break; } catch (ConcurrentModificationException cme) { } } adjustVertex(winner, tempXYD); }
From source file:views.network.MyRadialTreeLayout.java
public Point2D transform(V v) { PolarPoint pp = polarLocations.get(v); double centerX = getSize().getWidth() / 2; double centerY = getSize().getHeight() / 2; Point2D cartesian = PolarPoint.polarToCartesian(pp); cartesian.setLocation(cartesian.getX() + centerX, cartesian.getY() + centerY); return cartesian; }
From source file:net.schweerelos.parrot.ui.NodeWrapperPersistentLayoutImpl.java
protected void initializeLocation(NodeWrapper vertex, Point2D coord, Dimension size) { String uri = vertex.getOntResource().getURI(); if (uri != null && !uri.isEmpty() && uriToNodeLocation.containsKey(uri)) { Point point = uriToNodeLocation.get(uri); coord.setLocation(point.x, point.y); } else {//from w w w. jav a 2s.c o m // TODO } }
From source file:edu.uci.ics.jung.algorithms.layout.BalloonLayout.java
@Override public void setLocation(V v, Point2D location) { Point2D c = getCenter(v);/*from w w w . j a va2s. co m*/ Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY()); PolarPoint newLocation = PolarPoint.cartesianToPolar(pv); polarLocations.get(v).setLocation(newLocation); Point2D center = getCenter(v); pv.setLocation(pv.getX() + center.getX(), pv.getY() + center.getY()); locations.put(v, pv); }
From source file:org.jcurl.core.swing.RockLocationDisplayBase.java
/** * Convert world- to display coordinates. * //from w w w . ja va 2 s . c o m * @param wc * @param dc * @return display coordinates */ public Point2D wc2dc(final Point2D wc, Point2D dc) { if (dc == null) dc = new Point2D.Float(); dc.setLocation(wc.getX() * SCALE, wc.getY() * SCALE); return wc_mat.transform(dc, dc); }
From source file:inet.CalculationNetworkEditor.visual.control.listener.BothGraphActions.java
public void relocateVertexes() { Layout<V, E> layout = visViewBoth.getGraphLayout(); Collection<V> physical = logic.getAllVertOfType(IStorage.Type.PHYSICAL); for (V phy : physical) { Collection<V> mapping = logic.getVertexStack(phy); for (V visual : visualPhysicalV.keySet()) { if (visualPhysicalV.get(visual) == phy) { mapping.add(visual);//from w w w . j a v a2s . c o m } } Point2D pAct = layout.transform(phy); for (V mapped : mapping) { if (!mapped.equals(phy)) { // all vertices of mapping but the phisical vertex pAct.setLocation(pAct.getX() + mapDistance, pAct.getY() + mapDistance); layout.setLocation(mapped, pAct); } } } //printLocationOfAllVertices(); }
From source file:org.jcurl.core.swing.RockLocationDisplayBase.java
/** * Convert display to world-coordinates. * //from w w w .j a va 2s . com * @param dc * @param wc * @return world coordinates */ public Point2D dc2wc(final Point2D dc, Point2D wc) { try { wc = wc_mat.inverseTransform(dc, wc); wc.setLocation(wc.getX() / SCALE, wc.getY() / SCALE); return wc; } catch (NoninvertibleTransformException e) { throw new RuntimeException("Why uninvertible?", e); } }
From source file:edu.uci.ics.jung.algorithms.layout.FRLayout2.java
protected void calcRepulsion(V v1) { Point2D fvd1 = frVertexData.get(v1); if (fvd1 == null) return;//from w w w . ja v a 2s. c o m fvd1.setLocation(0, 0); boolean v1_locked = isLocked(v1); try { for (V v2 : getGraph().getVertices()) { boolean v2_locked = isLocked(v2); if (v1_locked && v2_locked) continue; if (v1 != v2) { Point2D p1 = transform(v1); Point2D p2 = transform(v2); if (p1 == null || p2 == null) continue; double xDelta = p1.getX() - p2.getX(); double yDelta = p1.getY() - p2.getY(); double deltaLength = Math.max(EPSILON, p1.distanceSq(p2)); double force = (repulsion_constant * repulsion_constant);// / deltaLength; double forceOverDeltaLength = force / deltaLength; assert Double.isNaN( force) == false : "Unexpected mathematical result in FRLayout:calcPositions [repulsion]"; if (v2_locked) { // double the offset for v1, as v2 will not be moving in // the opposite direction fvd1.setLocation(fvd1.getX() + 2 * xDelta * forceOverDeltaLength, fvd1.getY() + 2 * yDelta * forceOverDeltaLength); } else { fvd1.setLocation(fvd1.getX() + xDelta * forceOverDeltaLength, fvd1.getY() + yDelta * forceOverDeltaLength); } } } } catch (ConcurrentModificationException cme) { calcRepulsion(v1); } }
From source file:org.apache.fop.render.java2d.Java2DPainter.java
/** {@inheritDoc} */ public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text) throws IFException { g2dState.updateColor(state.getTextColor()); FontTriplet triplet = new FontTriplet(state.getFontFamily(), state.getFontStyle(), state.getFontWeight()); //TODO Ignored: state.getFontVariant() //TODO Opportunity for font caching if font state is more heavily used Font font = getFontInfo().getFontInstance(triplet, state.getFontSize()); //String fontName = font.getFontName(); //float fontSize = state.getFontSize() / 1000f; g2dState.updateFont(font.getFontName(), state.getFontSize() * 1000); Graphics2D g2d = this.g2dState.getGraph(); GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), text); Point2D cursor = new Point2D.Float(0, 0); int l = text.length(); int dxl = (dx != null ? dx.length : 0); if (dx != null && dxl > 0 && dx[0] != 0) { cursor.setLocation(cursor.getX() - (dx[0] / 10f), cursor.getY()); gv.setGlyphPosition(0, cursor);//from w w w . j av a 2s . c o m } for (int i = 0; i < l; i++) { char orgChar = text.charAt(i); float glyphAdjust = 0; int cw = font.getCharWidth(orgChar); if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) { glyphAdjust += wordSpacing; } glyphAdjust += letterSpacing; if (dx != null && i < dxl - 1) { glyphAdjust += dx[i + 1]; } cursor.setLocation(cursor.getX() + cw + glyphAdjust, cursor.getY()); gv.setGlyphPosition(i + 1, cursor); } g2d.drawGlyphVector(gv, x, y); }
From source file:com.mycompany.complexity.tool.mvn.TreeLayout.java
public void moveNodes(int x, int y) { Point2D p; for (V value : locations.keySet()) { p = locations.get(value);//from ww w.j av a2 s .c o m p.setLocation(p.getX() + x, p.getY() + y); locations.get(value).setLocation(p); } }