use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method transformShape.
protected static Shape transformShape(AffineTransform tx, Shape clip) {
if (clip == null) {
return null;
}
if (clip instanceof Rectangle2D && (tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0) {
Rectangle2D rect = (Rectangle2D) clip;
double[] matrix = new double[4];
matrix[0] = rect.getX();
matrix[1] = rect.getY();
matrix[2] = matrix[0] + rect.getWidth();
matrix[3] = matrix[1] + rect.getHeight();
tx.transform(matrix, 0, matrix, 0, 2);
fixRectangleOrientation(matrix, rect);
return new Rectangle2D.Double(matrix[0], matrix[1], matrix[2] - matrix[0], matrix[3] - matrix[1]);
}
if (tx.isIdentity()) {
return cloneShape(clip);
}
return tx.createTransformedShape(clip);
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method transformShape.
protected static Shape transformShape(int tx, int ty, Shape s) {
if (s == null) {
return null;
}
if (s instanceof Rectangle) {
Rectangle r = s.getBounds();
r.translate(tx, ty);
return r;
}
if (s instanceof Rectangle2D) {
Rectangle2D rect = (Rectangle2D) s;
return new Rectangle2D.Double(rect.getX() + tx, rect.getY() + ty, rect.getWidth(), rect.getHeight());
}
if (tx == 0 && ty == 0) {
return cloneShape(s);
}
AffineTransform mat = AffineTransform.getTranslateInstance(tx, ty);
return mat.createTransformedShape(s);
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class TextLine method getCharBounds.
public Rectangle2D getCharBounds(int logicalIndex) {
if (logicalIndex < 0) {
throw new IllegalArgumentException("Negative logicalIndex.");
}
int tlcStart = 0;
for (int i = 0; i < fComponents.length; i++) {
int tlcLimit = tlcStart + fComponents[i].getNumCharacters();
if (tlcLimit > logicalIndex) {
TextLineComponent tlc = fComponents[i];
int indexInTlc = logicalIndex - tlcStart;
Rectangle2D chBounds = tlc.getCharVisualBounds(indexInTlc);
int vi = getComponentVisualIndex(i);
chBounds.setRect(chBounds.getX() + locs[vi * 2], chBounds.getY() + locs[vi * 2 + 1], chBounds.getWidth(), chBounds.getHeight());
return chBounds;
} else {
tlcStart = tlcLimit;
}
}
throw new IllegalArgumentException("logicalIndex too large.");
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class TextLine method getItalicBounds.
public Rectangle2D getItalicBounds() {
float left = Float.MAX_VALUE, right = -Float.MAX_VALUE;
float top = Float.MAX_VALUE, bottom = -Float.MAX_VALUE;
for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
Rectangle2D tlcBounds = tlc.getItalicBounds();
float x = locs[n];
float y = locs[n + 1];
left = Math.min(left, x + (float) tlcBounds.getX());
right = Math.max(right, x + (float) tlcBounds.getMaxX());
top = Math.min(top, y + (float) tlcBounds.getY());
bottom = Math.max(bottom, y + (float) tlcBounds.getMaxY());
}
return new Rectangle2D.Float(left, top, right - left, bottom - top);
}
use of java.awt.geom.Rectangle2D in project processdash by dtuma.
the class ReportsAndToolsIcon method paintLargeIconImpl.
private void paintLargeIconImpl(Graphics2D g2, int pw, int ph) {
// draw a white page with a black outline.
int pageHeight = ph - 1;
int pageWidth = ph * 9 / 11;
g2.setColor(Color.white);
g2.fillRect(0, 0, pageWidth, pageHeight);
g2.setColor(Color.gray);
g2.drawRect(0, 0, pageWidth, pageHeight);
// draw text onto the page
int pad = 1 + ph / 20;
float lineSpacing = Math.max(2, ph / 14);
float fontSize = 0.85f * lineSpacing;
float y = pad + lineSpacing;
g2.setClip(pad + 1, pad, pageWidth - 2 * pad, pageHeight - 2 * pad);
g2.setFont(new Font("Dialog", Font.PLAIN, 10).deriveFont(fontSize));
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setColor(Color.darkGray);
String s = TEXT;
while (y <= ph) {
g2.drawString(s, pad + 1, y);
s = s.substring(20);
if (s.charAt(0) == ' ')
s = s.substring(1);
y += lineSpacing;
}
// calculate the geometry for the chart in the lower-left corner
int barWidth = pageWidth / 5;
int chartHeight = (int) (pageHeight * 0.4);
int chartTop = pageHeight - pad - chartHeight;
Rectangle2D[] bars = new Rectangle2D[BAR_DELTA.length];
for (int i = bars.length; i-- > 0; ) {
float barGap = chartHeight * BAR_DELTA[i];
bars[i] = new Rectangle2D.Float(pad + 1 + barWidth * i, chartTop + barGap, barWidth, chartHeight);
}
// draw white areas to ensure the text doesn't run into the bars
g2.setColor(Color.white);
g2.setStroke(new BasicStroke(Math.max(3, 1 + pad * 1.2f)));
for (int i = bars.length; i-- > 0; ) g2.draw(bars[i]);
// draw the bars themselves
for (int i = bars.length; i-- > 0; ) {
Color light = PaintUtils.mixColors(BAR_COLORS[i], Color.white, 0.7);
g2.setPaint(new GradientPaint((int) bars[i].getX(), 0, BAR_COLORS[i], (int) bars[i].getMaxX(), 0, light));
g2.fill(bars[i]);
}
// draw the calculator
ImageIcon calc = loadImage("calc.png");
int calcHeight = ph * 2 / 3;
float calcScale = calcHeight / (float) calc.getIconHeight();
int calcWidth = (int) (0.5 + calc.getIconWidth() * calcScale);
int calcLeft = (int) (pageWidth - pad * 2 / 3);
int calcTop = ph / 4;
Image scaledCalc = new ImageIcon(//
calc.getImage().getScaledInstance(calcWidth, calcHeight, Image.SCALE_SMOOTH)).getImage();
g2.setClip(null);
g2.drawImage(scaledCalc, calcLeft, calcTop, null);
}
Aggregations