本文整理汇总了Java中java.awt.geom.GeneralPath.transform方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralPath.transform方法的具体用法?Java GeneralPath.transform怎么用?Java GeneralPath.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.GeneralPath
的用法示例。
在下文中一共展示了GeneralPath.transform方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformTriangle
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Flip or rotate a left triangle so that it fits another side.
*
* @param triangle The left triangle.
* @return The transformed triangle.
*/
private GeneralPath transformTriangle(GeneralPath triangle) {
switch(unionPosition) {
case TOP:
triangle.transform(AffineTransform.getQuadrantRotateInstance(1));
triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
break;
case BOTTOM:
triangle.transform(AffineTransform.getQuadrantRotateInstance(3));
triangle.transform(AffineTransform.getTranslateInstance(0, HEIGHT));
break;
case RIGHT:
triangle.transform(AffineTransform.getScaleInstance(-1, 1));
triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
break;
case LEFT:
default:
}
return triangle;
}
示例2: getGlyphOutlineBounds
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
Rectangle2D getGlyphOutlineBounds(int glyphID, float x, float y) {
Rectangle2D result = null;
if (sgv.invdtx == null) {
result = new Rectangle2D.Float();
result.setRect(strike.getGlyphOutlineBounds(glyphID)); // don't mutate cached rect
} else {
GeneralPath gp = strike.getGlyphOutline(glyphID, 0, 0);
gp.transform(sgv.invdtx);
result = gp.getBounds2D();
}
/* Since x is the logical advance of the glyph to this point.
* Because of the way that Rectangle.union is specified, this
* means that subsequent unioning of a rect including that
* will be affected, even if the glyph is empty. So skip such
* cases. This alone isn't a complete solution since x==0
* may also not be what is wanted. The code that does the
* unioning also needs to be aware to ignore empty glyphs.
*/
if (!result.isEmpty()) {
result.setRect(result.getMinX() + x + dx,
result.getMinY() + y + dy,
result.getWidth(), result.getHeight());
}
return result;
}
示例3: transformBend
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Flip or rotate a top left triangle so that it fits another
* corner.
*
* @param triangle The top left triangle.
* @return The transformed triangle.
*/
private GeneralPath transformBend(GeneralPath triangle) {
if (unionPosition == UnionPosition.TOP) {
if (decoration == Decoration.BEND) {
triangle.transform(AffineTransform.getScaleInstance(-1, 1));
triangle.transform(AffineTransform.getTranslateInstance(WIDTH, 0));
} else if (decoration == Decoration.BEND_SINISTER) {
// nothing to do: default is top left
}
} else if (unionPosition == UnionPosition.BOTTOM) {
if (decoration == Decoration.BEND) {
triangle.transform(AffineTransform.getScaleInstance(1, -1));
triangle.transform(AffineTransform.getTranslateInstance(0, HEIGHT));
} else if (decoration == Decoration.BEND_SINISTER) {
triangle.transform(AffineTransform.getQuadrantRotateInstance(2));
triangle.transform(AffineTransform.getTranslateInstance(WIDTH, HEIGHT));
}
}
return triangle;
}
示例4: drawNeedle
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) {
GeneralPath shape = new GeneralPath();
shape.append(new Arc2D.Double(-9.0, -7.0, 10,
14, 0.0, 25.5, Arc2D.OPEN), true);
shape.append(new Arc2D.Double(0.0, -7.0, 10,
14, 154.5, 25.5, Arc2D.OPEN), true);
shape.closePath();
getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
shape.transform(getTransform());
if ((rotate != null) && (angle != 0)) {
/// we have rotation
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
shape.transform(getTransform());
}
defaultDisplay(g2, shape);
}
示例5: drawNeedle
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
GeneralPath shape = new GeneralPath();
shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5,
Arc2D.OPEN), true);
shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5,
Arc2D.OPEN), true);
shape.closePath();
getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
shape.transform(getTransform());
if ((rotate != null) && (angle != 0)) {
/// we have rotation
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
shape.transform(getTransform());
}
defaultDisplay(g2, shape);
}
示例6: getOutline
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
public Shape getOutline(AffineTransform tx) {
GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false);
}
if (tx != null) {
dstShape.transform(tx);
}
return dstShape;
}
示例7: appendGlyphOutline
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
void appendGlyphOutline(int glyphID, GeneralPath result, float x, float y) {
// !!! fontStrike needs a method for this. For that matter, GeneralPath does.
GeneralPath gp = null;
if (sgv.invdtx == null) {
gp = strike.getGlyphOutline(glyphID, x + dx, y + dy);
} else {
gp = strike.getGlyphOutline(glyphID, 0, 0);
gp.transform(sgv.invdtx);
gp.transform(AffineTransform.getTranslateInstance(x + dx, y + dy));
}
PathIterator iterator = gp.getPathIterator(null);
result.append(iterator, false);
}
示例8: getIcon
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Returns an icon.
*
* @param shape the shape.
* @param fill the fill flag.
* @param outline the outline flag.
*
* @return the icon.
*/
private Icon getIcon(Shape shape, final boolean fill, final boolean outline) {
final int width = shape.getBounds().width;
final int height = shape.getBounds().height;
final GeneralPath path = new GeneralPath(shape);
return new Icon() {
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
path.transform(AffineTransform.getTranslateInstance(x, y));
if (fill) {
g2.fill(path);
}
if (outline) {
g2.draw(path);
}
path.transform(AffineTransform.getTranslateInstance(-x, -y));
}
public int getIconWidth() {
return width;
}
public int getIconHeight() {
return height;
}
};
}
示例9: getIcon
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Returns an icon.
*
* @param shape the shape.
* @param fillPaint the fill paint.
* @param outlinePaint the outline paint.
*
* @return The icon.
*/
private Icon getIcon(Shape shape, final Paint fillPaint,
final Paint outlinePaint) {
final int width = shape.getBounds().width;
final int height = shape.getBounds().height;
final GeneralPath path = new GeneralPath(shape);
return new Icon() {
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
path.transform(AffineTransform.getTranslateInstance(x, y));
if (fillPaint != null) {
g2.setPaint(fillPaint);
g2.fill(path);
}
if (outlinePaint != null) {
g2.setPaint(outlinePaint);
g2.draw(path);
}
path.transform(AffineTransform.getTranslateInstance(-x, -y));
}
public int getIconWidth() {
return width;
}
public int getIconHeight() {
return height;
}
};
}
示例10: drawNeedle
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) {
GeneralPath shape1 = new GeneralPath();
GeneralPath shape2 = new GeneralPath();
float minX = (float) plotArea.getMinX();
float minY = (float) plotArea.getMinY();
float maxX = (float) plotArea.getMaxX();
float maxY = (float) plotArea.getMaxY();
float midX = (float) (minX + (plotArea.getWidth() / 2));
float midY = (float) (minY + (plotArea.getHeight() / 2));
shape1.moveTo(minX, midY);
shape1.lineTo(midX, minY);
shape1.lineTo(maxX, midY);
shape1.closePath();
shape2.moveTo(minX, midY);
shape2.lineTo(midX, maxY);
shape2.lineTo(maxX, midY);
shape2.closePath();
if ((rotate != null) && (angle != 0)) {
/// we have rotation huston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
shape1.transform(getTransform());
shape2.transform(getTransform());
}
if (getFillPaint() != null) {
g2.setPaint(getFillPaint());
g2.fill(shape1);
}
if (getHighlightPaint() != null) {
g2.setPaint(getHighlightPaint());
g2.fill(shape2);
}
if (getOutlinePaint() != null) {
g2.setStroke(getOutlineStroke());
g2.setPaint(getOutlinePaint());
g2.draw(shape1);
g2.draw(shape2);
}
}
示例11: drawNeedle
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
GeneralPath shape1 = new GeneralPath();
GeneralPath shape2 = new GeneralPath();
float minX = (float) plotArea.getMinX();
float minY = (float) plotArea.getMinY();
float maxX = (float) plotArea.getMaxX();
float maxY = (float) plotArea.getMaxY();
float midX = (float) (minX + (plotArea.getWidth() / 2));
float midY = (float) (minY + (plotArea.getHeight() / 2));
shape1.moveTo(minX, midY);
shape1.lineTo(midX, minY);
shape1.lineTo(maxX, midY);
shape1.closePath();
shape2.moveTo(minX, midY);
shape2.lineTo(midX, maxY);
shape2.lineTo(maxX, midY);
shape2.closePath();
if ((rotate != null) && (angle != 0)) {
/// we have rotation huston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
shape1.transform(getTransform());
shape2.transform(getTransform());
}
if (getFillPaint() != null) {
g2.setPaint(getFillPaint());
g2.fill(shape1);
}
if (getHighlightPaint() != null) {
g2.setPaint(getHighlightPaint());
g2.fill(shape2);
}
if (getOutlinePaint() != null) {
g2.setStroke(getOutlineStroke());
g2.setPaint(getOutlinePaint());
g2.draw(shape1);
g2.draw(shape2);
}
}
示例12: center
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
/**
* Centers the given path on the given point (x,y).
*
* @param path The path to center.
* @param x The x coordinate of the center.
* @param y The y coordinate of the center.
*/
private void center(GeneralPath path, double x, double y) {
double dx = x - path.getBounds().getX() - path.getBounds().getWidth() / 2;
double dy = y - path.getBounds().getY() - path.getBounds().getHeight() / 2;
path.transform(AffineTransform.getTranslateInstance(dx, dy));
}