final private void drawLine( final double x1, final double y1, final double x2, final double y2, final Graphics2D g ) { if ( ( x1 == x2 ) && ( y1 == y2 ) ) { return; } _line.setLine( x1, y1, x2, y2 ); g.draw( _line ); }
Line2D line = new Line2D.Double(); Graphics2D g2 = aPaintContext.getGraphics(); for (double x = bx; x < rightBorder; x += 5) { line.setLine(x, by, x, bottomBorder); g2.draw(line);
/** * Modify vector stopping point. * * @param pt new stopping point */ public void extendTo (Point pt) { line.setLine(line.getP1(), pt); }
Line2D a = new Line2D.Double(); Line2D b = new Line2D.Double(); Line2D c = new Line2D.Double(); a.setLine(x1, y1, x2, y2); b.setLine(x2, y2, x3, y3); c.setLine(x3, y3, x1, y1); double pntX = s.nextDouble(); double pntY = s.nextDouble(); if (a.ptLineDist(pntX, pntY) == 0 || b.ptLineDist(pntX, pntY) == 0 || c.ptLineDist(pntX, pntY) == 0) c++;
/** * Checks if one of the lines in the polyline intersects * with a given rectangle. * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D) */ public boolean intersects(Rectangle2D r) { if(np==0)return false; Line2D line = new Line2D.Double(x[0],y[0],x[0],y[0]); for (int i = 1; i < np; i++) { line.setLine(x[i-1], y[i-1], x[i], y[i]); if(line.intersects(r))return true; } return false; }
/** * Checks if one of the lines in the polyline intersects * with a given rectangle. * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D) */ public boolean intersects(Rectangle2D r) { if(np==0)return false; Line2D line = new Line2D.Double(x[0],y[0],x[0],y[0]); for (int i = 1; i < np; i++) { line.setLine(x[i-1], y[i-1], x[i], y[i]); if(line.intersects(r))return true; } return false; }
/** * Checks if one of the lines in the polyline intersects * with a given rectangle. * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D) */ public boolean intersects(Rectangle2D r) { if(np==0)return false; Line2D line = new Line2D.Double(x[0],y[0],x[0],y[0]); for (int i = 1; i < np; i++) { line.setLine(x[i-1], y[i-1], x[i], y[i]); if(line.intersects(r))return true; } return false; }
private void mapEdge(IQuadEdge e, AffineTransform af, Point2D p0, Point2D p1, Line2D l2d) { p0.setLocation(e.getA().x, e.getA().y); p1.setLocation(e.getB().x, e.getB().y); af.transform(p0, p0); af.transform(p1, p1); l2d.setLine(p0, p1); }
/** * @see Graphics#drawPolyline(int[], int[], int) */ @Override public void drawPolyline( final int[] x, final int[] y, final int nPoints ) { final Line2D line = new Line2D.Double( x[0], y[0], x[0], y[0] ); for ( int i = 1; i < nPoints; i++ ) { line.setLine( line.getX2(), line.getY2(), x[i], y[i] ); draw( line ); } }
@Override protected void renderElement(StyleGroup group, Graphics2D g, Camera camera, GraphicElement element) { GraphicEdge edge = (GraphicEdge) element; GraphicNode node0 = (GraphicNode) edge.getNode0(); GraphicNode node1 = (GraphicNode) edge.getNode1(); shape.setLine(node0.x, node0.y, node1.x, node1.y); g.draw(shape); renderArrow(group, g, camera, edge); renderText(group, g, camera, element); }
/** Check the bounds of given line with the bounds of this pane. Optionally * calculate the new bounds in current pane's boundary. * @param line a line for check * @return a line with bounds inside the pane's boundary */ private Line2D checkLineBounds (Line2D line) { Rectangle bounds = getBounds(); double startPointX, startPointY, endPointX, endPointY; // check start point startPointX = Math.max (line.getX1 (), bounds.x+MIN_X); startPointY = Math.max (line.getY1 (), bounds.y+MIN_Y); // check end point endPointX = Math.min (line.getX2 (), (bounds.x+bounds.width)-MIN_WIDTH); endPointY = Math.min (line.getY2 (), (bounds.y+bounds.height)-MIN_HEIGTH); // set new bounds line.setLine(startPointX, startPointY, endPointX, endPointY); return line; }
@Override protected void renderElement(StyleGroup group, Graphics2D g, Camera camera, GraphicElement element) { GraphicEdge edge = (GraphicEdge) element; GraphicNode node0 = (GraphicNode) edge.getNode0(); GraphicNode node1 = (GraphicNode) edge.getNode1(); shape.setLine(node0.x, node0.y, node1.x, node1.y); g.draw(shape); renderArrow(group, g, camera, edge); renderText(group, g, camera, element); }
protected PSemanticPath newGridLine(Line2D line) { if (line.equals(last_line)) return null; last_line.setLine(line); PSemanticPath gridline = new PSemanticPath(line); gridline.setMinimumScreenStrokeWidth(1); gridline.setStroke(GraphicsConstants.instance.gridStroke()); gridline.setStrokePaint(GraphicsConstants.instance.gridColor()); gridline.setSmallStrokePaint(GraphicsConstants.GRID_COLOR_SMALL, 0.4f); return gridline; }
/** * Creates an object based on this description. * * @return The object. */ public Object createObject() { final Line2D line = new Line2D.Float(); final float x1 = getFloatParameter("x1"); final float x2 = getFloatParameter("x2"); final float y1 = getFloatParameter("y1"); final float y2 = getFloatParameter("y2"); line.setLine(x1, y1, x2, y2); return line; }
/** * Creates an object based on this description. * * @return The object. */ public Object createObject() { final Line2D line = new Line2D.Float(); final float x1 = getFloatParameter( "x1" ); final float x2 = getFloatParameter( "x2" ); final float y1 = getFloatParameter( "y1" ); final float y2 = getFloatParameter( "y2" ); line.setLine( x1, y1, x2, y2 ); return line; }
/** * Scale provided line * * @param line the line to be scaled */ public void scale (Line2D line) { line.setLine( scaled(line.getX1()), scaled(line.getY1()), scaled(line.getX2()), scaled(line.getY2())); }
/** Converts line's bounds by the bounds of the root pane. Drop glass pane * is over this root pane. After covert a given line is set to drop glass pane. * @param line line for show in drop glass pane */ private void convertBoundsAndSetDropLine (final Line2D line) { int x1 = (int)line.getX1 (), x2 = (int)line.getX2 (); int y1 = (int)line.getY1 (), y2 = (int)line.getY2 (); Point p1 = SwingUtilities.convertPoint (tree, x1, y1, tree.getRootPane ()); Point p2 = SwingUtilities.convertPoint (tree, x2, y2, tree.getRootPane ()); line.setLine (p1, p2); dropPane.setDropLine (line); }
/** Converts line's bounds by the bounds of the root pane. Drop glass pane * is over this root pane. After covert a given line is set to drop glass pane. * @param line line for show in drop glass pane */ private void convertBoundsAndSetDropLine(final Line2D line) { int x1 = (int) line.getX1(); int x2 = (int) line.getX2(); int y1 = (int) line.getY1(); int y2 = (int) line.getY2(); Point p1 = SwingUtilities.convertPoint(tree, x1, y1, tree.getRootPane()); Point p2 = SwingUtilities.convertPoint(tree, x2, y2, tree.getRootPane()); line.setLine(p1, p2); dropPane.setDropLine(line); }
/** Converts line's bounds by the bounds of the root pane. Drop glass pane * is over this root pane. After covert a given line is set to drop glass pane. * @param line line for show in drop glass pane */ private void convertBoundsAndSetDropLine (final Line2D line) { int x1 = (int)line.getX1 (), x2 = (int)line.getX2 (); int y1 = (int)line.getY1 (), y2 = (int)line.getY2 (); Point p1 = SwingUtilities.convertPoint (tree, x1, y1, tree.getRootPane ()); Point p2 = SwingUtilities.convertPoint (tree, x2, y2, tree.getRootPane ()); line.setLine (p1, p2); dropPane.setDropLine (line); }
/** Converts line's bounds by the bounds of the root pane. Drop glass pane * is over this root pane. After covert a given line is set to drop glass pane. * @param line line for show in drop glass pane */ private void convertBoundsAndSetDropLine(final Line2D line) { int x1 = (int) line.getX1(); int x2 = (int) line.getX2(); int y1 = (int) line.getY1(); int y2 = (int) line.getY2(); Point p1 = SwingUtilities.convertPoint(table, x1, y1, table.getRootPane()); Point p2 = SwingUtilities.convertPoint(table, x2, y2, table.getRootPane()); line.setLine(p1, p2); dropPane.setDropLine(line); }