Search in sources :

Example 36 with Point2D

use of java.awt.geom.Point2D in project poi by apache.

the class DrawPaint method createRadialGradientPaint.

protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) {
    Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
    Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth() / 2, anchor.getY() + anchor.getHeight() / 2);
    float radius = (float) Math.max(anchor.getWidth(), anchor.getHeight());
    float[] fractions = fill.getGradientFractions();
    Color[] colors = new Color[fractions.length];
    int i = 0;
    for (ColorStyle fc : fill.getGradientColors()) {
        colors[i++] = applyColorTransform(fc);
    }
    return new RadialGradientPaint(pCenter, radius, fractions, colors);
}
Also used : Point2D(java.awt.geom.Point2D) ColorStyle(org.apache.poi.sl.usermodel.ColorStyle) Color(java.awt.Color) Rectangle2D(java.awt.geom.Rectangle2D) RadialGradientPaint(java.awt.RadialGradientPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) GradientPaint(org.apache.poi.sl.usermodel.PaintStyle.GradientPaint) TexturePaint(org.apache.poi.sl.usermodel.PaintStyle.TexturePaint) LinearGradientPaint(java.awt.LinearGradientPaint) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Example 37 with Point2D

use of java.awt.geom.Point2D in project intellij-community by JetBrains.

the class EditorWindowImpl method xyToVisualPosition.

@NotNull
@Override
public VisualPosition xyToVisualPosition(@NotNull Point2D p) {
    checkValid();
    Point2D pp = p.getX() >= 0 && p.getY() >= 0 ? p : new Point2D.Double(Math.max(p.getX(), 0), Math.max(p.getY(), 0));
    LogicalPosition hostPos = myDelegate.visualToLogicalPosition(myDelegate.xyToVisualPosition(pp));
    return logicalToVisualPosition(hostToInjected(hostPos));
}
Also used : Point2D(java.awt.geom.Point2D) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with Point2D

use of java.awt.geom.Point2D in project intellij-community by JetBrains.

the class DimensionService method keyPair.

/**
   * @return Pair(key, scale) where:
   * key is the HiDPI-aware key,
   * scale is the HiDPI-aware factor to transform size metrics.
   */
@NotNull
private static Pair<String, Float> keyPair(String key, @Nullable Project project) {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (env.isHeadlessInstance()) {
        return new Pair<>(key + ".headless", 1f);
    }
    JFrame frame = null;
    final Component owner = IdeFocusManager.findInstance().getFocusOwner();
    if (owner != null) {
        frame = UIUtil.getParentOfType(JFrame.class, owner);
    }
    if (frame == null) {
        frame = WindowManager.getInstance().findVisibleFrame();
    }
    if (project != null && (frame == null || (frame instanceof IdeFrame && project != ((IdeFrame) frame).getProject()))) {
        frame = WindowManager.getInstance().getFrame(project);
    }
    Rectangle screen = new Rectangle(0, 0, 0, 0);
    GraphicsDevice gd = null;
    if (frame != null) {
        final Point topLeft = frame.getLocation();
        Point2D center = new Point2D.Float(topLeft.x + frame.getWidth() / 2, topLeft.y + frame.getHeight() / 2);
        for (GraphicsDevice device : env.getScreenDevices()) {
            Rectangle bounds = device.getDefaultConfiguration().getBounds();
            if (bounds.contains(center)) {
                screen = bounds;
                gd = device;
                break;
            }
        }
    }
    if (gd == null) {
        gd = env.getDefaultScreenDevice();
        screen = gd.getDefaultConfiguration().getBounds();
    }
    float scale = 1f;
    if (UIUtil.isJreHiDPIEnabled()) {
        scale = JBUI.sysScale(gd.getDefaultConfiguration());
        // normalize screen bounds
        screen.setBounds((int) Math.floor(screen.x * scale), (int) Math.floor(screen.y * scale), (int) Math.ceil(screen.width * scale), (int) Math.ceil(screen.height * scale));
    }
    String realKey = key + '.' + screen.x + '.' + screen.y + '.' + screen.width + '.' + screen.height;
    if (JBUI.isPixHiDPI(gd.getDefaultConfiguration())) {
        int dpi = ((int) (96 * JBUI.pixScale(gd.getDefaultConfiguration())));
        realKey += "@" + dpi + "dpi";
    }
    return new Pair<>(realKey, scale);
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame) Point2D(java.awt.geom.Point2D) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with Point2D

use of java.awt.geom.Point2D in project ddf by codice.

the class GeoPdfParserImpl method getWktFromNeatLine.

/**
     * Parses a given NeatLine and Transformation matrix into a WKT String
     *
     * @param lgidict         - The PDF's LGIDict object
     * @param neatLineArray   - The NeatLine array of points for the PDF
     * @param toDoubleVisitor - A visitor that converts PDF Strings / Ints / Longs into doubles.
     * @return the generated WKT Lat/Lon set
     * @throws IOException
     */
private String getWktFromNeatLine(COSDictionary lgidict, COSArray neatLineArray, ICOSVisitor toDoubleVisitor) throws IOException {
    List<Double> neatline = new LinkedList<>();
    List<String> coordinateList = new LinkedList<>();
    String firstCoordinate = null;
    double[] points = new double[CTM_SIZE];
    for (int i = 0; i < CTM_SIZE; i++) {
        points[i] = (Double) lgidict.getObjectFromPath(CTM + "/[" + i + "]").accept(toDoubleVisitor);
    }
    AffineTransform affineTransform = new AffineTransform(points);
    for (int i = 0; i < neatLineArray.size(); i++) {
        neatline.add((Double) neatLineArray.get(i).accept(toDoubleVisitor));
    }
    for (int i = 0; i < neatline.size(); i += 2) {
        double x = neatline.get(i);
        double y = neatline.get(i + 1);
        Point2D p = new Point2D.Double(x, y);
        Point2D pprime = affineTransform.transform(p, null);
        String xySet = point2dToWkt(pprime);
        if (firstCoordinate == null) {
            firstCoordinate = xySet;
        }
        coordinateList.add(xySet);
    }
    coordinateList.add(firstCoordinate);
    String wktString = StringUtils.join(coordinateList, ", ");
    LOGGER.debug("{}", wktString);
    return wktString.toString();
}
Also used : Point2D(java.awt.geom.Point2D) AffineTransform(java.awt.geom.AffineTransform) COSString(org.apache.pdfbox.cos.COSString) LinkedList(java.util.LinkedList)

Example 40 with Point2D

use of java.awt.geom.Point2D in project jdk8u_jdk by JetBrains.

the class XWarningWindow method reposition.

/**
     * @param x,y,w,h coordinates of the untrusted window
     */
public void reposition(int x, int y, int w, int h) {
    Point2D point = AWTAccessor.getWindowAccessor().calculateSecurityWarningPosition(ownerWindow, x, y, w, h);
    reshape((int) point.getX(), (int) point.getY(), getWidth(), getHeight());
}
Also used : Point2D(java.awt.geom.Point2D)

Aggregations

Point2D (java.awt.geom.Point2D)193 Color (java.awt.Color)22 Rectangle2D (java.awt.geom.Rectangle2D)20 RadialGradientPaint (java.awt.RadialGradientPaint)19 Graphics2D (java.awt.Graphics2D)18 Point (java.awt.Point)18 Paint (java.awt.Paint)17 Line2D (java.awt.geom.Line2D)12 AffineTransform (java.awt.geom.AffineTransform)11 Rectangle (java.awt.Rectangle)9 BasicStroke (java.awt.BasicStroke)8 Stroke (java.awt.Stroke)8 Ellipse2D (java.awt.geom.Ellipse2D)8 BufferedImage (java.awt.image.BufferedImage)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 Element (org.jdom2.Element)6 GradientPaint (java.awt.GradientPaint)5 Arc2D (java.awt.geom.Arc2D)5 GeneralPath (java.awt.geom.GeneralPath)5