< prev index next >

src/java.desktop/share/classes/sun/print/PeekGraphics.java

Print this page




 344         mGraphics.setXORMode(c1);
 345     }
 346 
 347     /**
 348      * Gets the current font.
 349      * @return    this graphics context's current font.
 350      * @see       java.awt.Font
 351      * @see       java.awt.Graphics#setFont
 352      * @since     1.0
 353      */
 354     public Font getFont() {
 355         return mGraphics.getFont();
 356     }
 357 
 358     /**
 359      * Sets this graphics context's font to the specified font.
 360      * All subsequent text operations using this graphics context
 361      * use this font.
 362      * @param  font   the font.
 363      * @see     java.awt.Graphics#getFont
 364      * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
 365      * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
 366      * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
 367      * @since   1.0
 368     */
 369     public void setFont(Font font) {
 370         mGraphics.setFont(font);
 371     }
 372 
 373     /**
 374      * Gets the font metrics for the specified font.
 375      * @return    the font metrics for the specified font.
 376      * @param     f the specified font
 377      * @see       java.awt.Graphics#getFont
 378      * @see       java.awt.FontMetrics
 379      * @see       java.awt.Graphics#getFontMetrics()
 380      * @since     1.0
 381      */
 382     public FontMetrics getFontMetrics(Font f) {
 383         return mGraphics.getFontMetrics(f);
 384     }
 385 
 386     /**


1429      * @see #setClip
1430      */
1431     public void drawImage(BufferedImage img,
1432                           BufferedImageOp op,
1433                           int x,
1434                           int y) {
1435 
1436         if (img == null) {
1437             return;
1438         }
1439 
1440         mPrintMetrics.drawImage(this, (RenderedImage) img);
1441         mDrawingArea.addInfinite();
1442     }
1443 
1444 
1445     /**
1446      * Draws a string of text.
1447      * The rendering attributes applied include the clip, transform,
1448      * paint or color, font and composite attributes.
1449      * @param s The string to be drawn.
1450      * @param x,y The coordinates where the string should be drawn.
1451      * @see #setPaint
1452      * @see java.awt.Graphics#setColor
1453      * @see java.awt.Graphics#setFont
1454      * @see #transform
1455      * @see #setTransform
1456      * @see #setComposite
1457      * @see #clip
1458      * @see #setClip
1459      */
1460     public void drawString(String str,
1461                            float x,
1462                            float y) {
1463 
1464         if (str.length() == 0) {
1465             return;
1466         }
1467         /* Logical bounds close enough and is used for GlyphVector */
1468         FontRenderContext frc = getFontRenderContext();
1469         Rectangle2D bbox = getFont().getStringBounds(str, frc);


1531      * @see #transform
1532      * @see #setTransform
1533      * @see #clip
1534      * @see #setClip
1535      */
1536     public boolean hit(Rectangle rect,
1537                        Shape s,
1538                        boolean onStroke) {
1539 
1540         return mGraphics.hit(rect, s, onStroke);
1541     }
1542 
1543     /**
1544      * Sets the Composite in the current graphics state. Composite is used
1545      * in all drawing methods such as drawImage, drawString, draw,
1546      * and fill.  It specifies how new pixels are to be combined with
1547      * the existing pixels on the graphics device in the rendering process.
1548      * @param comp The Composite object to be used for drawing.
1549      * @see java.awt.Graphics#setXORMode
1550      * @see java.awt.Graphics#setPaintMode
1551      * @see AlphaComposite
1552      */
1553     public void setComposite(Composite comp) {
1554         mGraphics.setComposite(comp);
1555     }
1556 
1557 
1558     /**
1559      * Sets the Paint in the current graphics state.
1560      * @param paint The Paint object to be used to generate color in
1561      * the rendering process.
1562      * @see java.awt.Graphics#setColor
1563      * @see GradientPaint
1564      * @see TexturePaint
1565      */
1566     public void setPaint(Paint paint) {
1567         mGraphics.setPaint(paint);
1568     }
1569 
1570     /**
1571      * Sets the Stroke in the current graphics state.
1572      * @param s The Stroke object to be used to stroke a Shape in
1573      * the rendering process.
1574      * @see BasicStroke
1575      */
1576     public void setStroke(Stroke s) {
1577         mGraphics.setStroke(s);
1578     }
1579 
1580     /**
1581      * Sets the preferences for the rendering algorithms.
1582      * Hint categories include controls for rendering quality and
1583      * overall time/quality trade-off in the rendering process.
1584      * @param hintCategory The category of hint to be set.
1585      * @param hintValue The value indicating preferences for the specified
1586      * hint category.
1587      * @see RenderingHints
1588      */
1589     public void setRenderingHint(Key hintCategory, Object hintValue) {
1590         mGraphics.setRenderingHint(hintCategory, hintValue);
1591     }
1592 
1593     /**
1594      * Returns the preferences for the rendering algorithms.
1595      * @param hintCategory The category of hint to be set.
1596      * @return The preferences for rendering algorithms.
1597      * @see RenderingHings
1598      */
1599     public Object getRenderingHint(Key hintCategory) {
1600         return mGraphics.getRenderingHint(hintCategory);
1601     }
1602 
1603     /**
1604      * Sets the preferences for the rendering algorithms.
1605      * Hint categories include controls for rendering quality and
1606      * overall time/quality trade-off in the rendering process.
1607      * @param hints The rendering hints to be set
1608      * @see RenderingHints
1609      */
1610     public void setRenderingHints(Map<?,?> hints) {
1611         mGraphics.setRenderingHints(hints);
1612     }
1613 
1614     /**
1615      * Adds a number of preferences for the rendering algorithms.
1616      * Hint categories include controls for rendering quality and
1617      * overall time/quality trade-off in the rendering process.


1630      */
1631     public RenderingHints getRenderingHints() {
1632         return mGraphics.getRenderingHints();
1633     }
1634 
1635     /**
1636      * Composes a Transform object with the transform in this
1637      * Graphics2D according to the rule last-specified-first-applied.
1638      * If the currrent transform is Cx, the result of composition
1639      * with Tx is a new transform Cx'.  Cx' becomes the current
1640      * transform for this Graphics2D.
1641      * Transforming a point p by the updated transform Cx' is
1642      * equivalent to first transforming p by Tx and then transforming
1643      * the result by the original transform Cx.  In other words,
1644      * Cx'(p) = Cx(Tx(p)).
1645      * A copy of the Tx is made, if necessary, so further
1646      * modifications to Tx do not affect rendering.
1647      * @param Tx The Transform object to be composed with the current
1648      * transform.
1649      * @see #setTransform
1650      * @see TransformChain
1651      * @see AffineTransform
1652      */
1653     public void transform(AffineTransform Tx) {
1654         mGraphics.transform(Tx);
1655     }
1656 
1657     /**
1658      * Sets the Transform in the current graphics state.
1659      * @param Tx The Transform object to be used in the rendering process.
1660      * @see #transform
1661      * @see TransformChain
1662      * @see AffineTransform
1663      */
1664     public void setTransform(AffineTransform Tx) {
1665         mGraphics.setTransform(Tx);
1666     }
1667 
1668     /**
1669      * Returns the current Transform in the Graphics2D state.
1670      * @see #transform
1671      * @see #setTransform
1672      */
1673     public AffineTransform getTransform() {
1674         return mGraphics.getTransform();
1675     }
1676 
1677     /**
1678      * Returns the current Paint in the Graphics2D state.
1679      * @see #setPaint
1680      * @see java.awt.Graphics#setColor
1681      */


1683         return mGraphics.getPaint();
1684     }
1685 
1686     /**
1687      * Returns the current Composite in the Graphics2D state.
1688      * @see #setComposite
1689      */
1690     public Composite getComposite() {
1691         return mGraphics.getComposite();
1692     }
1693 
1694     /**
1695      * Sets the background color in this context used for clearing a region.
1696      * When Graphics2D is constructed for a component, the backgroung color is
1697      * inherited from the component. Setting the background color in the
1698      * Graphics2D context only affects the subsequent clearRect() calls and
1699      * not the background color of the component. To change the background
1700      * of the component, use appropriate methods of the component.
1701      * @param color The background color that should be used in
1702      * subsequent calls to clearRect().
1703      * @see getBackground
1704      * @see Graphics.clearRect()
1705      */
1706     public void setBackground(Color color) {
1707         mGraphics.setBackground(color);
1708     }
1709 
1710     /**
1711      * Returns the background color used for clearing a region.
1712      * @see setBackground
1713      */
1714     public Color getBackground() {
1715         return mGraphics.getBackground();
1716     }
1717 
1718     /**
1719      * Returns the current Stroke in the Graphics2D state.
1720      * @see setStroke
1721      */
1722     public Stroke getStroke() {
1723         return mGraphics.getStroke();
1724     }
1725 
1726     /**
1727      * Intersects the current clip with the interior of the specified Shape
1728      * and sets the current clip to the resulting intersection.
1729      * The indicated shape is transformed with the current transform in the
1730      * Graphics2D state before being intersected with the current clip.
1731      * This method is used to make the current clip smaller.
1732      * To make the clip larger, use any setClip method.
1733      * @param s The Shape to be intersected with the current clip.
1734      */
1735      public void clip(Shape s) {
1736         mGraphics.clip(s);
1737      }
1738 
1739      /**
1740       * Return true if the Rectangle <code>rect</code>




 344         mGraphics.setXORMode(c1);
 345     }
 346 
 347     /**
 348      * Gets the current font.
 349      * @return    this graphics context's current font.
 350      * @see       java.awt.Font
 351      * @see       java.awt.Graphics#setFont
 352      * @since     1.0
 353      */
 354     public Font getFont() {
 355         return mGraphics.getFont();
 356     }
 357 
 358     /**
 359      * Sets this graphics context's font to the specified font.
 360      * All subsequent text operations using this graphics context
 361      * use this font.
 362      * @param  font   the font.
 363      * @see     java.awt.Graphics#getFont
 364      * @see     java.awt.Graphics#drawChars(char[], int, int, int, int)
 365      * @see     java.awt.Graphics#drawString(String, int, int)
 366      * @see     java.awt.Graphics#drawBytes(byte[], int, int, int, int)
 367      * @since   1.0
 368     */
 369     public void setFont(Font font) {
 370         mGraphics.setFont(font);
 371     }
 372 
 373     /**
 374      * Gets the font metrics for the specified font.
 375      * @return    the font metrics for the specified font.
 376      * @param     f the specified font
 377      * @see       java.awt.Graphics#getFont
 378      * @see       java.awt.FontMetrics
 379      * @see       java.awt.Graphics#getFontMetrics()
 380      * @since     1.0
 381      */
 382     public FontMetrics getFontMetrics(Font f) {
 383         return mGraphics.getFontMetrics(f);
 384     }
 385 
 386     /**


1429      * @see #setClip
1430      */
1431     public void drawImage(BufferedImage img,
1432                           BufferedImageOp op,
1433                           int x,
1434                           int y) {
1435 
1436         if (img == null) {
1437             return;
1438         }
1439 
1440         mPrintMetrics.drawImage(this, (RenderedImage) img);
1441         mDrawingArea.addInfinite();
1442     }
1443 
1444 
1445     /**
1446      * Draws a string of text.
1447      * The rendering attributes applied include the clip, transform,
1448      * paint or color, font and composite attributes.
1449      * @param str The string to be drawn.
1450      * @param x,y The coordinates where the string should be drawn.
1451      * @see #setPaint
1452      * @see java.awt.Graphics#setColor
1453      * @see java.awt.Graphics#setFont
1454      * @see #transform
1455      * @see #setTransform
1456      * @see #setComposite
1457      * @see #clip
1458      * @see #setClip
1459      */
1460     public void drawString(String str,
1461                            float x,
1462                            float y) {
1463 
1464         if (str.length() == 0) {
1465             return;
1466         }
1467         /* Logical bounds close enough and is used for GlyphVector */
1468         FontRenderContext frc = getFontRenderContext();
1469         Rectangle2D bbox = getFont().getStringBounds(str, frc);


1531      * @see #transform
1532      * @see #setTransform
1533      * @see #clip
1534      * @see #setClip
1535      */
1536     public boolean hit(Rectangle rect,
1537                        Shape s,
1538                        boolean onStroke) {
1539 
1540         return mGraphics.hit(rect, s, onStroke);
1541     }
1542 
1543     /**
1544      * Sets the Composite in the current graphics state. Composite is used
1545      * in all drawing methods such as drawImage, drawString, draw,
1546      * and fill.  It specifies how new pixels are to be combined with
1547      * the existing pixels on the graphics device in the rendering process.
1548      * @param comp The Composite object to be used for drawing.
1549      * @see java.awt.Graphics#setXORMode
1550      * @see java.awt.Graphics#setPaintMode
1551      * @see java.awt.AlphaComposite
1552      */
1553     public void setComposite(Composite comp) {
1554         mGraphics.setComposite(comp);
1555     }
1556 
1557 
1558     /**
1559      * Sets the Paint in the current graphics state.
1560      * @param paint The Paint object to be used to generate color in
1561      * the rendering process.
1562      * @see java.awt.Graphics#setColor
1563      * @see java.awt.GradientPaint
1564      * @see java.awt.TexturePaint
1565      */
1566     public void setPaint(Paint paint) {
1567         mGraphics.setPaint(paint);
1568     }
1569 
1570     /**
1571      * Sets the Stroke in the current graphics state.
1572      * @param s The Stroke object to be used to stroke a Shape in
1573      * the rendering process.
1574      * @see BasicStroke
1575      */
1576     public void setStroke(Stroke s) {
1577         mGraphics.setStroke(s);
1578     }
1579 
1580     /**
1581      * Sets the preferences for the rendering algorithms.
1582      * Hint categories include controls for rendering quality and
1583      * overall time/quality trade-off in the rendering process.
1584      * @param hintCategory The category of hint to be set.
1585      * @param hintValue The value indicating preferences for the specified
1586      * hint category.
1587      * @see RenderingHints
1588      */
1589     public void setRenderingHint(Key hintCategory, Object hintValue) {
1590         mGraphics.setRenderingHint(hintCategory, hintValue);
1591     }
1592 
1593     /**
1594      * Returns the preferences for the rendering algorithms.
1595      * @param hintCategory The category of hint to be set.
1596      * @return The preferences for rendering algorithms.
1597      * @see RenderingHints
1598      */
1599     public Object getRenderingHint(Key hintCategory) {
1600         return mGraphics.getRenderingHint(hintCategory);
1601     }
1602 
1603     /**
1604      * Sets the preferences for the rendering algorithms.
1605      * Hint categories include controls for rendering quality and
1606      * overall time/quality trade-off in the rendering process.
1607      * @param hints The rendering hints to be set
1608      * @see RenderingHints
1609      */
1610     public void setRenderingHints(Map<?,?> hints) {
1611         mGraphics.setRenderingHints(hints);
1612     }
1613 
1614     /**
1615      * Adds a number of preferences for the rendering algorithms.
1616      * Hint categories include controls for rendering quality and
1617      * overall time/quality trade-off in the rendering process.


1630      */
1631     public RenderingHints getRenderingHints() {
1632         return mGraphics.getRenderingHints();
1633     }
1634 
1635     /**
1636      * Composes a Transform object with the transform in this
1637      * Graphics2D according to the rule last-specified-first-applied.
1638      * If the currrent transform is Cx, the result of composition
1639      * with Tx is a new transform Cx'.  Cx' becomes the current
1640      * transform for this Graphics2D.
1641      * Transforming a point p by the updated transform Cx' is
1642      * equivalent to first transforming p by Tx and then transforming
1643      * the result by the original transform Cx.  In other words,
1644      * Cx'(p) = Cx(Tx(p)).
1645      * A copy of the Tx is made, if necessary, so further
1646      * modifications to Tx do not affect rendering.
1647      * @param Tx The Transform object to be composed with the current
1648      * transform.
1649      * @see #setTransform

1650      * @see AffineTransform
1651      */
1652     public void transform(AffineTransform Tx) {
1653         mGraphics.transform(Tx);
1654     }
1655 
1656     /**
1657      * Sets the Transform in the current graphics state.
1658      * @param Tx The Transform object to be used in the rendering process.
1659      * @see #transform

1660      * @see AffineTransform
1661      */
1662     public void setTransform(AffineTransform Tx) {
1663         mGraphics.setTransform(Tx);
1664     }
1665 
1666     /**
1667      * Returns the current Transform in the Graphics2D state.
1668      * @see #transform
1669      * @see #setTransform
1670      */
1671     public AffineTransform getTransform() {
1672         return mGraphics.getTransform();
1673     }
1674 
1675     /**
1676      * Returns the current Paint in the Graphics2D state.
1677      * @see #setPaint
1678      * @see java.awt.Graphics#setColor
1679      */


1681         return mGraphics.getPaint();
1682     }
1683 
1684     /**
1685      * Returns the current Composite in the Graphics2D state.
1686      * @see #setComposite
1687      */
1688     public Composite getComposite() {
1689         return mGraphics.getComposite();
1690     }
1691 
1692     /**
1693      * Sets the background color in this context used for clearing a region.
1694      * When Graphics2D is constructed for a component, the backgroung color is
1695      * inherited from the component. Setting the background color in the
1696      * Graphics2D context only affects the subsequent clearRect() calls and
1697      * not the background color of the component. To change the background
1698      * of the component, use appropriate methods of the component.
1699      * @param color The background color that should be used in
1700      * subsequent calls to clearRect().
1701      * @see #getBackground
1702      * @see Graphics#clearRect
1703      */
1704     public void setBackground(Color color) {
1705         mGraphics.setBackground(color);
1706     }
1707 
1708     /**
1709      * Returns the background color used for clearing a region.
1710      * @see #setBackground
1711      */
1712     public Color getBackground() {
1713         return mGraphics.getBackground();
1714     }
1715 
1716     /**
1717      * Returns the current Stroke in the Graphics2D state.
1718      * @see #setStroke
1719      */
1720     public Stroke getStroke() {
1721         return mGraphics.getStroke();
1722     }
1723 
1724     /**
1725      * Intersects the current clip with the interior of the specified Shape
1726      * and sets the current clip to the resulting intersection.
1727      * The indicated shape is transformed with the current transform in the
1728      * Graphics2D state before being intersected with the current clip.
1729      * This method is used to make the current clip smaller.
1730      * To make the clip larger, use any setClip method.
1731      * @param s The Shape to be intersected with the current clip.
1732      */
1733      public void clip(Shape s) {
1734         mGraphics.clip(s);
1735      }
1736 
1737      /**
1738       * Return true if the Rectangle <code>rect</code>


< prev index next >