本文整理汇总了Java中edu.umd.cs.piccolo.util.PPaintContext类的典型用法代码示例。如果您正苦于以下问题:Java PPaintContext类的具体用法?Java PPaintContext怎么用?Java PPaintContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PPaintContext类属于edu.umd.cs.piccolo.util包,在下文中一共展示了PPaintContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullPaint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
public void fullPaint( PPaintContext paintContext ) {
Graphics2D g = paintContext.getGraphics();
Object origAnt = g.getRenderingHint( RenderingHints.KEY_ANTIALIASING );
Object origInt = g.getRenderingHint( RenderingHints.KEY_INTERPOLATION );
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR );
super.fullPaint( paintContext );
if( origAnt == null ) {
origAnt = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
}
if( origInt == null ) {
origInt = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
}
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, origAnt );
g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, origInt );
}
示例2: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
protected void paint( PPaintContext paintContext ) {
super.paint( paintContext );
Collection paths = _pathMap.values();
if ( paths != null && paths.size() != 0 ) {
Graphics2D g2 = paintContext.getGraphics();
Color saveColor = g2.getColor();
Stroke saveStroke = g2.getStroke();
g2.setColor( TRACE_COLOR );
g2.setStroke( TRACE_STROKE );
Iterator i = paths.iterator();
while ( i.hasNext() ) {
GeneralPath path = (GeneralPath) i.next();
g2.draw( path );
}
g2.setColor( saveColor );
g2.setStroke( saveStroke );
}
}
示例3: createYLineNode
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
private PNode createYLineNode( double minX, double maxX, double y ) {
PPath child = new PPath( new Line2D.Double( minX, y, maxX, y ) ) {
//Use low quality rendering to improve performance when grid is turned on
@Override protected void paint( PPaintContext paintContext ) {
int renderQuality = paintContext.getRenderQuality();
paintContext.setRenderQuality( PPaintContext.LOW_QUALITY_RENDERING );
super.paint( paintContext );
paintContext.setRenderQuality( renderQuality );
}
};
boolean thickStroke = MathUtil.isApproxEqual( y, 0, 0.001 );
//On 11/29/2011 It was requested to make every other line thick instead of every 5 lines.
if ( (int) y % 2 == 0 ) {
thickStroke = true;
}
child.setStroke( new BasicStroke( 0.01f * ( thickStroke ? 3 : 1 ) ) );
return child;
}
示例4: createIcon
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
private BufferedImage createIcon( EnergySkateParkBasicsModule module, String location, Vector2D offset ) {
//To create the icon, load the module and render it to an image
module.loadTrack( location, offset );
BufferedImage icon = new BufferedImage( 1024, 768, BufferedImage.TYPE_INT_RGB );
Graphics2D g2 = icon.createGraphics();
module.getEnergySkateParkSimulationPanel().setSize( 1024, 768 );
//Have to call update background since the size changed without the background changing
module.getEnergySkateParkSimulationPanel().getRootNode().updateBackground();
//Render into the image
module.getEnergySkateParkSimulationPanel().getRootNode().fullPaint( new PPaintContext( g2 ) );
//Resize to a small icon size using multi-scaling so the quality will be high
return BufferedImageUtils.multiScaleToWidth( icon, 100 );
}
示例5: fullPaint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
public void fullPaint( PPaintContext paintContext ) {
Graphics2D g = paintContext.getGraphics();
Object origAnt = g.getRenderingHint( RenderingHints.KEY_ANTIALIASING );
Object origInt = g.getRenderingHint( RenderingHints.KEY_INTERPOLATION );
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR );
super.fullPaint( paintContext );
if ( origAnt == null ) {
origAnt = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
}
if ( origInt == null ) {
origInt = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
}
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, origAnt );
g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, origInt );
}
示例6: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* WORKAROUND for Gradient Paint bug on Mac OS 10.4.
* With the default rendering value (VALUE_RENDER_QUALITY), gradient paints will crash.
* Using VALUE_RENDER_SPEED avoids the problem.
*/
protected void paint( PPaintContext paintContext ) {
if ( IS_MAC_OS_10_4 ) {
boolean usesGradient = ( ( getPaint() instanceof GradientPaint ) || ( getStrokePaint() instanceof GradientPaint ) );
if ( usesGradient ) {
Object saveValueRender = paintContext.getGraphics().getRenderingHint( RenderingHints.KEY_RENDERING );
paintContext.getGraphics().setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
super.paint( paintContext );
if ( saveValueRender != null ) {
paintContext.getGraphics().setRenderingHint( RenderingHints.KEY_RENDERING, saveValueRender );
}
}
else {
super.paint( paintContext );
}
}
else {
super.paint( paintContext );
}
}
示例7: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
protected void paint( PPaintContext paintContext ) {
if ( rescaledImage != null ) {
Rectangle2D bounds = getGlobalFullBounds();
canvas.getPhetRootNode().globalToScreen( bounds );
int desiredWidth = (int) bounds.getWidth();
// System.out.println( "desiredWidth = " + desiredWidth + ", bounds.width=" + ( (int) bounds.getWidth() ) );
if ( desiredWidth != rescaledImage.getWidth() ) {
updateImage( desiredWidth );
}
Graphics2D g2 = paintContext.getGraphics();
AffineTransform originalTransform = g2.getTransform();
// System.out.println( "canvas.getG2().getTransform() = " + canvas.getAffineTransform() );
g2.setTransform( canvas.getTransform() );
g2.drawRenderedImage( rescaledImage, AffineTransform.getTranslateInstance( bounds.getX(), bounds.getY() ) );
g2.setTransform( originalTransform );
}
}
示例8: main
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
public static void main( String[] args ) {
PCanvas pCanvas = new PCanvas();
pCanvas.setPanEventHandler( null );
final PText pText = new PText( "Testing Piccolo Rendering" );
pText.setFont( new PhetFont( Font.BOLD, 32 ) );
pText.setOffset( 22.96045684814453, 19.954608917236328 );
pCanvas.getLayer().addChild( pText );
PPath path = new PPath( new Rectangle( 50, 50 ) );
path.setPaint( new Color( 0, 0, 0, 0 ) );
path.addInputEventListener( new PDragEventHandler() );
pCanvas.getLayer().addChild( path );
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setContentPane( pCanvas );
frame.setSize( 400, 600 );
frame.setVisible( true );
pCanvas.setDefaultRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
pCanvas.setInteractingRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
pCanvas.setAnimatingRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
}
示例9: main
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
public static void main( String[] args ) {
JFrame frame = new JFrame();
PCanvas pCanvas = new PCanvas();
PPath tabNode = new PPath( new Rectangle( 20, 20 ) ) {
protected void paint( PPaintContext paintContext ) {
Object orig = paintContext.getGraphics().getRenderingHint( RenderingHints.KEY_RENDERING );
paintContext.getGraphics().setRenderingHint( RenderingHints.KEY_RENDERING, VALUE_RENDER );
super.paint( paintContext );
if ( orig != null ) {
paintContext.getGraphics().setRenderingHint( RenderingHints.KEY_RENDERING, orig );
}
}
};
tabNode.setPaint( new GradientPaint( 0, 0, Color.blue, 0, 10, Color.blue ) );
pCanvas.getLayer().addChild( tabNode );
frame.setContentPane( pCanvas );
frame.setSize( 200, 200 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible( true );
}
示例10: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
protected void paint(PPaintContext paintContext) {
Graphics2D g2 = paintContext.getGraphics();
g2.setPaint(getPaint());
g2.draw(getBoundsReference());
g2.setFont(CalendarNode.DEFAULT_FONT);
float y = (float) getY() + CalendarNode.TEXT_Y_OFFSET;
paintContext.getGraphics().drawString(dayOfMonthString,
(float) getX() + CalendarNode.TEXT_X_OFFSET, y);
if (hasWidthFocus && hasHeightFocus) {
paintContext.pushClip(getBoundsReference());
for (int i = 0; i < lines.size(); i++) {
y += 10;
g2.drawString((String) lines.get(i),
(float) getX() + CalendarNode.TEXT_X_OFFSET, y);
}
paintContext.popClip(getBoundsReference());
}
}
示例11: PSWTCanvas
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Construct a canvas with the basic scene graph consisting of a root,
* camera, and layer. Event handlers for zooming and panning are
* automatically installed.
*
* @param parent component onto which the canvas is installed
* @param style component style for the PSWTCanvas
*/
public PSWTCanvas(final Composite parent, final int style) {
super(parent, style | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
CURRENT_CANVAS = this;
cursorStack = new PStack();
setCamera(createBasicSceneGraph());
installInputSources();
setDefaultRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
setAnimatingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
setInteractingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
panEventHandler = new PPanEventHandler();
zoomEventHandler = new PZoomEventHandler();
addInputEventListener(panEventHandler);
addInputEventListener(zoomEventHandler);
installPaintListener();
installDisposeListener();
}
示例12: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Paints the path on the context provided.
*
* @param paintContext the context onto which the path will be painted
*/
protected void paint(final PPaintContext paintContext) {
final Paint p = getPaint();
final SWTGraphics2D g2 = (SWTGraphics2D) paintContext.getGraphics();
if (internalXForm != null) {
g2.transform(internalXForm);
}
if (p != null) {
g2.setBackground((Color) p);
fillShape(g2);
}
if (strokePaint != null) {
g2.setColor((Color) strokePaint);
drawShape(g2);
}
if (inverseXForm != null) {
g2.transform(inverseXForm);
}
}
示例13: initializeMarquee
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void initializeMarquee(final PInputEvent e) {
super.initializeMarquee(e);
marquee = new PSWTPath(new Rectangle2D.Float((float) pressPt.getX(), (float) pressPt.getY(), 0, 0)) {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void paint(final PPaintContext paintContext) {
final SWTGraphics2D s2g = (SWTGraphics2D) paintContext.getGraphics();
s2g.gc.setLineStyle(SWT.LINE_DASH);
super.paint(paintContext);
s2g.gc.setLineStyle(SWT.LINE_SOLID);
}
};
marquee.setStrokeColor(Color.black);
marquee.setPaint(null);
marqueeParent.addChild(marquee);
}
示例14: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Paints the PSwing on the specified renderContext. Also determines if
* the Swing component should be rendered normally or as a filled rectangle (greeking).
* <p/>
* The transform, clip, and composite will be set appropriately when this
* object is rendered. It is up to this object to restore the transform,
* clip, and composite of the Graphics2D if this node changes any of them.
* However, the color, font, and stroke are unspecified by Piccolo. This
* object should set those things if they are used, but they do not need to
* be restored.
*
* @param renderContext Contains information about current render.
*/
public void paint(final PPaintContext renderContext) {
if (componentNeedsResizing()) {
updateComponentSize();
component.validate();
}
final Graphics2D g2 = renderContext.getGraphics();
//Save Stroke and Font for restoring.
Stroke originalStroke = g2.getStroke();
Font originalFont = g2.getFont();
g2.setStroke(defaultStroke);
g2.setFont(DEFAULT_FONT);
if (shouldRenderGreek(renderContext)) {
paintAsGreek(g2);
}
else {
paint(g2);
}
//Restore the stroke and font on the Graphics2D
g2.setStroke(originalStroke);
g2.setFont(originalFont);
}
示例15: fullPaint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Overrides the camera's full paint method to do the fast rendering when
* possible.
*
* @param paintContext Paint Contex in which the painting is done
*/
public void fullPaint(final PPaintContext paintContext) {
if (imageAnimate) {
final PBounds fRef = getFullBoundsReference();
final PBounds viewBounds = getViewBounds();
final double scale = getFullBoundsReference().getWidth() / imageAnimateBounds.getWidth();
final double xOffset = (viewBounds.getX() - imageAnimateBounds.getX()) * scale;
final double yOffset = (viewBounds.getY() - imageAnimateBounds.getY()) * scale;
final double scaleW = viewBounds.getWidth() * scale;
final double scaleH = viewBounds.getHeight() * scale;
paintContext.getGraphics().drawImage(paintBuffer, 0, 0, (int) Math.ceil(fRef.getWidth()),
(int) Math.ceil(fRef.getHeight()), (int) Math.floor(xOffset), (int) Math.floor(yOffset),
(int) Math.ceil(xOffset + scaleW), (int) Math.ceil(yOffset + scaleH), null);
}
else {
super.fullPaint(paintContext);
}
}