當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。