本文整理汇总了Java中java.awt.geom.Area.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Area.transform方法的具体用法?Java Area.transform怎么用?Java Area.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Area
的用法示例。
在下文中一共展示了Area.transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawNeedle
import java.awt.geom.Area; //导入方法依赖的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) {
Arc2D shape = new Arc2D.Double(Arc2D.PIE);
double radius = plotArea.getHeight();
double halfX = plotArea.getWidth() / 2;
double diameter = 2 * radius;
shape.setFrame(plotArea.getMinX() + halfX - radius ,
plotArea.getMinY() - radius,
diameter, diameter);
radius = Math.toDegrees(Math.asin(halfX / radius));
shape.setAngleStart(270 - radius);
shape.setAngleExtent(2 * radius);
Area s = new Area(shape);
if ((rotate != null) && (angle != 0)) {
/// we have rotation houston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s.transform(getTransform());
}
defaultDisplay(g2, s);
}
示例2: drawFiltArea
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Draw a semi-trasparent area that is the filtered area
* @param g The graphic object
* @param filteredArea The filtered area
*/
public void drawFiltArea(Graphics2D g, Area filtArea) {
AffineTransform t = new AffineTransform();
t.scale(scale / 100, scale / 100);
AffineTransform t2 = new AffineTransform();
t2.translate(tran_x, tran_y);
filtArea.transform(t);
filtArea.transform(t2);
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.GRAY);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fill(filtArea);
g.setComposite(oldComp);
g.setStroke(oldStro);
}
示例3: drawFiltArea
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Draw a semi-trasparent area that is the filtered area
* @param g The graphic object
* @param filteredArea The filtered area
*/
public void drawFiltArea(Graphics2D g, Area filtArea) {
AffineTransform t = new AffineTransform();
t.scale(scale / 100, scale / 100);
AffineTransform t2 = new AffineTransform();
t2.translate(tran_x, tran_y);
filtArea.transform(t);
filtArea.transform(t2);
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.gray);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fill(filtArea);
g.setComposite(oldComp);
g.setStroke(oldStro);
}
示例4: drawNeedle
import java.awt.geom.Area; //导入方法依赖的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) {
Arc2D shape = new Arc2D.Double(Arc2D.PIE);
double radius = plotArea.getHeight();
double halfX = plotArea.getWidth() / 2;
double diameter = 2 * radius;
shape.setFrame(plotArea.getMinX() + halfX - radius ,
plotArea.getMinY() - radius,
diameter, diameter);
radius = Math.toDegrees(Math.asin(halfX / radius));
shape.setAngleStart(270 - radius);
shape.setAngleExtent(2 * radius);
Area s = new Area(shape);
if ((rotate != null) && (angle != 0)) {
/// we have rotation houston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s.transform(getTransform());
}
defaultDisplay(g2, s);
}
示例5: nakresli
import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
void nakresli() {
vystreduj();
// Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]);
// Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]);
// a1.add(a2);
final Area poly = new Area(new Polygon(new int[] { 0, 1, 1, 5, 0 }, new int[] { 0, 1, 7, 7, 12 }, 5));
final Area a = new Area();
final AffineTransform rotace = new AffineTransform();
rotace.rotate(Math.PI / 2);
final AffineTransform zrcadlo = new AffineTransform();
zrcadlo.scale(1, -1);
for (int i = 0; i < 4; i++) {
a.transform(zrcadlo);
a.add(poly);
a.transform(zrcadlo);
a.add(poly);
a.transform(rotace);
}
g.setColor(Color.GREEN);
g.fill(a);
g.setColor(Color.BLACK);
g.draw(a);
}
示例6: calculateMultiplier
import java.awt.geom.Area; //导入方法依赖的package包/类
/** Calculating the scaling ratio for the shape to fit the dimensions provided. */
protected float calculateMultiplier(Dimension size) {
Shape shape = getShape();
Area base = new Area(shape);
AffineTransform transform = new AffineTransform();
Rectangle2D r = ShapeBounds.getBounds(base);
transform.translate(size.width/2f-r.getCenterX(),size.height/2f-r.getCenterY());
base.transform(transform);
r = ShapeBounds.getBounds(base,r);
float min = 0;
float max = 1;
Rectangle2D boundsRect = new Rectangle2D.Float(0,0,size.width,size.height);
while(isOK(base,r,boundsRect,max)==false) {
min = max;
max*=1.2;
}
float f = calculateMultiplier(base,r,boundsRect,min,max);
isOK(base,r,boundsRect,f);
return f;
}
示例7: doLayout
import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public void doLayout() {
int height = BlockUtils.VGAP, cwidth=150,width=150;
StringBuilder svg = new StringBuilder(BlockRender.getBlockTop(connectionType));
for (BlockLine line : lines) {
line.setLocation(connectionType==ConnectionType.Left?5:0, height);
svg.append(BlockRender.getBlockSide(line.getLineType(), line.getX(), line.getY(), line.getComponentWidth(), line.getComponentHeight()));
height+=line.getHeight()+BlockUtils.VGAP;
if(line.getComponentWidth()>cwidth) cwidth=line.getComponentWidth();
if(line.getWidth()>width) width=line.getWidth();
}
svg.append(BlockRender.getBlockBottom(connectionType, 0, 0,cwidth,height>30?height:30));
if(next!=null){
next.setLocation(connectionType==ConnectionType.Left?5:0, height);
next.doLayout();
if(next.getWidth()>width) width=next.getWidth();
height+=next.getHeight();
}
area = new Area(BlockRender.getPathFromSVG(svg.toString()));
if(connectionType==ConnectionType.Left) area.transform(AffineTransform.getTranslateInstance(5, 0));
setSize(width+1, height+1);
}
示例8: clip
import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public void clip(Shape s) {
if(s==null) return;
if(clipping==null) {
setClip(s);
return;
}
Area a1 = new Area(clipping);
Area a2 = new Area(s);
a2.transform(transform);
a1.intersect(a2);
if(a1.isRectangular()) {
clipping = a1.getBounds2D();
} else {
clipping = a1;
}
}
示例9: getClip
import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public Shape getClip() {
if(clipping==null)
return null;
try {
Area area = new Area(clipping);
area.transform(transform.createInverse());
if(area.isRectangular())
return area.getBounds2D();
return area;
} catch(NoninvertibleTransformException t) {
RuntimeException e2 = new RuntimeException();
e2.initCause(t);
throw e2;
}
}
示例10: isClipped
import java.awt.geom.Area; //导入方法依赖的package包/类
/** Return true if this instruction is affected by the current clipping.
* (Returns false if no clipping is present.)
*/
public boolean isClipped() {
if(clipping==null) return false;
if(isClipped==null) {
Stroke currentStroke = stroke;
if(currentStroke instanceof BasicStroke) {
BasicStroke bs = (BasicStroke)currentStroke;
currentStroke = new BasicStroke(bs.getLineWidth(),
BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);
}
Area strokeArea = new Area(currentStroke.createStrokedShape(path));
strokeArea.transform(transform);
Area clipArea = new Area(clipping);
strokeArea.subtract(clipArea);
Rectangle2D r = strokeArea.getBounds2D();
isClipped = new Boolean( r.getWidth()>.00001 && r.getHeight()>.00001 );
}
return isClipped.booleanValue();
}
示例11: getAreaOnFloor
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Returns the area on the floor of the given staircase.
*/
public Area getAreaOnFloor(HomePieceOfFurniture staircase)
{
if (staircase.getStaircaseCutOutShape() == null)
{
throw new IllegalArgumentException("No cut out shape associated to piece");
}
Shape shape = getShape(staircase.getStaircaseCutOutShape());
Area staircaseArea = new Area(shape);
if (staircase.isModelMirrored())
{
staircaseArea = getMirroredArea(staircaseArea);
}
AffineTransform staircaseTransform = AffineTransform.getTranslateInstance(
staircase.getX() - staircase.getWidth() / 2, staircase.getY() - staircase.getDepth() / 2);
staircaseTransform.concatenate(AffineTransform.getRotateInstance(staircase.getAngle(), staircase.getWidth() / 2,
staircase.getDepth() / 2));
staircaseTransform.concatenate(AffineTransform.getScaleInstance(staircase.getWidth(), staircase.getDepth()));
staircaseArea.transform(staircaseTransform);
return staircaseArea;
}
示例12: getShadowMask
import java.awt.geom.Area; //导入方法依赖的package包/类
private Shape getShadowMask( Shape parentMask ) {
Area area = new Area(parentMask);
AffineTransform tx = new AffineTransform();
tx.translate(SHADOW_SIZE, SHADOW_SIZE );//Math.sin(ANGLE)*(getHeight()+SHADOW_SIZE), 0);
area.transform(tx);
area.subtract(new Area(parentMask));
return area;
}
示例13: drawNeedle
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
@Override
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
Arc2D shape = new Arc2D.Double(Arc2D.PIE);
double radius = plotArea.getHeight();
double halfX = plotArea.getWidth() / 2;
double diameter = 2 * radius;
shape.setFrame(plotArea.getMinX() + halfX - radius ,
plotArea.getMinY() - radius,
diameter, diameter);
radius = Math.toDegrees(Math.asin(halfX / radius));
shape.setAngleStart(270 - radius);
shape.setAngleExtent(2 * radius);
Area s = new Area(shape);
if ((rotate != null) && (angle != 0)) {
/// we have rotation houston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s.transform(getTransform());
}
defaultDisplay(g2, s);
}
示例14: drawNeedle
import java.awt.geom.Area; //导入方法依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
@Override
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
Arc2D shape = new Arc2D.Double(Arc2D.PIE);
double radius = plotArea.getHeight();
double halfX = plotArea.getWidth() / 2;
double diameter = 2 * radius;
shape.setFrame(plotArea.getMinX() + halfX - radius,
plotArea.getMinY() - radius,
diameter, diameter);
radius = Math.toDegrees(Math.asin(halfX / radius));
shape.setAngleStart(270 - radius);
shape.setAngleExtent(2 * radius);
Area s = new Area(shape);
if ((rotate != null) && (angle != 0)) {
/// we have rotation houston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s.transform(getTransform());
}
defaultDisplay(g2, s);
}
示例15: paint
import java.awt.geom.Area; //导入方法依赖的package包/类
public void paint(Graphics g,double x,double y,RenderedShape otherShape,boolean debug) {
Graphics2D g2 = (Graphics2D)g.create();
Area clip = new Area(body);
clip.transform(AffineTransform.getTranslateInstance(dx, dy));
clip.intersect(new Area(new Ellipse2D.Double(x - strokeWidth*3/2, y - strokeWidth*3/2, strokeWidth*3, strokeWidth*3)));
Area otherBody = new Area(otherShape.body);
otherBody.transform(AffineTransform.getTranslateInstance(otherShape.dx, otherShape.dy));
clip.intersect(otherBody);
g2.clip(clip);
if(debug) {
g2.setStroke(new BasicStroke(5));
g2.setColor(Color.green);
g2.draw(clip);
}
g2.translate(dx, dy);
if(debug) {
g2.setColor(Color.cyan);
g2.draw(body);
}
g2.translate(imageBounds.x, imageBounds.y);
if(debug) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .75f));
}
g2.drawImage(image,0,0,null);
g2.dispose();
}