本文整理汇总了Java中edu.umd.cs.piccolo.util.PPaintContext类的典型用法代码示例。如果您正苦于以下问题:Java PPaintContext类的具体用法?Java PPaintContext怎么用?Java PPaintContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PPaintContext类属于edu.umd.cs.piccolo.util包,在下文中一共展示了PPaintContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:SimpleWavefunctionGraphic.java
示例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 );
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:TracesNode.java
示例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;
}
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:GridNode.java
示例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 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:TrackButton.java
示例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 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:WaveModelGraphic.java
示例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 );
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:PhetPPath.java
示例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 );
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:BufferedPNode.java
示例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 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:TestPiccoloRendering.java
示例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 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:TestTabGraphic.java
示例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());
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:DayNode.java
示例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();
}
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:PSWTCanvas.java
示例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);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:PSWTPath.java
示例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);
}
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:PSWTSelectionEventHandler.java
示例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);
}
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:PSwing.java
示例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);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:PCacheCamera.java
示例16: getActiveScale
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Detect the current scale. Made protected to enable custom
* re-implementations.
*/
protected float getActiveScale() {
// FIXME Honestly I don't understand this distinction - shouldn't it
// always be PPaintContext.CURRENT_PAINT_CONTEXT regardless of the
// debugging flag?
if (PDebug.getProcessingOutput()) {
if (PPaintContext.CURRENT_PAINT_CONTEXT != null) {
return (float) PPaintContext.CURRENT_PAINT_CONTEXT.getScale();
}
}
else {
if (PPickPath.CURRENT_PICK_PATH != null) {
return (float) PPickPath.CURRENT_PICK_PATH.getScale();
}
}
return 1.0f;
}
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:PSemanticStroke.java
示例17: testPaintTooSmallPaintsGreek
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
public void testPaintTooSmallPaintsGreek() {
final JPanel panel = new JPanel();
panel.setBounds(0, 0, 100, 100);
final MockPaintingPSwing pSwing = new MockPaintingPSwing(panel);
BufferedImage image = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
graphics.setTransform(AffineTransform.getScaleInstance(0.01, 0.01));
PPaintContext paintContext = new PPaintContext(graphics);
pSwing.paint(paintContext);
assertTrue(pSwing.isPaintedGreek());
assertFalse(pSwing.isPaintedComponent());
}
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:PSwingTest.java
示例18: fullPaint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Paint this node and all of its descendants. Most subclasses do not need
* to override this method, they should override <code>paint</code> or
* <code>paintAfterChildren</code> instead.
*
* @param paintContext the paint context to use for painting this node and
* its children
*/
public void fullPaint(final PPaintContext paintContext) {
if (getVisible() && fullIntersects(paintContext.getLocalClip())) {
paintContext.pushTransform(transform);
paintContext.pushTransparency(transparency);
if (!getOccluded()) {
paint(paintContext);
}
final int count = getChildrenCount();
for (int i = 0; i < count; i++) {
final PNode each = (PNode) children.get(i);
each.fullPaint(paintContext);
}
paintAfterChildren(paintContext);
paintContext.popTransparency(transparency);
paintContext.popTransform(transform);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:PNode.java
示例19: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Paints the path in the provided paintContext. Can perform very
* differently depending on whether the path is being drawn using its stroke
* or its paint.
*
* It both are provided to the path, fun ensues.
*
* @param paintContext context in which painting is occurring
*/
protected void paint(final PPaintContext paintContext) {
final Paint p = getPaint();
final Graphics2D g2 = paintContext.getGraphics();
if (p != null) {
g2.setPaint(p);
g2.fill(path);
}
if (stroke != null && strokePaint != null) {
g2.setPaint(strokePaint);
g2.setStroke(stroke);
g2.draw(path);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:PPath.java
示例20: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入依赖的package包/类
/**
* Renders the wrapped Image, stretching it appropriately if the bounds of
* this PImage doesn't match the bounds of the image.
*
* @param paintContext context into which the rendering will occur
*/
protected void paint(final PPaintContext paintContext) {
if (getImage() == null) {
return;
}
final double iw = image.getWidth(null);
final double ih = image.getHeight(null);
final PBounds b = getBoundsReference();
final Graphics2D g2 = paintContext.getGraphics();
if (b.x != 0 || b.y != 0 || b.width != iw || b.height != ih) {
g2.translate(b.x, b.y);
g2.scale(b.width / iw, b.height / ih);
g2.drawImage(image, 0, 0, null);
g2.scale(iw / b.width, ih / b.height);
g2.translate(-b.x, -b.y);
}
else {
g2.drawImage(image, 0, 0, null);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:PImage.java
注:本文中的edu.umd.cs.piccolo.util.PPaintContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论