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


Java Graphics2D.setTransform方法代码示例

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


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

示例1: drawShape

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

  final AffineTransform oldTransForm = g.getTransform();
  final Stroke oldStroke = g.getStroke();
  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.setStroke(stroke);
  g.draw(shape);
  g.setTransform(oldTransForm);
  g.setStroke(oldStroke);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:18,代码来源:RenderEngine.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: paintGraph

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Paints the graph outline.
 */
public void paintGraph(Graphics g)
{
	if (graphComponent != null)
	{
		Graphics2D g2 = (Graphics2D) g;
		AffineTransform tx = g2.getTransform();

		try
		{
			Point tr = graphComponent.getGraphControl().getTranslate();
			g2.translate(translate.x + tr.getX() * scale,
					translate.y + tr.getY() * scale);
			g2.scale(scale, scale);

			// Draws the scaled graph
			graphComponent.getGraphControl().drawGraph(g2, drawLabels);
		}
		finally
		{
			g2.setTransform(tx);
		}
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:27,代码来源:mxGraphOutline.java

示例4: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** Provides the painting logic.  Note that this does not call any of the
 * painting methods of BasicToggleButtonUI */
@Override
public final void paint(Graphics g, JComponent c) {
    
    BasicSlidingTabDisplayerUI.IndexButton b = 
        (BasicSlidingTabDisplayerUI.IndexButton) c;
    
    Graphics2D g2d = (Graphics2D) g;
    
    paintBackground (g2d, b);
    
    Object orientation = b.getOrientation();
    
    AffineTransform tr = g2d.getTransform();
    if (orientation == TabDisplayer.ORIENTATION_EAST) {
         g2d.rotate( Math.PI / 2 ); 
         g2d.translate( 0, - c.getWidth() );
    } else if (orientation == TabDisplayer.ORIENTATION_WEST) {
         g2d.rotate(-Math.PI / 2); 
         g2d.translate(-c.getHeight(), 0);
    }

    paintIconAndText (g2d, b, orientation);
    g2d.setTransform (tr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SlidingTabDisplayerButtonUI.java

示例5: 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

示例6: 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

示例7: mouseMoved

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
	if(graphics !=null ){
		LinkedPanel panel = (LinkedPanel) e.getComponent();
		Graphics2D g = (Graphics2D) panel.getGraphics();
		g.setTransform(panel.getTransform());
		
		float timeOffset = LayerUtilities.pixelsToUnits(g, e.getX(), true);
		float time = cs.getMin(Axis.X) + timeOffset;
		float frequencyOffset = LayerUtilities.pixelsToUnits(g, panel.getHeight() - e.getY(), false);
		float frequency = cs.getMin(Axis.Y) + frequencyOffset;
		
		float timeDiameter = LayerUtilities.pixelsToUnits(g, 10, true) * 2f;
		float frequencyDiameter = LayerUtilities.pixelsToUnits(g, 10, false)* 2f;
		
	}
	
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:19,代码来源:QIFFTAudioInfoLayer.java

示例8: 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

示例9: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    double direction = this.node.getDirection();
    if (direction != Math.PI / 2) {
        AffineTransform newXform = g2d.getTransform();
        newXform.rotate(direction + Math.PI / 2, drawSize, drawSize);
        g2d.setTransform(newXform);
    }
    g2d.drawImage(scaledIcon, 0, 0, null);
    JTopology jTopology = (JTopology) this.getParent();
    for (NodePainter painter : jTopology.nodePainters)
        painter.paintNode(g2d, node);
}
 
开发者ID:acasteigts,项目名称:JBotSim,代码行数:14,代码来源:JNode.java

示例10: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** This method is called by Swing to draw this component. */
@Override public void paintComponent(final Graphics gr) {
    super.paintComponent(gr);
    Graphics2D g2 = (Graphics2D)gr;
    AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.scale(scale, scale);
    Object sel=(selected!=null ? selected : highlight);
    GraphNode c=null;
    if (sel instanceof GraphNode && ((GraphNode)sel).shape()==null) { c = (GraphNode)sel; sel = c.ins.get(0); }
    graph.draw(new Artist(g2), scale, sel, true);
    if (c!=null) { gr.setColor(((GraphEdge)sel).color()); gr.fillArc(c.x()-5-graph.getLeft(), c.y()-5-graph.getTop(), 10, 10, 0, 360); }
    g2.setTransform(oldAF);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:GraphViewer.java

示例11: 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 ? onColor : offColor );

//		***** 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,代码来源:ShipData.java

示例12: testTransformedFont

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void testTransformedFont(AffineTransform a, Object textHint) {
    BufferedImage bi = new BufferedImage(200, 200,
                               BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = (Graphics2D) bi.getGraphics();
    g2.setFont(g2.getFont().deriveFont(12.0f));
    g2.setTransform(a);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textHint);
    g2.drawString("test", 100, 100);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TestTransform.java

示例13: 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

示例14: 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

示例15: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override public void paint(Graphics defaultGraphics) {
	super.paint(defaultGraphics);
	Graphics2D graphics = prepareGraphics(defaultGraphics);
	AffineTransform transform = graphics.getTransform();
	graphics.transform(this.transform);

	paint = System.currentTimeMillis();
	if(isGridVisible())
		paintGrid(graphics, super.getPreferredSize());

	List<Component> components = new ArrayList<Component>(getAllComponents());
	if(dragComponents!=null)
		components.removeAll(dragComponents);
	paintComponents(graphics, components, dragWires);
	if(selectWire!=null) {
		graphics.setColor(SELECTION);
		graphics.fill(selectWire.getSelectionArea());
	} else if(selectComponent==null)
		paintSelection(graphics);
	if(dragContact!=null&&dragContact.isWired())
		dragContact.getWire().paint(graphics);
	if(dragComponents!=null) {
		Point point = invertPoint(addPoints(select, invertPoint(current)));
		graphics.drawImage(dragImage, point.x, point.y, null);
		if(dragWires!=null) for(Wire dragWire:dragWires) {
			if(dragComponents.contains(dragWire.getSource().getComponent()))
				dragWire.paint(graphics, point);
			else if(dragComponents.contains(dragWire.getTarget().getComponent()))
				dragWire.paint(graphics, null, point);
		}
	}

	graphics.setTransform(transform);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:35,代码来源:Simulation.java


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