use of java.awt.geom.AffineTransform in project antlrworks by antlr.
the class XJRotableToggleButton method paint.
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
AffineTransform tr = g2d.getTransform();
switch(rotation) {
case ROTATE_90:
tr.rotate(Math.PI / 2);
tr.translate(0, -computedHeight);
g2d.setTransform(tr);
break;
case ROTATE_270:
tr.rotate(-Math.PI / 2);
tr.translate(-computedWidth, 0);
g2d.setTransform(tr);
break;
}
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
drawAquaBackground(g2d);
TextLayout layout = new TextLayout(title, g2d.getFont(), g2d.getFontRenderContext());
Rectangle2D r = layout.getBounds();
int offset = MARGIN_WIDTH;
if (icon != null) {
int voffset = (computedHeight - icon.getIconHeight()) / 2;
g2d.drawImage(icon.getImage(), offset, voffset, null);
offset += icon.getIconWidth();
offset += SEPARATOR;
} else {
offset = (int) ((computedWidth - r.getWidth()) / 2);
}
int voffset = (int) ((computedHeight - r.getHeight()) / 2);
g2d.setColor(Color.black);
layout.draw(g2d, offset, computedHeight - voffset - layout.getDescent() / 2);
}
use of java.awt.geom.AffineTransform in project WordCram by danbernier.
the class EngineWord method finalizeLocation.
void finalizeLocation() {
AffineTransform transform = AffineTransform.getTranslateInstance(currentLocation.x, currentLocation.y);
shape = transform.createTransformedShape(shape);
bbTree.setLocation((int) currentLocation.x, (int) currentLocation.y);
word.setRenderedPlace(currentLocation);
}
use of java.awt.geom.AffineTransform in project darkFunction-Editor by darkFunction.
the class AnimationCell method rebuild.
public void rebuild() {
//System.out.println("Attempting to rebuild animation cell volatile image");
Rectangle r = getSpreadRect();
if (r.width <= 0 || r.height <= 0) {
vImage = null;
return;
}
do {
vImage = ImageUtil.createVolatileImage(r.width, r.height, java.awt.Transparency.TRANSLUCENT);
Graphics2D g = null;
try {
g = vImage.createGraphics();
// clear to transparent
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, r.width, r.height);
g.setComposite(AlphaComposite.SrcOver);
//for (Enumeration<GraphicObject> e = graphicNodeDict.keys(); e.hasMoreElements();)
for (int i = graphicOrderList.size() - 1; i >= 0; i--) {
//GraphicObject graphic = e.nextElement();
GraphicObject graphic = graphicOrderList.get(i);
// backup selected state and remove... don't want to draw it selected in the cell
boolean isSelected = graphic.isSelected();
graphic.setSelected(false);
Graphics2D g2d = (Graphics2D) g;
AffineTransform transform = new AffineTransform(g2d.getTransform());
AffineTransform oldTransform = g2d.getTransform();
Rectangle gr = graphic.getRect();
transform.rotate(Math.toRadians(graphic.getAngle()), -r.x + gr.x + gr.width / 2, -r.y + gr.y + gr.height / 2);
g2d.setTransform(transform);
graphic.draw(g2d, new Point(-r.x, -r.y), 1.0f, 1.0f, false);
g2d.setTransform(oldTransform);
// restore selected state
graphic.setSelected(isSelected);
}
} finally {
g.dispose();
}
} while (vImage.contentsLost());
}
use of java.awt.geom.AffineTransform in project Fling by entertailion.
the class DragHereIcon method paintIcon.
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.translate(x, y);
g2.setStroke(new BasicStroke(a));
g2.setPaint(linec);
g2.draw(new RoundRectangle2D.Float(a, a, size - 2 * a - 1, size - 2 * a - 1, r, r));
// draw bounding box
g2.setStroke(new BasicStroke(b));
g2.setColor(UIManager.getColor("Panel.background"));
g2.drawLine(1 * f, 0 * f, 1 * f, 4 * f);
g2.drawLine(2 * f, 0 * f, 2 * f, 4 * f);
g2.drawLine(3 * f, 0 * f, 3 * f, 4 * f);
g2.drawLine(0 * f, 1 * f, 4 * f, 1 * f);
g2.drawLine(0 * f, 2 * f, 4 * f, 2 * f);
g2.drawLine(0 * f, 3 * f, 4 * f, 3 * f);
// draw arrow
g2.setPaint(linec);
Rectangle2D b = s.getBounds();
Point2D.Double p = new Point2D.Double(b.getX() + b.getWidth() / 2d, b.getY() + b.getHeight() / 2d);
AffineTransform toCenterAT = AffineTransform.getTranslateInstance(size / 2d - p.getX(), size / 2d - p.getY());
g2.fill(toCenterAT.createTransformedShape(s));
g2.translate(-x, -y);
g2.dispose();
}
use of java.awt.geom.AffineTransform in project android_frameworks_base by ParanoidAndroid.
the class Paint_Delegate method updateFontObject.
/**
* Update the {@link Font} object from the typeface, text size and scaling
*/
@SuppressWarnings("deprecation")
private void updateFontObject() {
if (mTypeface != null) {
// Get the fonts from the TypeFace object.
List<Font> fonts = mTypeface.getFonts();
// create new font objects as well as FontMetrics, based on the current text size
// and skew info.
ArrayList<FontInfo> infoList = new ArrayList<FontInfo>(fonts.size());
for (Font font : fonts) {
FontInfo info = new FontInfo();
info.mFont = font.deriveFont(mTextSize);
if (mTextScaleX != 1.0 || mTextSkewX != 0) {
// TODO: support skew
info.mFont = info.mFont.deriveFont(new AffineTransform(mTextScaleX, mTextSkewX, 0, 1, 0, 0));
}
info.mMetrics = Toolkit.getDefaultToolkit().getFontMetrics(info.mFont);
infoList.add(info);
}
mFonts = Collections.unmodifiableList(infoList);
}
}
Aggregations