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


Java Graphics2D.getTransform方法代码示例

本文整理汇总了Java中java.awt.Graphics2D.getTransform方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.getTransform方法的具体用法?Java Graphics2D.getTransform怎么用?Java Graphics2D.getTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics2D的用法示例。


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

示例1: paintComponent

import java.awt.Graphics2D; //导入方法依赖的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.Graphics2D; //导入方法依赖的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: draw

import java.awt.Graphics2D; //导入方法依赖的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

示例4: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics g, int x, int y, Component obs, double zoom) {
    updateCachedImage();
    piece.draw(g, x, y, obs, zoom);

// FIXME: We should be drawing the text at the right size, not scaling it!
    final Point p = getLabelPosition();
    final int labelX = x + (int) (zoom * p.x);
    final int labelY = y + (int) (zoom * p.y);

    AffineTransform saveXForm = null;
    final Graphics2D g2d = (Graphics2D) g;

    if (rotateDegrees != 0) {
      saveXForm = g2d.getTransform();
      final AffineTransform newXForm = AffineTransform.getRotateInstance(
        Math.toRadians(rotateDegrees), x, y);
      g2d.transform(newXForm);
    }

    imagePainter.draw(g, labelX, labelY, zoom, obs);

    if (rotateDegrees != 0) {
      g2d.setTransform(saveXForm);
    }
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:Labeler.java

示例5: fillShape

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void fillShape(final Graphics2D g, final Shape shape) {
  if (shape == null) {
    return;
  }

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

  g.setTransform(t);
  g.fill(shape);
  g.setTransform(oldTransForm);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:15,代码来源:RenderEngine.java

示例6: drawCurrentSeg

import java.awt.Graphics2D; //导入方法依赖的package包/类
protected void drawCurrentSeg(Graphics2D g, boolean on) {
		if( currentSeg==null ) return;
		Color color = g.getColor();
		Stroke stroke = g.getStroke();
		AffineTransform at = g.getTransform();
		g.setColor( on ? ON_COLOR : OFF_COLOR );

//		***** GMA 1.5.2: TESTING
//		g.setStroke( new BasicStroke( 1f/ (float)map.getZoom()) );
		g.setStroke( new BasicStroke( 5f/ (float)map.getZoom()) );
//		***** GMA 1.5.2

		double wrap = map.getWrap();
		if( wrap>0. ) {
			g.translate(-wrap, 0.);
			g.draw( currentSeg );
			g.translate(wrap, 0.);
			g.draw( currentSeg );
			g.translate(wrap, 0.);
			g.draw( currentSeg );
		} else {
			g.draw( currentSeg );
		}
		g.setColor(color);
		g.setStroke(stroke);
		g.setTransform( at);
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:28,代码来源:MGGData.java

示例7: drawStaticEllipses

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawStaticEllipses(Graphics2D g2d) {
	AffineTransform old = g2d.getTransform();
	// -----------------------------------------//
	ArrayList<Ellipse> staticEllipses = mImg.getEllipseStatic();
	if (staticEllipses == null)
		return;
	int i = 0;
	for (Ellipse e : staticEllipses) {
		e = e.offset(minX, minY);
		BasicStroke bs = UniversalTool.getPreferableStroke(Math.max(e.major, e.minor) * 2);

		// do rotation
		g2d.rotate(e.angle, e.x, e.y);
		// draw elps

		Ellipse2D.Double ed = e.getErectedEllipse2D();
		if(i == highlightedStaticEllipseIdx){
			g2d.setColor(Color.CYAN);
		}else{
			g2d.setColor(Color.black);
		}
		
		g2d.setStroke(bs);
		g2d.draw(ed);

		g2d.setColor(Color.yellow);
		g2d.setStroke(new BasicStroke(bs.getLineWidth() / 2));

		g2d.draw(ed);

		// reset transform
		g2d.setTransform(old);
		i++;
	}
}
 
开发者ID:Microos,项目名称:FaceAnnotationTool,代码行数:36,代码来源:MyImagePanel.java

示例8: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override public void paint(Graphics2D g2) {
  if (this.isShowing) {
    //g2.setFont(new Font(fontName, Font.PLAIN, fontSize));
    g2.setFont(  dFont.deriveFont( (float) fontSize) ); 
    g2.setColor(color);
    // only print if the message has visible characters.
    if (msg.trim().length() > 0) {
      AffineTransform tmp = g2.getTransform();
      g2.setTransform(EZElement.transformHelper(this));
      g2.drawString(msg, -getWidth() / 2, getHeight() / 3);
      g2.setTransform(tmp);
    }
  }
}
 
开发者ID:gcalica,项目名称:agar.io,代码行数:15,代码来源:EZ.java

示例9: paintIcon

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintIcon(Component comp, Graphics g, int x, int y)
{
    Graphics2D g2 = (Graphics2D) g;
    AffineTransform savedTransform = g2.getTransform(); // save current
    displayObj.draw(null, comp, g2, new Rectangle(x, y, getIconWidth(),
            getIconHeight()));
    g2.setTransform(savedTransform); // restore coordinate system
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:9,代码来源:DisplayMap.java

示例10: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
	Rectangle area = g.getClipBounds();
	currentPoint = null;
	if( !intersects(area) ) return;
	Color color = g.getColor();
	g.setColor( OFF_COLOR );
	GeneralPath path = new GeneralPath();
	float offset = (float)this.offset;
	for( int seg=0 ; seg<cptIndex.length ; seg++ ) {
		path.moveTo( offset+cptX[seg][0], cptY[seg][0] );
		for( int i=0 ; i<cptIndex[seg].length ; i++ ) {
			path.lineTo( offset+cptX[seg][i], cptY[seg][i] );
		}
	}
	g.draw(path);
	double wrap = map.getWrap();
	if(wrap>0) {
		AffineTransform xform = g.getTransform();
		offset += (float)wrap;
		while( mapBounds.getX()+(double)offset < area.getX()+area.getWidth() ) {
			g.translate( (double)wrap, 0.d );
			g.draw(path);
			offset += (float)wrap;
		}
		g.setTransform( xform );
	}
	g.setColor( ON_COLOR );
	drawCurrentSeg(g, true);
	g.setColor( color );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:31,代码来源:MGGData.java

示例11: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics2D g, AffineTransform aTrans, Rectangle2D bounds) {
	AffineTransform at0 = g.getTransform();
	g.transform( aTrans );
	g.translate( x, y );
	g.scale( scale, scale );
	g.drawRenderedImage( image, new AffineTransform() );
	g.setTransform( at0 );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:9,代码来源:ImageLayer.java

示例12: tlDrawLine

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void tlDrawLine( Graphics2D g2, TextLayout tl,
                                   float baseX, float baseY ) {
    /// ABP - keep track of old tform, restore it later
    AffineTransform oldTx = null;
    oldTx = g2.getTransform();
    g2.translate( baseX, baseY );
    g2.transform( getAffineTransform( g2Transform ) );

    tl.draw( g2, (float) 0, (float) 0 );

    /// ABP - restore old tform
    g2.setTransform ( oldTx );

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:FontPanel.java

示例13: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw( Graphics2D g ) {
	if( image==null )return;
	AffineTransform at = g.getTransform();
	g.translate( x0, y0 );
	g.scale( scale, scale );
	g.drawRenderedImage(image, new AffineTransform() );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:MapImage.java

示例14: printDescription

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws description for each axis.
 * 
 * @param g
 *            The {@link Graphics} object.
 */
private void printDescription(Graphics g) {
    String text = chart.getxDescription();
    FontMetrics fm = g.getFontMetrics();
    int width = getTextWidth(text, g);

    // Draws description for x-axis
    g.setColor(Color.black);
    g.drawString(text, rect.x + (rect.width - width) / 2, rect.height
            - SPACE);

    // Draws description for y-axis
    Graphics2D g2d = (Graphics2D) g.create();
    AffineTransform defaultAt = g2d.getTransform();
    AffineTransform at = new AffineTransform();
    at.rotate(3 * Math.PI / 2);

    g2d.setTransform(at);
    g2d.setColor(Color.black);

    text = chart.getyDescription();
    width = fm.stringWidth(text);

    g2d.drawString(text,
            -(rect.y + (rect.height + width * 2 + SPACE) / 2 - yPoint),
            SPACE * 2);
    g2d.setTransform(defaultAt);
    g2d.dispose();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:35,代码来源:BarChartComponent.java

示例15: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics2D g) {
//	if(!display) return;
int yr1 = 1900;
int yr2 = 2005;
try {
	long[] interval = timeInterval();
	Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
	if( db.before.isSelected() ) {
			cal.setTimeInMillis(interval[0]);
			yr1 = cal.get(cal.YEAR);
	}
	if( db.after.isSelected() ) {
		cal.setTimeInMillis(interval[1]);
		yr2 = cal.get(cal.YEAR);
	}
} catch(Exception e) {
}
//	System.out.println( yr1 +"\t"+ yr2);
	float size = 2.0f + 6f/(float)map.getZoom();
	Arc2D.Float dot = new Arc2D.Float(-size/2f, -size/2f, size, size, 0f, 360f, Arc2D.CHORD);
	float size1 = 2.0f + 7f/(float)map.getZoom();
	GeneralPath triangle = new GeneralPath();
	triangle.moveTo(0f, size1/2f );
	triangle.lineTo(size1/2f, -size1/2f );
	triangle.lineTo(-size1/2f, -size1/2f );
	triangle.closePath();
//	Rectangle2D.Float square = new Rectangle2D.Float(-size1/2f, -size1/2f, size1, size1);
	AffineTransform at = g.getTransform();
	g.setStroke( new BasicStroke( .5f/(float)map.getZoom() ) );
	RenderingHints hints = g.getRenderingHints();
	g.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,
			RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);

	Shape shape = dot;
	for(int k=0 ; k<xyd.length ; k++) {
	//	Shape shape = triangle;
	//	if( xyd[k][5]<=1991f ) shape = dot;
		if( xyd[k][5]>yr2 )continue;
		if( xyd[k][5]<yr1 )continue;
		g.translate( (double)xyd[k][0], (double)xyd[k][1] );
	//	g.setColor( Color.black );
	//	g.draw(shape);
		g.setColor( color[k] );
		g.fill(shape);
		g.setColor( Color.black );
		g.draw(shape);
		g.setTransform( at );
	}
	g.setFont( (new Font("Serif", Font.BOLD, 1)).deriveFont( size1*1.5f));
	Rectangle2D rect = map.getClipRect2D();
	double s = (double) size1;
	double x = rect.getX() + s;
	double y = rect.getY() + 2.*s;
//	g.translate( x, y );
//	g.setColor( Color.white );
//	g.fill( dot );
//	g.setColor( Color.black );
//	g.draw( dot );
//	g.translate( s, s/2.);
//	String year = db.startF.getText();
//	String dateString = db.before.isSelected()
//		? "before 1/1/"+year
//		: "after 1/1/"+year;
//	g.drawString( dateString, 0, 0);
//	g.drawString( "before 1/1/1991", 0, 0);
//	g.setTransform(at);
//	g.translate( x, y+s*2.0 );
//	g.setColor( Color.white );
//	g.fill( triangle );
//	g.setColor( Color.black );
//	g.draw( triangle );
//	g.translate( s, s/2.);
//	g.drawString( "after 1/1/1991", 0, 0);
	g.setTransform(at);
	g.setRenderingHints( hints);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:79,代码来源:D18oObservations.java


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