Search in sources :

Example 1 with ConstrainableGraphics

use of sun.awt.ConstrainableGraphics in project jdk8u_jdk by JetBrains.

the class Component method getGraphics_NoClientCode.

final Graphics getGraphics_NoClientCode() {
    ComponentPeer peer = this.peer;
    if (peer instanceof LightweightPeer) {
        // This is for a lightweight component, need to
        // translate coordinate spaces and clip relative
        // to the parent.
        Container parent = this.parent;
        if (parent == null)
            return null;
        Graphics g = parent.getGraphics_NoClientCode();
        if (g == null)
            return null;
        if (g instanceof ConstrainableGraphics) {
            ((ConstrainableGraphics) g).constrain(x, y, width, height);
        } else {
            g.translate(x, y);
            g.setClip(0, 0, width, height);
        }
        g.setFont(getFont_NoClientCode());
        return g;
    } else {
        return (peer != null) ? peer.getGraphics() : null;
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ComponentPeer(java.awt.peer.ComponentPeer)

Example 2 with ConstrainableGraphics

use of sun.awt.ConstrainableGraphics in project jdk8u_jdk by JetBrains.

the class Component method getGraphics.

/**
     * Creates a graphics context for this component. This method will
     * return <code>null</code> if this component is currently not
     * displayable.
     * @return a graphics context for this component, or <code>null</code>
     *             if it has none
     * @see       #paint
     * @since     JDK1.0
     */
public Graphics getGraphics() {
    if (peer instanceof LightweightPeer) {
        // to the parent.
        if (parent == null)
            return null;
        Graphics g = parent.getGraphics();
        if (g == null)
            return null;
        if (g instanceof ConstrainableGraphics) {
            ((ConstrainableGraphics) g).constrain(x, y, width, height);
        } else {
            g.translate(x, y);
            g.setClip(0, 0, width, height);
        }
        g.setFont(getFont());
        return g;
    } else {
        ComponentPeer peer = this.peer;
        return (peer != null) ? peer.getGraphics() : null;
    }
}
Also used : LightweightPeer(java.awt.peer.LightweightPeer) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ConstrainableGraphics(sun.awt.ConstrainableGraphics) ComponentPeer(java.awt.peer.ComponentPeer)

Aggregations

ComponentPeer (java.awt.peer.ComponentPeer)2 LightweightPeer (java.awt.peer.LightweightPeer)2 ConstrainableGraphics (sun.awt.ConstrainableGraphics)2