本文整理汇总了Java中edu.umd.cs.piccolo.util.PPaintContext.getGraphics方法的典型用法代码示例。如果您正苦于以下问题:Java PPaintContext.getGraphics方法的具体用法?Java PPaintContext.getGraphics怎么用?Java PPaintContext.getGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.util.PPaintContext
的用法示例。
在下文中一共展示了PPaintContext.getGraphics方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
protected void paint( PPaintContext paintContext ) {
Graphics2D g2 = paintContext.getGraphics();
if ( _renderingHints != null ) {
g2.setRenderingHints( _renderingHints );
}
// Clip to the data area
Shape restoreClip = g2.getClip();
g2.setClip( _dataArea );
// Draw the markers...
int numberOfRenderers = _plot.getDatasetCount();
for ( int i = 0; i < numberOfRenderers; i++ ) {
_plot.drawDomainMarkers( g2, _dataArea, i, Layer.BACKGROUND );
_plot.drawDomainMarkers( g2, _dataArea, i, Layer.FOREGROUND );
}
for ( int i = 0; i < numberOfRenderers; i++ ) {
_plot.drawRangeMarkers( g2, _dataArea, i, Layer.BACKGROUND );
_plot.drawRangeMarkers( g2, _dataArea, i, Layer.FOREGROUND );
}
// restore the clip
g2.setClip( restoreClip );
}
示例2: 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);
}
示例3: 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 );
}
示例4: 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 );
}
}
示例5: 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);
}
}
示例6: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void paint(final PPaintContext paintContext) {
if (getImage() != null) {
final Rectangle r = image.getBounds();
final PBounds b = getBoundsReference();
final SWTGraphics2D g2 = (SWTGraphics2D) paintContext.getGraphics();
if (b.x == 0 && b.y == 0 && b.width == r.width && b.height == r.height) {
g2.drawImage(image, 0, 0);
}
else {
g2.translate(b.x, b.y);
g2.scale(b.width / r.width, b.height / r.height);
g2.drawImage(image, 0, 0);
g2.scale(r.width / b.width, r.height / b.height);
g2.translate(-b.x, -b.y);
}
}
}
示例7: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
* Paints the PLine in the provided context if it has both a stroke and a
* stroke paint assigned.
*
* @param paintContext the context into which the line should be drawn
*/
protected void paint(final PPaintContext paintContext) {
final Graphics2D g2 = paintContext.getGraphics();
if (stroke != null && strokePaint != null) {
g2.setPaint(strokePaint);
g2.setStroke(stroke);
g2.draw(lineShape);
}
}
示例8: fullPaint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
* Repaints this node, using the cached result if possible.
*
* @param paintContext context in which painting should occur
*/
public void fullPaint(final PPaintContext paintContext) {
if (validatingCache) {
super.fullPaint(paintContext);
}
else {
final Graphics2D g2 = paintContext.getGraphics();
g2.drawImage(getImageCache(), (int) getX(), (int) getY(), null);
}
}
示例9: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
* Renders the text object.
* <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 Jazz. This object
* should set those things if they are used, but they do not need to be
* restored.
*
* @param ppc Contains information about current render.
*/
public void paint(final PPaintContext ppc) {
if (lines.isEmpty()) {
return;
}
final Graphics2D g2 = ppc.getGraphics();
AffineTransform at = null;
boolean translated = false;
if (translateX != 0.0 || translateY != 0.0) {
at = g2.getTransform();
g2.translate(translateX, translateY);
translated = true;
}
final double renderedFontSize = font.getSize() * ppc.getScale();
// If font is too small then render it as "greek"
if (renderedFontSize < greekThreshold) {
paintAsGreek(ppc);
}
else {
paintAsText(ppc);
}
if (translated) {
g2.setTransform(at);
}
}
示例10: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
* Paint's this node as a solid rectangle if paint is provided, clipping
* appropriately.
*
* @param paintContext context into which this node will be painted
*/
protected void paint(final PPaintContext paintContext) {
final Paint p = getPaint();
if (p != null) {
final Graphics2D g2 = paintContext.getGraphics();
g2.setPaint(p);
g2.fill(getPathReference());
}
paintContext.pushClip(getPathReference());
}
示例11: paintBuffered
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
private void paintBuffered( PPaintContext paintContext ) {
Rectangle2D bounds = getBoundsReference();
if ( _chartImage == null ) {
rebuildBuffer();
}
Graphics2D g2 = paintContext.getGraphics();
// Set interpolation to "nearest neighbor" to avoid JDK 1.5 performance problems.
g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR );
_imageTransform.setToTranslation( bounds.getX(), bounds.getY() );
g2.drawRenderedImage( _chartImage, _imageTransform );
}
示例12: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
protected void paint( PPaintContext paintContext ) {
Graphics2D g2 = paintContext.getGraphics();
if ( _renderingHints != null ) {
g2.setRenderingHints( _renderingHints );
}
// Clip to the data area.
// Do NOT call g2.setClip, or really bad things happen
// with drawing order on Macintosh (and possibly other platforms).
paintContext.pushClip( _dataArea );
// Render each of the plot's datasets, in the proper order...
int numberOfDatasets = _plot.getDatasetCount();
DatasetRenderingOrder renderingOrder = _plot.getDatasetRenderingOrder();
if ( renderingOrder == DatasetRenderingOrder.FORWARD ) {
for ( int i = 0; i < numberOfDatasets; i++ ) {
_plot.render( g2, _dataArea, i, null, null );
}
}
else { /* DatasetRenderingOrder.REVERSE */
for ( int i = numberOfDatasets - 1; i >= 0; i-- ) {
_plot.render( g2, _dataArea, i, null, null );
}
}
// restore the clip
paintContext.popClip( null );
// optionally stroke the data area -- do this after restoring the clip
if ( _dataAreaStroked ) {
g2.setStroke( _plot.getOutlineStroke() );
g2.setPaint( _plot.getOutlinePaint() );
g2.draw( _dataArea );
}
}
示例13: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
protected void paint( PPaintContext paintContext ) {
// System.out.println( "paintContext.getLocalClip() = " + paintContext.getLocalClip() );
Paint p = getPaint();
Graphics2D g2 = paintContext.getGraphics();
if ( p != null ) {
g2.setPaint( p );
g2.fill( getPathReference() );
}
if ( getStroke() != null && getStrokePaint() != null ) {
g2.setPaint( getStrokePaint() );
g2.setStroke( getStroke() );
int numPtsToUse = 30;
if ( pts.size() < numPtsToUse || !updatingAndPainting ) {
System.out.println( "rendering full path: updating&P=" + updatingAndPainting );
g2.draw( getPathReference() );
}
else {
// System.out.println( "rendering subpath" );
GeneralPath path = new GeneralPath();
path.moveTo( (float) getPreviousPoint( 0 ).getX(), (float) getPreviousPoint( 0 ).getY() );
for ( int i = 1; i < numPtsToUse; i++ ) {
path.lineTo( (float) getPreviousPoint( i ).getX(), (float) getPreviousPoint( i ).getY() );
}
g2.draw( path );
}
}
}
示例14: paint
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
@Override
protected void paint( PPaintContext paintContext ) {
super.paint( paintContext );
Graphics2D g2 = paintContext.getGraphics();
//save the old RenderingHints for restoring afterwards
RenderingHints renderingHints = g2.getRenderingHints();
//disable fractional metrics, if causes bounds to be computed incorrectly for some font sizes, see #2178
g2.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF );
label.paint( g2 );
//restore rendering hints so other painting systems are undisturbed
g2.setRenderingHints( renderingHints );
}
示例15: paintAfterChildren
import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
* Paints a border around this node if it has a stroke and stroke paint
* provided.
*
* @param paintContext context into which the border will be drawn
*/
protected void paintAfterChildren(final PPaintContext paintContext) {
paintContext.popClip(getPathReference());
if (getStroke() != null && getStrokePaint() != null) {
final Graphics2D g2 = paintContext.getGraphics();
g2.setPaint(getStrokePaint());
g2.setStroke(getStroke());
g2.draw(getPathReference());
}
}