public NoOpGraphics2D() { super(true); this.gc = new GraphicContext(); }
/** * Gets the current clipping area. * This method returns the user clip, which is independent of the * clipping associated with device bounds and window visibility. * If no clip has previously been set, or if the clip has been * cleared using <code>setClip(null)</code>, this method returns * <code>null</code>. * @return a <code>Shape</code> object representing the * current clipping area, or <code>null</code> if * no clip is set. * @see java.awt.Graphics#getClipBounds() * @see java.awt.Graphics#clipRect(int, int, int, int) * @see java.awt.Graphics#setClip(int, int, int, int) * @see java.awt.Graphics#setClip(Shape) * @since JDK1.1 */ public Shape getClip(){ return gc.getClip(); }
/** * Returns the current <code>Composite</code> in the * <code>Graphics2D</code> context. * @return the current <code>Graphics2D</code> <code>Composite</code>, * which defines a compositing style. * @see #setComposite */ public Composite getComposite(){ return gc.getComposite(); }
/** * Converts part or all of the input GraphicContext into * a set of attribute/value pairs and related definitions * * @param gc GraphicContext to be converted * @return descriptor of the attributes required to represent * some or all of the GraphicContext state, along * with the related definitions * @see org.apache.batik.svggen.SVGDescriptor */ public SVGDescriptor toSVG(GraphicContext gc) { return toSVG(gc.getFont(), gc.getFontRenderContext()); }
/** * Clears the specified rectangle by filling it with the background * color of the current drawing surface. This operation does not * use the current paint mode. * <p> * Beginning with Java 1.1, the background color * of offscreen images may be system dependent. Applications should * use <code>setColor</code> followed by <code>fillRect</code> to * ensure that an offscreen image is cleared to a specific color. * @param x the <i>x</i> coordinate of the rectangle to clear. * @param y the <i>y</i> coordinate of the rectangle to clear. * @param width the width of the rectangle to clear. * @param height the height of the rectangle to clear. * @see java.awt.Graphics#fillRect(int, int, int, int) * @see java.awt.Graphics#drawRect * @see java.awt.Graphics#setColor(java.awt.Color) * @see java.awt.Graphics#setPaintMode * @see java.awt.Graphics#setXORMode(java.awt.Color) */ public void clearRect(int x, int y, int width, int height){ Paint paint = gc.getPaint(); gc.setColor(gc.getBackground()); fillRect(x, y, width, height); gc.setPaint(paint); }
this.generatorCtx = generatorCtx; this.gc = new GraphicContext(new AffineTransform()); gc.setPaint(gcDefaults.getPaint()); gc.setStroke(gcDefaults.getStroke()); gc.setComposite(gcDefaults.getComposite()); gc.setClip(gcDefaults.getClip()); gc.setRenderingHints(gcDefaults.getRenderingHints()); gc.setFont(gcDefaults.getFont()); gc.setBackground(gcDefaults.getBackground());
gc.transform(xform); retVal = drawImage(img, 0, 0, null); gc.transform(inverseTransform); AffineTransform savTransform = new AffineTransform(gc.getTransform()); gc.transform(xform); retVal = drawImage(img, 0, 0, null); gc.setTransform(savTransform);
/** * Returns the current <code>Paint</code> of the * <code>Graphics2D</code> context. * @return the current <code>Graphics2D</code> <code>Paint</code>, * which defines a color or pattern. * @see #setPaint * @see java.awt.Graphics#setColor */ public Paint getPaint(){ return gc.getPaint(); }
boolean onStroke){ if (onStroke) { s = gc.getStroke().createStrokedShape(s); s = gc.getTransform().createTransformedShape(s);
/** * Returns the current <code>Stroke</code> in the * <code>Graphics2D</code> context. * @return the current <code>Graphics2D</code> <code>Stroke</code>, * which defines the line style. * @see #setStroke */ public Stroke getStroke(){ return gc.getStroke(); }
/** * Gets the preferences for the rendering algorithms. Hint categories * include controls for rendering quality and overall time/quality * trade-off in the rendering process. * Returns all of the hint key/value pairs that were ever specified in * one operation. Refer to the * <code>RenderingHints</code> class for definitions of some common * keys and values. * @return a reference to an instance of <code>RenderingHints</code> * that contains the current preferences. * @see RenderingHints */ public RenderingHints getRenderingHints(){ return gc.getRenderingHints(); }
/** * Returns a copy of the current <code>Transform</code> in the * <code>Graphics2D</code> context. * @return the current <code>AffineTransform</code> in the * <code>Graphics2D</code> context. * @see #transform * @see #setTransform */ public AffineTransform getTransform(){ return gc.getTransform(); }
/** * Gets the current font. * @return this graphics context's current font. * @see java.awt.Font * @see java.awt.Graphics#setFont */ public Font getFont(){ return gc.getFont(); }
/** * Sets the background color for the <code>Graphics2D</code> context. * The background color is used for clearing a region. * When a <code>Graphics2D</code> is constructed for a * <code>Component</code>, the background color is * inherited from the <code>Component</code>. Setting the background color * in the <code>Graphics2D</code> context only affects the subsequent * <code>clearRect</code> calls and not the background color of the * <code>Component</code>. To change the background * of the <code>Component</code>, use appropriate methods of * the <code>Component</code>. * @param color the background color that isused in * subsequent calls to <code>clearRect</code> * @see #getBackground * @see java.awt.Graphics#clearRect */ public void setBackground(Color color){ gc.setBackground(color); }
/** * Get the rendering context of the <code>Font</code> within this * <code>Graphics2D</code> context. * The {@link FontRenderContext} * encapsulates application hints such as anti-aliasing and * fractional metrics, as well as target device specific information * such as dots-per-inch. This information should be provided by the * application when using objects that perform typographical * formatting, such as <code>Font</code> and * <code>TextLayout</code>. This information should also be provided * by applications that perform their own layout and need accurate * measurements of various characteristics of glyphs such as advance * and line height when various rendering hints have been applied to * the text rendering. * * @return a reference to an instance of FontRenderContext. * @see java.awt.font.FontRenderContext * @see java.awt.Font#createGlyphVector(FontRenderContext,char[]) * @see java.awt.font.TextLayout * @since JDK1.2 */ public FontRenderContext getFontRenderContext(){ return gc.getFontRenderContext(); }
this.generatorCtx = generatorCtx; this.gc = new GraphicContext(new AffineTransform()); gc.setPaint(gcDefaults.getPaint()); gc.setStroke(gcDefaults.getStroke()); gc.setComposite(gcDefaults.getComposite()); gc.setClip(gcDefaults.getClip()); gc.setRenderingHints(gcDefaults.getRenderingHints()); gc.setFont(gcDefaults.getFont()); gc.setBackground(gcDefaults.getBackground());
gc.transform(xform); retVal = drawImage(img, 0, 0, null); gc.transform(inverseTransform); AffineTransform savTransform = new AffineTransform(gc.getTransform()); gc.transform(xform); retVal = drawImage(img, 0, 0, null); gc.setTransform(savTransform);
/** * Clears the specified rectangle by filling it with the background * color of the current drawing surface. This operation does not * use the current paint mode. * <p> * Beginning with Java 1.1, the background color * of offscreen images may be system dependent. Applications should * use <code>setColor</code> followed by <code>fillRect</code> to * ensure that an offscreen image is cleared to a specific color. * @param x the <i>x</i> coordinate of the rectangle to clear. * @param y the <i>y</i> coordinate of the rectangle to clear. * @param width the width of the rectangle to clear. * @param height the height of the rectangle to clear. * @see java.awt.Graphics#fillRect(int, int, int, int) * @see java.awt.Graphics#drawRect * @see java.awt.Graphics#setColor(java.awt.Color) * @see java.awt.Graphics#setPaintMode * @see java.awt.Graphics#setXORMode(java.awt.Color) */ public void clearRect(int x, int y, int width, int height){ Paint paint = gc.getPaint(); gc.setColor(gc.getBackground()); fillRect(x, y, width, height); gc.setPaint(paint); }