本文整理匯總了Java中java.awt.geom.AffineTransform.concatenate方法的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.concatenate方法的具體用法?Java AffineTransform.concatenate怎麽用?Java AffineTransform.concatenate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.AffineTransform
的用法示例。
在下文中一共展示了AffineTransform.concatenate方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStrike
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public FontStrike getStrike(Font font, FontRenderContext frc) {
AffineTransform at = frc.getTransform();
double ptSize = font.getSize2D();
at.scale(ptSize, ptSize);
if (font.isTransformed()) {
at.concatenate(font.getTransform());
if (at.getTranslateX() != 0 || at.getTranslateY() != 0) {
at.setTransform(at.getScaleX(),
at.getShearY(),
at.getShearX(),
at.getScaleY(),
0.0, 0.0);
}
}
int aa = FontStrikeDesc.getAAHintIntVal(this, font, frc);
int fm = FontStrikeDesc.getFMHintIntVal(frc.getFractionalMetricsHint());
FontStrikeDesc desc = new FontStrikeDesc(frc.getTransform(),
at, font.getStyle(),
aa, fm);
return getStrike(desc, false);
}
示例2: drawFrame
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private void drawFrame(GraphicsDecorator g, Shape shape, Color color, Point2D.Float pos) {
Shape old_clip = g.getClip();
AffineTransform old = g.getTransform();
AffineTransform t = g.getTransform();
t.concatenate(AffineTransform.getTranslateInstance(pos.x, pos.y));
g.setTransform(t);
g.setColor(color);
Stroke old_stroke = g.getStroke();
g.setStroke(new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
Area a = new Area(g.getClip());
a.subtract(new Area(shape));
g.setClip(a);
g.draw(shape);
g.setTransform(old);
g.setStroke(old_stroke);
g.setClip(old_clip);
}
示例3: addShadow
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Adds a shadow effect by executing the following steps: 1. Transform visible
* pixels to a semi-transparent black 2. Flip the image vertically 3. Scale it
* down 4. Render original image and shadow on a buffered image
*
* @param image
* the image
* @param xOffset
* the x offset
* @param yOffset
* the y offset
* @return the buffered image
*/
public static BufferedImage addShadow(final BufferedImage image, final int xOffset, final int yOffset) {
if (image == null) {
return image;
}
// Transform visible pixels to a semi-transparent black
final BufferedImage shadowImage = flashVisiblePixels(image, new Color(0, 0, 0, 30));
if (shadowImage == null) {
return image;
}
final AffineTransform tx = new AffineTransform();
// Flip the image vertically
tx.concatenate(AffineTransform.getScaleInstance(1, -0.15));
tx.concatenate(AffineTransform.getTranslateInstance(0, -shadowImage.getHeight()));
final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
final BufferedImage rotatedImage = op.filter(shadowImage, null);
final BufferedImage shadow = getCompatibleImage(image.getWidth(), image.getHeight() + rotatedImage.getHeight());
final Graphics2D g2D = shadow.createGraphics();
g2D.drawImage(rotatedImage, xOffset, yOffset, null);
g2D.drawImage(image, 0, 0, null);
g2D.dispose();
return shadow;
}
示例4: getTransform
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Returns the current Transform in the Graphics2D state.
* @see #transform
* @see #setTransform
*/
@Override
public AffineTransform getTransform() {
if ((constrainX | constrainY) == 0) {
return new AffineTransform(transform);
}
AffineTransform tx
= AffineTransform.getTranslateInstance(-constrainX, -constrainY);
tx.concatenate(transform);
return tx;
}
示例5: platformFontCount
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
@Override
protected int platformFontCount(Font font, String str) {
AffineTransform deviceTransform = getTransform();
AffineTransform fontTransform = new AffineTransform(deviceTransform);
fontTransform.concatenate(getFont().getTransform());
int transformType = fontTransform.getType();
/* Test if GDI can handle the transform */
boolean directToGDI = ((transformType !=
AffineTransform.TYPE_GENERAL_TRANSFORM)
&& ((transformType & AffineTransform.TYPE_FLIP)
== 0));
if (!directToGDI) {
return 0;
}
/* Since all windows fonts are available, and the JRE fonts
* are also registered. Only the Font.createFont() case is presently
* unknown to GDI. Those can be registered too, although that
* code does not exist yet, it can be added too, so we should not
* fail that case. Just do a quick check whether its a TrueTypeFont
* - ie not a Type1 font etc, and let drawString() resolve the rest.
*/
Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof CompositeFont ||
font2D instanceof TrueTypeFont) {
return 1;
} else {
return 0;
}
}
示例6: getNativePointSize
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private int getNativePointSize() {
/* Make a copy of the glyphTX in which we will store the
* font transform, inverting the devTx if necessary
*/
double[] mat = new double[4];
desc.glyphTx.getMatrix(mat);
fontTx = new AffineTransform(mat);
/* Now work backwards to get the font transform */
if (!desc.devTx.isIdentity() &&
desc.devTx.getType() != AffineTransform.TYPE_TRANSLATION) {
try {
invertDevTx = desc.devTx.createInverse();
fontTx.concatenate(invertDevTx);
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
}
/* At this point the fontTx may be a simple +ve scale, or it
* may be something more complex.
*/
Point2D.Float pt = new Point2D.Float(1f,1f);
fontTx.deltaTransform(pt, pt);
double ptSize = Math.abs(pt.y);
int ttype = fontTx.getType();
if ((ttype & ~AffineTransform.TYPE_UNIFORM_SCALE) != 0 ||
fontTx.getScaleY() <= 0) {
/* We need to create an inverse transform that doesn't
* include the point size (strictly the uniform scale)
*/
fontTx.scale(1/ptSize, 1/ptSize);
} else {
fontTx = null; // no need
}
return (int)ptSize;
}
示例7: getVisualBounds
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Return the union of the visual bounds of all the components.
* This incorporates the path. It does not include logical
* bounds (used by carets).
*/
public Rectangle2D getVisualBounds() {
Rectangle2D result = null;
for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
Rectangle2D r = tlc.getVisualBounds();
Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
if (lp == null) {
r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
r.getWidth(), r.getHeight());
} else {
lp.pathToPoint(pt, false, pt);
AffineTransform at = tlc.getBaselineTransform();
if (at != null) {
AffineTransform tx = AffineTransform.getTranslateInstance
(pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
tx.concatenate(at);
r = tx.createTransformedShape(r).getBounds2D();
} else {
r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
r.getWidth(), r.getHeight());
}
}
if (result == null) {
result = r;
} else {
result.add(r);
}
}
if (result == null) {
result = new Rectangle2D.Float(Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
}
return result;
}
示例8: getTransform
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
* Returns the current Transform in the Graphics2D state.
* @see #transform
* @see #setTransform
*/
@Override
public AffineTransform getTransform() {
if ((constrainX | constrainY) == 0 && devScale == 1) {
return new AffineTransform(transform);
}
final double invScale = 1.0 / devScale;
AffineTransform tx = new AffineTransform(invScale, 0, 0, invScale,
-constrainX * invScale,
-constrainY * invScale);
tx.concatenate(transform);
return tx;
}
示例9: drawArrow
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private void drawArrow(Graphics2D g, int x1, int y1, int x2, int y2) {
RenderingHints renderHints
= new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.addRenderingHints(renderHints);
g.setStroke(new BasicStroke(
getSetaLargura(),
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND));
//g.setPaint(Color.BLACK);
int ARR_SIZE = 3 + getSetaLargura();
double dx = x2 - x1, dy = y2 - y1;
double angle = Math.atan2(dy, dx);
int len = (int) Math.sqrt(dx * dx + dy * dy);
AffineTransform at = AffineTransform.getTranslateInstance(x1, y1);
at.concatenate(AffineTransform.getRotateInstance(angle));
//AffineTransform bkp = g.getTransform();
g.setTransform(at);
// Draw horizontal arrow starting in (0, 0)
g.drawLine(ARR_SIZE, 0, len - ARR_SIZE, 0);
if (isSetaPontaEsquerda()) {
g.fillPolygon(new int[]{len, len - ARR_SIZE, len - ARR_SIZE, len},
new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
}
if (isSetaPontaDireita()) {
g.fillPolygon(new int[]{0, ARR_SIZE, ARR_SIZE, 0},
new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
}
}
示例10: getAAHintIntVal
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public static int getAAHintIntVal(Font2D font2D, Font font,
FontRenderContext frc) {
Object aa = frc.getAntiAliasingHint();
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
aa == VALUE_TEXT_ANTIALIAS_DEFAULT) {
return INTVAL_TEXT_ANTIALIAS_OFF;
} else if (aa == VALUE_TEXT_ANTIALIAS_ON) {
return INTVAL_TEXT_ANTIALIAS_ON;
} else if (aa == VALUE_TEXT_ANTIALIAS_GASP) {
/* FRC.isIdentity() would have been useful */
int ptSize;
AffineTransform tx = frc.getTransform();
if (tx.isIdentity() && !font.isTransformed()) {
ptSize = font.getSize();
} else {
/* one or both transforms is not identity */
float size = font.getSize2D();
if (tx.isIdentity()) {
tx = font.getTransform();
tx.scale(size, size);
} else {
tx.scale(size, size);
if (font.isTransformed()) {
tx.concatenate(font.getTransform());
}
}
double shearx = tx.getShearX();
double scaley = tx.getScaleY();
if (shearx != 0) {
scaley = Math.sqrt(shearx * shearx + scaley * scaley);
}
ptSize = (int)(Math.abs(scaley)+0.5);
}
if (font2D.useAAForPtSize(ptSize)) {
return INTVAL_TEXT_ANTIALIAS_ON;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
aa == VALUE_TEXT_ANTIALIAS_LCD_HBGR) {
return INTVAL_TEXT_ANTIALIAS_LCD_HRGB;
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_VRGB ||
aa == VALUE_TEXT_ANTIALIAS_LCD_VBGR) {
return INTVAL_TEXT_ANTIALIAS_LCD_VRGB;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
}
示例11: buildRadialGradientShading
import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private PDShading buildRadialGradientShading(Paint paint, AffineTransform tf) throws IOException {
/*
* Batik has a copy of RadialGradientPaint, but it has the same structure as the
* AWT RadialGradientPaint. So we use Reflection to access the fields of both
* these classes.
*/
Color[] colors = getPropertyValue(paint, "getColors");
Color firstColor = colors[0];
PDColor firstColorMapped = colorMapper.mapColor(contentStream, firstColor);
applyAsStrokingColor(firstColor);
PDShadingType3 shading = new PDShadingType3(new COSDictionary());
shading.setShadingType(PDShading.SHADING_TYPE3);
shading.setColorSpace(firstColorMapped.getColorSpace());
float[] fractions = getPropertyValue(paint, "getFractions");
Point2D centerPoint = getPropertyValue(paint, "getCenterPoint");
Point2D focusPoint = getPropertyValue(paint, "getFocusPoint");
AffineTransform gradientTransform = getPropertyValue(paint, "getTransform");
tf.concatenate(gradientTransform);
tf.transform(centerPoint, centerPoint);
tf.transform(focusPoint, focusPoint);
@SuppressWarnings("ConstantConditions")
float radius = getPropertyValue(paint, "getRadius");
radius = (float) Math.abs(radius * tf.getScaleX());
COSArray coords = new COSArray();
coords.add(new COSFloat((float) centerPoint.getX()));
coords.add(new COSFloat((float) centerPoint.getY()));
coords.add(new COSFloat(0));
coords.add(new COSFloat((float) focusPoint.getX()));
coords.add(new COSFloat((float) focusPoint.getY()));
coords.add(new COSFloat(radius));
shading.setCoords(coords);
PDFunctionType3 type3 = buildType3Function(colors, fractions);
COSArray extend = new COSArray();
extend.add(COSBoolean.TRUE);
extend.add(COSBoolean.TRUE);
shading.setFunction(type3);
shading.setExtend(extend);
return shading;
}