private void avoid(Point2D.Double move, Positionable pos, Shape sh) { final Oscillator oscillator = new Oscillator(); final Point2D.Double orig = new Point2D.Double(move.x, move.y); while (cut(pos, sh)) { final Point2D.Double m = oscillator.nextPosition(); move.setLocation(orig.x + m.x, orig.y + m.y); } }
/** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param angle the angle. */ public void draw(Graphics2D g2, Rectangle2D plotArea, double angle) { Point2D.Double pt = new Point2D.Double(); pt.setLocation(plotArea.getMinX() + this.rotateX * plotArea.getWidth(), plotArea.getMinY() + this.rotateY * plotArea.getHeight()); draw(g2, plotArea, pt, angle); }
@Override public Integer moveAndResizeOnDrawing(Integer handlePointIndex, Double deltaX, Double deltaY, MouseEventDouble mouseEvent) { if (Objects.equals(handlePointIndex, UNDEFINED)) { pts.stream().filter(Objects::nonNull).forEach(p -> p.setLocation(p.getX() + deltaX, p.getY() + deltaY)); } else if (handlePointIndex >= 0 && handlePointIndex < pts.size()) { Point2D point = pts.get(handlePointIndex); Optional.ofNullable(point).ifPresent(p -> p.setLocation(mouseEvent.getImageCoordinates())); } return handlePointIndex; } }
/** * Gets a object relative location for a given location and an object. * * @param xLoc the X location relative to the local area. * @param yLoc the Y location relative to the local area. * @param boundedObject the local bounded object. * @return Point containing the X and Y locations relative to the object. */ public static Point2D.Double getObjectRelativeLocation(double xLoc, double yLoc, LocalBoundedObject boundedObject) { Point2D.Double result = new Point2D.Double(); double translateX = xLoc - boundedObject.getXLocation(); double translateY = yLoc - boundedObject.getYLocation(); double radianRotation = (Math.PI * 2D) - Math.toRadians(boundedObject.getFacing()); double rotateX = (translateX * Math.cos(radianRotation)) - (translateY * Math.sin(radianRotation)); double rotateY = (translateX * Math.sin(radianRotation)) + (translateY * Math.cos(radianRotation)); result.setLocation(rotateX, rotateY); return result; }
/** * Sets this coordinate to the specified point. If the specified position is also a * {@code DirectPosition} containing a non-null coordinate reference system (CRS), * then the CRS for this position will be set to the CRS of the given point. * * @param position the new position for this point. */ @Override public void setLocation(final Point2D position) { super.setLocation(position); if (position instanceof DirectPosition) { final CoordinateReferenceSystem candidate = ((DirectPosition) position).getCoordinateReferenceSystem(); if (candidate != null) { setCoordinateReferenceSystem(candidate); } } }
/** * Sets this coordinate to the specified point. If the specified position is also a * {@code DirectPosition} containing a non-null coordinate reference system (CRS), * then the CRS for this position will be set to the CRS of the given point. * * @param position the new position for this point. */ @Override public void setLocation(final Point2D position) { super.setLocation(position); if (position instanceof DirectPosition) { final CoordinateReferenceSystem candidate = ((DirectPosition) position).getCoordinateReferenceSystem(); if (candidate != null) { setCoordinateReferenceSystem(candidate); } } }
/** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param angle the angle. */ public void draw(Graphics2D g2, Rectangle2D plotArea, double angle) { Point2D.Double pt = new Point2D.Double(); pt.setLocation( plotArea.getMinX() + this.rotateX * plotArea.getWidth(), plotArea.getMinY() + this.rotateY * plotArea.getHeight() ); draw(g2, plotArea, pt, angle); }
public void setImageCoordinates(Point2D point) { point2d.setLocation(point); }
public void setImageCoordinates(double x, double y) { point2d.setLocation(x, y); }
public void setBounds(Rectangle2D bounds) { if (tempLocation != null) tempLocation.setLocation(bounds.getX(), bounds.getY()); }
public void translate(Point2D.Double offset) { if (offset == null) { return; } start.setLocation(start.x + offset.x, start.y + offset.y); end.setLocation(end.x + offset.x, end.y + offset.y); this.bounds = null; }
private Vector<Point2D.Double> pairs(String x, String y) { Point2D.Double pt; Vector<Point2D.Double> cleanedVals = new Vector<>(); List<Double> _x = getConditionedDataContinuous(x); List<Double> _y = getConditionedDataContinuous(y); for (int row = 0; row < _x.size(); row++) { pt = new Point2D.Double(); pt.setLocation(_x.get(row), _y.get(row)); cleanedVals.add(pt); } return cleanedVals; }
public void moveTo(Point2D.Double pos) { if (pos == null) { return; } double xDiff = end.x - start.x; double yDiff = end.y - start.y; start.setLocation(pos.x, pos.y); start.setLocation(pos.x + xDiff, pos.y + yDiff); this.bounds = null; }
public void translate(Point2D.Double offset) { if (offset == null) { return; } start.setLocation(start.x + offset.x, start.y + offset.y); end.setLocation(end.x + offset.x, end.y + offset.y); this.bounds = null; }
private Point2D.Double createPoint(QuantityValue timeseriesValue) { Long timestamp = timeseriesValue.getTimestamp(); BigDecimal value = timeseriesValue.getValue(); Point2D.Double p = new Point2D.Double(); p.setLocation(timestamp, value.doubleValue()); return p; }
public void moveTo(Point2D.Double pos) { if (pos == null) { return; } double xDiff = end.x - start.x; double yDiff = end.y - start.y; start.setLocation(pos.x, pos.y); start.setLocation(pos.x + xDiff, pos.y + yDiff); this.bounds = null; }
public static void applyCoG(Point2D.Double[] points, Point2D.Double cog) { for (int i = 0; i < points.length; i++) { points[i].setLocation(points[i].x - cog.x, points[i].y - cog.y); } }
private void avoid(Point2D.Double move, Positionable pos, Shape sh) { final Oscillator oscillator = new Oscillator(); final Point2D.Double orig = new Point2D.Double(move.x, move.y); while (cut(pos, sh)) { final Point2D.Double m = oscillator.nextPosition(); move.setLocation(orig.x + m.x, orig.y + m.y); } }
Point2D.Double p1, p2; //p1 and p2 inits // you don't use abs value and use the still point as the first one of the subtraction double deltaX = p2.getX() - p1.getX(); double deltaY = p2.getY() - p1.getY(); // now you know how much far they are double coeff = 0.5; //this coefficient can be tweaked to decice how much near the two points will be after the update.. 0.5 = 50% of the previous distance p1.setLocation(p1.getX() + coeff*deltaX, p1.getY() + coeff*deltaY);
private Point2D.Double createPoint(TimeseriesValue timeseriesValue) { Long timestamp = timeseriesValue.getTimestamp(); double value = timeseriesValue.getValue(); Point2D.Double p = new Point2D.Double(); p.setLocation(timestamp, value); return p; }