List of usage examples for java.awt.geom Point2D getX
public abstract double getX();
From source file:net.sf.mzmine.chartbasics.gestures.ChartGestureHandler.java
/** * Create preset handlers// w ww. j av a2s .c om * * @param handler * @param g * @param param Parameters for specific handlers <br> * @return */ public static ChartGestureHandler createHandler(Handler handler, final ChartGesture g, Object[] param) { Consumer<ChartGestureEvent> newHandler = null; switch (handler) { case DEBUG: newHandler = e -> System.out.println(e.toString()); break; case PREVIOUS_ZOOM_HISTORY: newHandler = e -> { ZoomHistory h = e.getChartWrapper().getZoomHistory(); if (h != null) { Range[] range = h.setPreviousPoint(); if (range != null && range.length > 0 && range[0] != null) { ValueAxis dom = e.getChart().getXYPlot().getDomainAxis(); ValueAxis ran = e.getChart().getXYPlot().getRangeAxis(); ChartLogics.setZoomAxis(dom, range[0]); ChartLogics.setZoomAxis(ran, range[1]); } } }; break; case NEXT_ZOOM_HISTORY: newHandler = e -> { ZoomHistory h = e.getChartWrapper().getZoomHistory(); if (h != null) { Range[] range = h.setNextPoint(); if (range != null && range.length > 0 && range[0] != null) { ValueAxis dom = e.getChart().getXYPlot().getDomainAxis(); ValueAxis ran = e.getChart().getXYPlot().getRangeAxis(); ChartLogics.setZoomAxis(dom, range[0]); ChartLogics.setZoomAxis(ran, range[1]); } } }; break; case TITLE_REMOVER: newHandler = e -> { if (e.getEntity() instanceof TitleEntity) { TitleEntity te = (TitleEntity) e.getEntity(); te.getTitle().setVisible(false); } }; break; case AUTO_ZOOM_AXIS: newHandler = e -> { ValueAxis a = e.getAxis(); if (a != null) ChartLogics.autoAxis(a); }; break; case AUTO_ZOOM_OPPOSITE_AXIS: newHandler = e -> { if (e.getGesture().getEntity().equals(Entity.AXIS)) { e.getChartWrapper().autoRangeAxis(); e.getChartWrapper().autoDomainAxis(); } else if (e.getGesture().getEntity().equals(Entity.DOMAIN_AXIS)) e.getChartWrapper().autoRangeAxis(); else e.getChartWrapper().autoDomainAxis(); }; break; case SCROLL_AXIS: newHandler = e -> { ValueAxis axis = e.getAxis(); if (axis != null) { double diff = 0.03; if (e.getMouseEvent().isMouseWheelEvent()) { diff = -0.10 * e.getMouseEvent().getWheelRotation(); } ChartLogics.offsetAxis(axis, diff); } }; break; case SCROLL_AXIS_AND_AUTO_ZOOM: newHandler = e -> { ValueAxis axis = e.getAxis(); if (axis != null) { double diff = 0.03; if (e.getMouseEvent().isMouseWheelEvent()) { diff = -0.10 * e.getMouseEvent().getWheelRotation(); } ChartLogics.offsetAxis(axis, diff); if (e.getGesture().getEntity().equals(Entity.DOMAIN_AXIS)) e.getChartWrapper().autoRangeAxis(); else e.getChartWrapper().autoDomainAxis(); } }; break; case ZOOM_AXIS_INCLUDE_ZERO: newHandler = e -> { ValueAxis axis = e.getAxis(); if (axis != null) { double diff = 0.05; if (e.getMouseEvent().isMouseWheelEvent()) { diff = -0.10 * e.getMouseEvent().getWheelRotation(); } ChartLogics.zoomAxis(axis, diff, true); } }; break; case ZOOM_AXIS_CENTER: newHandler = e -> { ValueAxis axis = e.getAxis(); if (axis != null) { MouseEventWrapper p = e.getMouseEvent(); double diff = 0.05; if (e.getMouseEvent().isMouseWheelEvent()) { diff = -0.10 * p.getWheelRotation(); } // get data space coordinates Point2D point = e.getCoordinates(p.getX(), p.getY()); if (point != null) { // vertical ? Boolean orient = e.isVerticalAxis(axis); if (orient == null) return; else if (orient) ChartLogics.zoomAxis(axis, diff, point.getY()); else ChartLogics.zoomAxis(axis, diff, point.getX()); } } }; break; default: break; } if (newHandler == null) return null; else return new ChartGestureHandler(g, newHandler); }
From source file:org.jcurl.core.ui.RockMemento.java
protected RockMemento(final Rock<R> context, final int idx16, final Point2D p) { this(null, idx16, p.getX(), p.getY()); }
From source file:org.jcurl.core.ui.RockMemento.java
protected RockMemento(final RockSet<R> context, final int idx16, final Point2D p) { this(context, idx16, p.getX(), p.getY()); }
From source file:RotatedText.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "111111111111111111111111111111"; Font font = new Font("Courier", Font.PLAIN, 12); g2d.translate(20, 20);//from w ww .j a va 2 s . c om FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector gv = font.createGlyphVector(frc, s); int length = gv.getNumGlyphs(); for (int i = 0; i < length; i++) { Point2D p = gv.getGlyphPosition(i); AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); at.rotate((double) i / (double) (length - 1) * Math.PI / 3); Shape glyph = gv.getGlyphOutline(i); Shape transformedGlyph = at.createTransformedShape(glyph); g2d.fill(transformedGlyph); } }
From source file:GeometryUtilities.java
public static Vector<Point2D> getCrossings(Arc2D arc0, Point2D arc0Center, Arc2D arc1, Point2D arc1Center) { Vector<Point2D> ret = new Vector<Point2D>(); double distance = arc0Center.distance(arc1Center); double radius0Squared = arc0Center.distanceSq(arc0.getStartPoint()); double radius0 = sqrt(radius0Squared); double radius1Squared = arc1Center.distanceSq(arc1.getStartPoint()); double radius1 = sqrt(radius1Squared); if (distance > radius0 + radius1) { // There are no solutions because the circles are separate. } else if (distance < abs(radius0 - radius1)) { // There are no solutions because one circle is contained within the // other. } else if (distance == 0 && radius0 == radius1) { // There are an infinite number of solutions because the circles are // coincident. } else {/*from ww w . j a v a 2 s . c om*/ // Calculate the first intersection double x0 = arc0Center.getX(), y0 = arc0Center.getY(); double x1 = arc1Center.getX(), y1 = arc1Center.getY(); double a = (radius0Squared - radius1Squared + distance * distance) / (2 * distance); double h = sqrt(radius0Squared - a * a); double x2 = x0 + a * (x1 - x0) / distance; double y2 = y0 + a * (y1 - y0) / distance; Point2D.Double intersection = new Point2D.Double(x2 + h * (y1 - y0) / distance, y2 - h * (x1 - x0) / distance); double angle0ToIntersection = toDegrees(atan2(-(intersection.y - y0), intersection.x - x0)); double angle1ToIntersection = toDegrees(atan2(-(intersection.y - y1), intersection.x - x1)); if (arc0.containsAngle(angle0ToIntersection) && arc1.containsAngle(angle1ToIntersection)) ret.add(intersection); // If the circles aren't tangential, calculate the second // intersection if (distance != radius0 + radius1) { intersection = new Point2D.Double(x2 - h * (y1 - y0) / distance, y2 + h * (x1 - x0) / distance); angle0ToIntersection = toDegrees(atan2(-(intersection.y - y0), intersection.x - x0)); angle1ToIntersection = toDegrees(atan2(-(intersection.y - y1), intersection.x - x1)); if (arc0.containsAngle(angle0ToIntersection) && arc1.containsAngle(angle1ToIntersection)) ret.add(intersection); } } return ret; }
From source file:vnreal.gui.control.MyGraphLayout.java
@Override public void setLocation(V v, Point2D p) { // Update own storage. v.setCoordinateX(p.getX()); v.setCoordinateY(p.getY());//from w ww .ja va 2 s . c om super.setLocation(v, p); }
From source file:MouseTest.java
/** * Adds a square to the collection.//from ww w .j av a2 s .com * @param p the center of the square */ public void add(Point2D p) { double x = p.getX(); double y = p.getY(); current = new Rectangle2D.Double(x - SIDELENGTH / 2, y - SIDELENGTH / 2, SIDELENGTH, SIDELENGTH); squares.add(current); repaint(); }
From source file:HitTestSample.java
public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.white);//from w ww .j av a2 s .c om Graphics2D graphics2D = (Graphics2D) g; Point2D origin = computeLayoutOrigin(); graphics2D.translate(origin.getX(), origin.getY()); // Draw textLayout. textLayout.draw(graphics2D, 0, 0); // Retrieve caret Shapes for insertionIndex. Shape[] carets = textLayout.getCaretShapes(insertionIndex); graphics2D.setColor(STRONG_CARET_COLOR); graphics2D.draw(carets[0]); if (carets[1] != null) { graphics2D.setColor(WEAK_CARET_COLOR); graphics2D.draw(carets[1]); } }
From source file:algorithms.quality.AttentionQuality.java
@Override public double getQuality(Colormap2D colormap) { // max L + max c (which is the same as a or b) double normFac = Math.sqrt(100 * 100 + 150 * 150); DescriptiveStatistics stats = new DescriptiveStatistics(); for (Point2D pt : sampling.getPoints()) { Color color = colormap.getColor(pt.getX(), pt.getY()); double[] lch = new CIELABLch().fromColor(color); double attention = Math.sqrt(lch[0] * lch[0] + lch[1] * lch[1]) / normFac; stats.addValue(attention);//ww w .j a va 2s. co m } return stats.getVariance(); }
From source file:joshua.ui.hypergraph_visualizer.HyperGraphTransformer.java
public Point2D transform(Vertex v) { // System.err.print(v); double x, y;//from w w w .ja v a2s .com /* if (v instanceof NodeVertex) { NodeVertex nv = (NodeVertex) v; int span = nv.getNode().j - nv.getNode().i; y = Y_BASELINE - Y_DIST * distanceToLeaf(v); x = X_DIST * nv.getNode().i; x += .5 * X_DIST * span; } else if (v instanceof LeafVertex) { LeafVertex lv = (LeafVertex) v; y = Y_BASELINE; x = X_DIST * lv.getTargetPosition(); } else { Vertex node = (Vertex) graph.getPredecessors(v).toArray()[0]; Point2D nodePosition = transform(node); x = nodePosition.getX(); y = nodePosition.getY() + .5 * Y_DIST; } */ // System.err.println(": (" + x + "," + y + ")"); Point2D treePosition = graphTree.transform(v); x = treePosition.getX(); y = Y_BASELINE - Y_DIST * distanceToLeaf(v); return new Point2D.Double(x, y); }