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);
}
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));
}
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);
}
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();
}
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());
}
Aggregations