List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static void drawText(Graphics2D g2, Rectangle2D imageArea, LinkedHashMap<Rectangle2D, String> textContentMap, JFreeChart chart) { if (textContentMap == null || textContentMap.size() == 0) { return;//from w w w . j av a 2 s . co m } // for (Entry<Rectangle2D, String> textEntry : textMap.entrySet()) { // Rectangle2D rect = textEntry.getKey(); // String text = textEntry.getValue(); // drawText(g2, imageArea, rect, text, chart); // } Color oldColor = g2.getColor(); g2.setColor(Color.BLACK); for (Entry<Rectangle2D, String> entry : textContentMap.entrySet()) { Rectangle2D rect = entry.getKey(); Point2D screenPoint = ChartMaskingUtilities .translateChartPoint(new Point2D.Double(rect.getX(), rect.getY()), imageArea, chart); String text = entry.getValue(); if (text == null) { continue; } String[] lines = text.split("\n"); g2.setColor(Color.BLACK); for (int i = 0; i < lines.length; i++) { g2.drawString(lines[i], (int) screenPoint.getX() + 3, (int) screenPoint.getY() - 3 + i * 15); } // if (rect == selectedTextWrapper) { // FontMetrics fm = g2.getFontMetrics(); // int maxWidth = 0; // int maxHeight = 0; // for (int i = 0; i < lines.length; i++) { // int lineWidth = fm.stringWidth(lines[i]); // if (lineWidth > maxWidth) { // maxWidth = lineWidth; // } // } // maxHeight = 15 * lines.length; // if (maxWidth < 100) { // maxWidth = 100; // } // Rectangle2D inputBox = new Rectangle2D.Double(screenPoint.getX(), screenPoint.getY() - 15, maxWidth + 8, maxHeight); // Color fillColor = new Color(250, 250, 50, 30); // g2.setPaint(fillColor); // g2.fill(inputBox); // g2.setColor(Color.ORANGE); // g2.drawRect((int) screenPoint.getX(), (int) screenPoint.getY() - 15, maxWidth + 8, maxHeight); // // } // g2.drawString(text == null ? "" : text, (int) screenPoint.getX() + 3, (int) screenPoint.getY() - 3); } g2.setColor(oldColor); }
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:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static Point2D translateChartPoint(Point2D point, Rectangle2D imageArea, JFreeChart chart, int rangeAxisIndex) { XYPlot plot = chart.getXYPlot();//from www . ja va 2 s .co m double x, y; ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis; if (rangeAxisIndex < 0 || rangeAxisIndex >= plot.getRangeAxisCount()) { rangeAxis = plot.getRangeAxis(); } else { rangeAxis = plot.getRangeAxis(rangeAxisIndex); } x = domainAxis.valueToJava2D(point.getX(), imageArea, RectangleEdge.BOTTOM); y = rangeAxis.valueToJava2D(point.getY(), imageArea, RectangleEdge.LEFT); return new Point2D.Double(x, y); }
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 v a 2 s. c o m 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 w w w . j a v a 2 s . co m*/ // 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:algorithms.quality.JndRegionSize.java
private double computeArea(List<Point2D> poly, Point2D center) { double sum = 0; for (int i = 0; i < poly.size(); i++) { Point2D p0 = poly.get(i); Point2D p1 = poly.get((i + 1) % poly.size()); sum = sum + p0.getX() * p1.getY() - p0.getY() * p1.getX(); }//from w w w .j ava 2 s. c o m double area = Math.abs(sum / 2); return area; }
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);//from w ww . j av a2s . c o m } return stats.getVariance(); }
From source file:vnreal.gui.control.MyGraphLayout.java
@Override public void setLocation(V v, Point2D p) { // Update own storage. v.setCoordinateX(p.getX());/*ww w.jav a 2 s . c o m*/ v.setCoordinateY(p.getY()); super.setLocation(v, p); }
From source file:HitTestSample.java
public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.white);//from w w w . j av a 2s . c o m 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]); } }