当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransform类代码示例

本文整理汇总了Java中java.awt.geom.AffineTransform的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform类的具体用法?Java AffineTransform怎么用?Java AffineTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AffineTransform类属于java.awt.geom包,在下文中一共展示了AffineTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintComponent

import java.awt.geom.AffineTransform; //导入依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform origXform = g2d.getTransform();
    AffineTransform newXform = (AffineTransform) (origXform.clone());
    //center of rotation is center of the panel
    int xRot = this.getWidth() / 2;
    int yRot = this.getHeight() / 2;
    newXform.rotate((2 * Math.PI) - currentAngle, xRot, yRot);
    g2d.setTransform(newXform);
    //draw image centered in panel
    int x = (getWidth() - image.getWidth(this)) / 2;
    int y = (getHeight() - image.getHeight(this)) / 2;
    g2d.drawImage(image, x, y, this);
    g2d.setTransform(origXform);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:18,代码来源:RotatableImagePanel.java

示例2: renderFogOfWar

import java.awt.geom.AffineTransform; //导入依赖的package包/类
@Override
public void renderFogOfWar(final Graphics2D g) {
  if (this.fogOfWar == null) {
    return;
  }

  final AffineTransform oldTransform = g.getTransform();
  final AffineTransform at = new AffineTransform();
  at.scale(Game.getCamera().getRenderScale(), Game.getCamera().getRenderScale());
  at.translate(Game.getCamera().getPixelOffsetX(), Game.getCamera().getPixelOffsetY());

  g.setTransform(at);
  g.setColor(FogOfWarColor);
  g.fill(this.fogOfWar);
  g.setTransform(oldTransform);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:17,代码来源:CombatEntityVision.java

示例3: deviceFill

import java.awt.geom.AffineTransform; //导入依赖的package包/类
protected void deviceFill(PathIterator pathIter, Color color,
                          AffineTransform tx, Shape clip) {

    setTransform(tx);
    setClip(clip);
    setColor(color);
    convertToPSPath(pathIter);
    /* Specify the path to fill as the clip, this ensures that only
     * pixels which are inside the path will be filled, which is
     * what the Java 2D APIs specify
     */
    mPSStream.println(GSAVE_STR);
    selectClipPath();
    fillPath();
    mPSStream.println(GRESTORE_STR + " " + NEWPATH_STR);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:PSPrinterJob.java

示例4: compare

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public static boolean compare(AffineTransform at1, AffineTransform at2) {
    maxulps = Math.max(maxulps, ulps(at1.getScaleX(), at2.getScaleX()));
    maxulps = Math.max(maxulps, ulps(at1.getScaleY(), at2.getScaleY()));
    maxulps = Math.max(maxulps, ulps(at1.getShearX(), at2.getShearX()));
    maxulps = Math.max(maxulps, ulps(at1.getShearY(), at2.getShearY()));
    maxtxulps = Math.max(maxtxulps,
                         ulps(at1.getTranslateX(), at2.getTranslateX()));
    maxtxulps = Math.max(maxtxulps,
                         ulps(at1.getTranslateY(), at2.getTranslateY()));
    return (getModifiedType(at1) == getModifiedType(at2) &&
            (compare(at1.getScaleX(), at2.getScaleX(), MAX_ULPS)) &&
            (compare(at1.getScaleY(), at2.getScaleY(), MAX_ULPS)) &&
            (compare(at1.getShearX(), at2.getShearX(), MAX_ULPS)) &&
            (compare(at1.getShearY(), at2.getShearY(), MAX_ULPS)) &&
            (compare(at1.getTranslateX(),
                     at2.getTranslateX(), MAX_TX_ULPS)) &&
            (compare(at1.getTranslateY(),
                     at2.getTranslateY(), MAX_TX_ULPS)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:TestInvertMethods.java

示例5: AffineTransformOp

import java.awt.geom.AffineTransform; //导入依赖的package包/类
/**
 * Construct AffineTransformOp with the given xform and rendering hints.
 * 
 * @param xform AffineTransform that will applied to the source image
 * @param hints rendering hints that will be used during transformation
 * @throws ImagingOpException if the transform matrix is noninvertible
 */
public AffineTransformOp (AffineTransform xform, RenderingHints hints)
{
  this.transform = xform;
  this.hints = hints;
  if (xform.getDeterminant() == 0)
    throw new ImagingOpException(null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:AffineTransformOp.java

示例6: 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);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:18,代码来源:ViwnVertexRenderer.java

示例7: createImageProjected

import java.awt.geom.AffineTransform; //导入依赖的package包/类
/**
 * Modify the GeometricLayer so the layer coordinate system matches the image coordinate system ("pixel" projection).
 */
public static GeometryImage createImageProjected(GeometryImage layer, AffineTransform geoTransform) {
    for(Geometry geom:layer.geoms){
        for(Coordinate pos:geom.getCoordinates()){
            Point2D.Double temp=new Point2D.Double();
            try {
	geoTransform.inverseTransform(new Point2D.Double(pos.x, pos.y),temp);
} catch (NoninvertibleTransformException e) {
	e.printStackTrace();
}
            pos.x=temp.x;
            pos.y=temp.y;
        }
    }
    return layer;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:GeometryImage.java

示例8: getAATileGenerator

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public AATileGenerator getAATileGenerator(Shape s,
                                          AffineTransform at,
                                          Region clip,
                                          BasicStroke bs,
                                          boolean thin,
                                          boolean normalize,
                                          int bbox[])
{
    System.out.println(name+".getAATileGenerator("+
                       s.getClass().getName()+", "+
                       at+", "+
                       clip+", "+
                       bs+", "+
                       (thin ? "thin" : "wide")+", "+
                       (normalize ? "normalized" : "pure")+")");
    return target.getAATileGenerator(s, at, clip,
                                     bs, thin, normalize,
                                     bbox);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:RenderingEngine.java

示例9: draw

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public void draw(Graphics2D g) {
	arc = null;;
	arc2 = null;;
	if( path==null)return;
	AffineTransform at = g.getTransform();
	if( !enabled || line==null) return;
	g.setStroke( new BasicStroke(4.f/(float)map.getZoom()) );
	g.setColor(Color.white);
	g.draw( path );
	double wrap = map.getWrap();
	if( wrap>0.) {
		g.translate(wrap, 0.);
		g.draw( path );
	}
	g.setTransform(at);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:17,代码来源:GMAProfile.java

示例10: strokeTo

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public void strokeTo(Shape src,
                     AffineTransform at,
                     BasicStroke bs,
                     boolean thin,
                     boolean normalize,
                     boolean antialias,
                     PathConsumer2D consumer)
{
    System.out.println(name+".strokeTo("+
                       src.getClass().getName()+", "+
                       at+", "+
                       bs+", "+
                       (thin ? "thin" : "wide")+", "+
                       (normalize ? "normalized" : "pure")+", "+
                       (antialias ? "AA" : "non-AA")+", "+
                       consumer.getClass().getName()+")");
    target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:RenderingEngine.java

示例11: paintComponent

import java.awt.geom.AffineTransform; //导入依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    atualizar();
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2.setFont(FONT);
    FontRenderContext frc = g2.getFontRenderContext();
    TextLayout textLayout = new TextLayout(Integer.toString(value), FONT, frc);
    g2.setPaint(textColor);
    AffineTransform at = AffineTransform.getTranslateInstance(20, 30);
    Shape outline = textLayout.getOutline(at);
    g2.fill(outline);
    g2.setPaint(BLACK);
    g2.draw(outline);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:19,代码来源:Custo.java

示例12: draw

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public void draw(Graphics g, Map map) {
  if (drawGhost) {
    final Point p = map.componentCoordinates(getGhostPosition());

    final Graphics2D g2d = (Graphics2D) g.create();
    g2d.transform(
       AffineTransform.getRotateInstance(-PI_180 * tempAngle,
                                         p.x + centerX(),
                                         p.y + centerY()));
    g2d.setComposite(
       AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                         RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         RenderingHints.VALUE_ANTIALIAS_ON);
    piece.draw(g2d, p.x, p.y, map.getView(), map.getZoom());
    g2d.dispose();
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:FreeRotator.java

示例13: draw

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public void draw(Graphics g, int x, int y, Component obs, double zoom) {
  if (invisibleToMe()) {
    return;
  }
  else if (invisibleToOthers()) {
    final Graphics2D g2d = (Graphics2D) g;

    if (bgColor != null) {
      g.setColor(bgColor);
      final AffineTransform t = AffineTransform.getScaleInstance(zoom, zoom);
      t.translate(x / zoom, y / zoom);
      g2d.fill(t.createTransformedShape(piece.getShape()));
    }

    final Composite oldComposite = g2d.getComposite();
    g2d.setComposite(
      AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transparency)
    );
    piece.draw(g, x, y, obs, zoom);
    g2d.setComposite(oldComposite);
  }
  else {
    piece.draw(g, x, y, obs, zoom);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:Hideable.java

示例14: drawYLabel

import java.awt.geom.AffineTransform; //导入依赖的package包/类
private void drawYLabel(Graphics2D chartGraphics) {
    if (yAxisLabel != null) {
        // Strings are drawn from the baseline position of the leftmost char.
        int yPosYAxisLabel = heatMapC.y + (yAxisLabelSize.width / 2);
        int xPosYAxisLabel = (margin / 2) + yAxisLabelAscent;

        chartGraphics.setFont(axisLabelsFont);
        chartGraphics.setColor(axisLabelColour);

        // Create 270 degree rotated transform.
        AffineTransform transform = chartGraphics.getTransform();
        AffineTransform originalTransform = (AffineTransform) transform.clone();
        transform.rotate(Math.toRadians(270), xPosYAxisLabel, yPosYAxisLabel);
        chartGraphics.setTransform(transform);

        // Draw string.
        chartGraphics.drawString(yAxisLabel, xPosYAxisLabel, yPosYAxisLabel);

        // Revert to original transform before rotation.
        chartGraphics.setTransform(originalTransform);
    }
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:23,代码来源:HeatChart.java

示例15: getItalicAngle

import java.awt.geom.AffineTransform; //导入依赖的package包/类
public float getItalicAngle(Font font, AffineTransform at,
                            Object aaHint, Object fmHint) {
    /* hardwire psz=12 as that's typical and AA vs non-AA for 'gasp' mode
     * isn't important for the caret slope of this rarely used API.
     */
    int aa = FontStrikeDesc.getAAHintIntVal(aaHint, this, 12);
    int fm = FontStrikeDesc.getFMHintIntVal(fmHint);
    FontStrike strike = getStrike(font, at, aa, fm);
    StrikeMetrics metrics = strike.getFontMetrics();
    if (metrics.ascentY == 0 || metrics.ascentX == 0) {
        return 0f;
    } else {
        /* ascent is "up" from the baseline so its typically
         * a negative value, so we need to compensate
         */
        return metrics.ascentX/-metrics.ascentY;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:Font2D.java


注:本文中的java.awt.geom.AffineTransform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。