本文整理了Java中java.awt.Graphics2D.getClip()
方法的一些代码示例,展示了Graphics2D.getClip()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.getClip()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:getClip
暂无
代码示例来源:origin: org.apache.poi/poi
Shape clipOld = graphics.getClip();
if (isClipped) graphics.clip(anchor.getBounds2D());
graphics.drawRenderedImage(img, at);
graphics.setClip(clipOld);
代码示例来源:origin: apache/pdfbox
/**
* Glyph bounding boxes.
*/
@Override
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,
Vector displacement) throws IOException
{
// draw glyph
super.showGlyph(textRenderingMatrix, font, code, unicode, displacement);
// bbox in EM -> user units
Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1);
AffineTransform at = textRenderingMatrix.createAffineTransform();
bbox = at.createTransformedShape(bbox);
// save
Graphics2D graphics = getGraphics();
Color color = graphics.getColor();
Stroke stroke = graphics.getStroke();
Shape clip = graphics.getClip();
// draw
graphics.setClip(graphics.getDeviceConfiguration().getBounds());
graphics.setColor(Color.RED);
graphics.setStroke(new BasicStroke(.5f));
graphics.draw(bbox);
// restore
graphics.setStroke(stroke);
graphics.setColor(color);
graphics.setClip(clip);
}
代码示例来源:origin: apache/pdfbox
/**
* Filled path bounding boxes.
*/
@Override
public void fillPath(int windingRule) throws IOException
{
// bbox in user units
Shape bbox = getLinePath().getBounds2D();
// draw path (note that getLinePath() is now reset)
super.fillPath(windingRule);
// save
Graphics2D graphics = getGraphics();
Color color = graphics.getColor();
Stroke stroke = graphics.getStroke();
Shape clip = graphics.getClip();
// draw
graphics.setClip(graphics.getDeviceConfiguration().getBounds());
graphics.setColor(Color.GREEN);
graphics.setStroke(new BasicStroke(.5f));
graphics.draw(bbox);
// restore
graphics.setStroke(stroke);
graphics.setColor(color);
graphics.setClip(clip);
}
代码示例来源:origin: knowm/XChart
@Override
public void paint(Graphics2D g) {
Rectangle2D bounds = getBounds();
// g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
// g.setColor(Color.red);
// g.draw(bounds);
// if the area to draw a chart on is so small, don't even bother
if (bounds.getWidth() < 30) {
return;
}
java.awt.Shape saveClip = g.getClip();
// this is for preventing the series to be drawn outside the plot area if min and max is
// overridden to fall inside the data range
g.setClip(bounds.createIntersection(bounds));
chart.toolTips.prepare(g);
doPaint(g);
chart.toolTips.paint(g);
g.setClip(saveClip);
}
代码示例来源:origin: apache/pdfbox
Color color = graphics.getColor();
Stroke stroke = graphics.getStroke();
Shape clip = graphics.getClip();
graphics.setClip(graphics.getDeviceConfiguration().getBounds());
graphics.setColor(Color.cyan);
graphics.setStroke(new BasicStroke(.5f));
graphics.setClip(clip);
代码示例来源:origin: geotools/geotools
Shape oldClip = graphics.getClip();
try {
paintGraphicFill(graphics, shape, ps2d.getGraphicFill(), scale);
} finally {
graphics.setClip(oldClip);
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
public void clip(int x1, int y1, int width, int height) {
clipHist.push(g2d.getClip());
g2d.setClip(x1,y1,width,height);
}
代码示例来源:origin: stackoverflow.com
public void paintComponent( Graphics g ) {
Graphics2D gx = (Graphics2D) g;
Shape old = gx.getClip();
gx.rotate(-Math.toRadians(45), getWidth()/2, getHeight()/2);
gx.setClip(old);
super.paintComponent(gx);
}
public void setRotation( int angle ) { this.angle = angle; }
}
}
代码示例来源:origin: lbalazscs/Pixelitor
public DragDisplay(Graphics2D g, int bgWidth) {
this.g = g;
origComposite = g.getComposite();
origStroke = g.getStroke();
origClip = g.getClip();
this.bgWidth = bgWidth;
g.setStroke(BG_STROKE);
g.setClip(null);
}
代码示例来源:origin: stackoverflow.com
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
AffineTransform aT = g2.getTransform();
Shape oldshape = g2.getClip();
g2.rotate(Math.toRadians(300));
super.paintComponent(g);
g2.setTransform(aT);
g2.setClip(oldshape);
}
代码示例来源:origin: stackoverflow.com
@Override
public void paintComponent(final Graphics g) {
super.paintComponent(g);
Graphics2D gImg = (Graphics2D) g;
Shape oldClip= gImg.getClip();
Polygon shape = new Polygon(
new int[] { 0, 100, 100, 50, 0},
new int[] {200, 200, 100, 50, 100}, 5);
gImg.setClip(shape);
gImg.setColor(new Color(255, 0, 0, 50));
gImg.fill(shape);
gImg.setClip(oldClip);
}
代码示例来源:origin: gurkenlabs/litiengine
public void render(final Graphics2D g, final Collection<? extends IRenderable> renderables, final Shape clip) {
// set render shape according to the vision
final Shape oldClip = g.getClip();
g.setClip(clip);
renderables.forEach(r -> r.render(g));
g.setClip(oldClip);
}
代码示例来源:origin: gurkenlabs/litiengine
public void renderEntities(final Graphics2D g, final Collection<? extends IEntity> entities, final boolean sort, final Shape clip) {
// set render shape according to the vision
final Shape oldClip = g.getClip();
if (clip != null) {
g.setClip(clip);
}
this.renderEntities(g, entities, sort);
g.setClip(oldClip);
}
代码示例来源:origin: com.jtattoo/JTattoo
public static void fillComponent(Graphics g, Component c, int x, int y, int w, int h) {
Graphics2D g2D = (Graphics2D) g;
Shape savedClip = g2D.getClip();
Area clipArea = new Area(new Rectangle2D.Double(x, y, w, h));
if (savedClip != null) {
clipArea.intersect(new Area(savedClip));
}
g2D.setClip(clipArea);
fillComponent(g, c);
g2D.setClip(savedClip);
}
}
代码示例来源:origin: robo-code/robocode
private void drawBorderEdge(Graphics2D g) {
final Shape savedClip = g.getClip();
g.setClip(null);
g.setColor(Color.RED);
g.drawRect(-1, -1, battleField.getWidth() + 2, battleField.getHeight() + 2);
g.setClip(savedClip);
}
代码示例来源:origin: com.barchart.pivot/pivot-wtk
@Override
public Graphics2D prepare(Component component, Graphics2D graphics) {
this.graphics = graphics;
int width = component.getWidth();
int height = component.getHeight();
if (bufferedImage == null
|| bufferedImage.getWidth() != width
|| bufferedImage.getHeight() != height) {
bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
}
bufferedImageGraphics = bufferedImage.createGraphics();
bufferedImageGraphics.setClip(graphics.getClip());
return bufferedImageGraphics;
}
代码示例来源:origin: org.apache.pivot/pivot-wtk
@Override
public Graphics2D prepare(Component component, Graphics2D graphicsArgument) {
this.graphics = graphicsArgument;
int width = component.getWidth();
int height = component.getHeight();
if (bufferedImage == null
|| bufferedImage.getWidth() != width
|| bufferedImage.getHeight() != height) {
bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
}
bufferedImageGraphics = bufferedImage.createGraphics();
bufferedImageGraphics.setClip(graphicsArgument.getClip());
return bufferedImageGraphics;
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer
/**
* Renders the document to the given canvas. Call layout() first.
*
* @param g2 Canvas to render to.
*/
public void render(Graphics2D g2) {
if (g2.getClip() == null) {
g2.setClip(getMinimumSize());
}
panel.paintComponent(g2);
}
代码示例来源:origin: org.xhtmlrenderer/core-renderer
/**
* Renders the document to the given canvas. Call layout() first.
*
* @param g2 Canvas to render to.
*/
public void render(Graphics2D g2) {
if (g2.getClip() == null) {
g2.setClip(getMinimumSize());
}
panel.paintComponent(g2);
}
代码示例来源:origin: uk.ac.gate.plugins/tagger-measurements
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.translate(x, y);
Area clip = new Area(new Rectangle(0, 0, this.width, this.height));
if (g2d.getClip() != null) clip.intersect(new Area(g2d.getClip()));
g2d.setClip(clip);
double coef1 = (double) this.width / (double) getOrigWidth();
double coef2 = (double) this.height / (double) getOrigHeight();
double coef = Math.min(coef1, coef2);
g2d.scale(coef, coef);
paint(g2d);
g2d.dispose();
}
}
内容来源于网络,如有侵权,请联系作者删除!