Renders content.

@param g
the graphics
@param a
the allocation
@param fg
the color of foreground
@param p0
start position
@param p1
end position
164492
protected void renderContent(Graphics2D g, Shape a, Color fg, int p0, int p1)
    {
        TextLayout layout = getTextLayout();
        Rectangle absoluteBounds = box.getAbsoluteBounds();
        Rectangle absoluteContentBounds = box.getAbsoluteContentBounds();

        int pStart = getStartOffset();
        int pEnd = getEndOffset();
        int x = absoluteBounds.x;
        int y = absoluteBounds.y;

        Shape oldclip = g.getClip();
        BlockBox clipblock = box.getClipBlock();
        if (clipblock != null)
        {
            Rectangle newclip = clipblock.getClippedContentBounds();
            Rectangle clip = toRect(oldclip).intersection(newclip);
            g.setClip(clip);
        }
        
        g.setFont(getFont());
        g.setColor(fg);

        // -- Draw the string at specified positions --

        if (p0 > pStart || p1 < pEnd)
        {
            try
            {
                // TextLayout can't render only part of it's range, so if a
                // partial range is required, add a clip region.
                Shape s = modelToView(p0, Position.Bias.Forward, p1, Position.Bias.Backward, a);
                absoluteContentBounds = absoluteContentBounds.intersection(toRect(s));
            } catch (BadLocationException ignored)
            {
            }
        }

        // render the text
        layout.draw(g, x, y + layout.getAscent());

        //render the decoration
        if (underline || strike || overline)
        {
            Stroke origStroke = g.getStroke();

            int w;
            if (getFont().isBold())
                w = getFont().getSize() / 8;
            else
                w = getFont().getSize() / 10;
            if (w < 1) w = 1;
            y += w / 2;
            
            g.setStroke(new BasicStroke(w));

            int xx = absoluteContentBounds.x + absoluteContentBounds.width;
            if (overline)
            {
                g.drawLine(absoluteContentBounds.x, y, xx, y);
            }
            if (underline)
            {
                int yy = y + absoluteContentBounds.height - (int) layout.getDescent();
                g.drawLine(absoluteContentBounds.x, yy, xx, yy);
            }
            if (strike)
            {
                int yy = y + absoluteContentBounds.height / 2;
                g.drawLine(absoluteContentBounds.x, yy, xx, yy);
            }
            
            g.setStroke(origStroke);
        }

        g.setClip(oldclip);
    }
1356207
private void paint(SeaGlassContext context, Graphics g) {
        String title = frame.getTitle();

        if (title != null) {
            SynthStyle style = context.getStyle();

            Color color = style.getColor(context, ColorType.TEXT_FOREGROUND);

            // TODO style.getColor returns improper color for state? Why?
            if ((context.getComponentState() & 512) != 0) {
                Object obj = style.get(context, "[WindowFocused].textForeground");

                if (obj != null && obj instanceof Color) {
                    color = (Color) obj;
                }

                // FIXME The state *still* doesn't get the color right!!!
                color = Color.WHITE;
            }

            g.setColor(color);
            g.setFont(style.getFont(context));

            // Center text vertically.
            FontMetrics fm         = SwingUtilities2.getFontMetrics(frame, g);
            int         baseline   = (getHeight() + fm.getAscent() - fm.getLeading() - fm.getDescent()) / 2;
            JButton     lastButton = null;

            if (frame.isIconifiable()) {
                lastButton = iconButton;
            } else if (frame.isMaximizable()) {
                lastButton = maxButton;
            } else if (frame.isClosable()) {
                lastButton = closeButton;
            }

            int     maxX;
            int     minX;
            boolean ltr = SeaGlassLookAndFeel.isLeftToRight(frame);

            if (ltr) {

                if (lastButton != null) {
                    maxX = lastButton.getX() - titleSpacing;
                } else {
                    maxX = frame.getWidth() - frame.getInsets().right - titleSpacing;
                }

                minX = menuButton.getX() + menuButton.getWidth() + titleSpacing;
            } else {

                if (lastButton != null) {
                    minX = lastButton.getX() + lastButton.getWidth() + titleSpacing;
                } else {
                    minX = frame.getInsets().left + titleSpacing;
                }

                maxX = menuButton.getX() - titleSpacing;
            }

            String clippedTitle = getTitle(title, fm, maxX - minX);

            if (clippedTitle == title) {
                int width = style.getGraphicsUtils(context).computeStringWidth(context, g.getFont(), fm, title);

                minX = Math.max(minX, (getWidth() - width) / 2);
                minX = Math.min(maxX - width, minX);
            }

            style.getGraphicsUtils(context).paintText(context, g, clippedTitle, minX, baseline - fm.getAscent(), -1);
        }
    }
776133
public void render() {
		if ((engine.usePoints() && (usePoints == INHERIT_POINTS))
				|| (usePoints == USE_POINTS)) {
			TextureImpl.bindNone();
			GL.glEnable(SGL.GL_POINT_SMOOTH);
			GL.glPointSize(size / 2);
			color.bind();
			GL.glBegin(SGL.GL_POINTS);
			GL.glVertex2f(x, y);
			GL.glEnd();
		} else if (oriented || scaleY != 1.0f) {
			GL.glPushMatrix();

			GL.glTranslatef(x, y, 0f);

			if (oriented) {
				float angle = (float) (Math.atan2(y, x) * 180 / Math.PI);
				GL.glRotatef(angle, 0f, 0f, 1.0f);
			}

			// scale
			GL.glScalef(1.0f, scaleY, 1.0f);

			image.draw((int) (-(size / 2)), (int) (-(size / 2)), (int) size,
					(int) size, color);
			GL.glPopMatrix();
		} else {
			color.bind();
			image.drawEmbedded((int) (x - (size / 2)), (int) (y - (size / 2)),
					(int) size, (int) size);
		}
	}
909929
public void drawPairs(Graphics g){

		if ( aligs == null)
			return;

		int nr = aligs.length;

		Graphics2D g2D = (Graphics2D)g;
		Stroke oldStroke = g2D.getStroke();
		g2D.setStroke(stroke);

		Color color;
		float hue;

		int width = Math.round(scale);
		int w2 = width / 2 ;

		for (int i = 0; i < aligs.length; i++) {
			AlternativeAlignment a = aligs[i];
			int[] idx1 = a.getIdx1();
			int[] idx2 = a.getIdx2();
			int xold = -1;
			int yold = -1;
			boolean start = true;

			if ( (selectedAlignmentPos != -1 ) &&
					( selectedAlignmentPos == i)){
				color = Color.white;
			} else {

				hue = i * (1/ (float)nr);
				color = Color.getHSBColor(hue,1.0f,1.0f);
			}
			g.setColor(color);

			for (int j = 0; j < idx1.length; j++) {
				int x1 = Math.round(idx1[j]*scale) ;
				int y1 = Math.round(idx2[j]*scale) ;
				if ( ! start){
					//g.drawLine(xold+1,yold,x1+1,y1);

					//g2D.draw(new Line2D.Double(xold,yold,x1,y1));
					g.fillRect(xold,yold,2,2);
				} else {
					g.fillRect(x1,y1, w2, w2);
					start =false;
				}
				xold = x1;
				yold = y1;
			}

			if ( ! start)
				g.fillRect(xold,yold,w2,w2);


		}

		g2D.setStroke(oldStroke);
	}
1297330
@Override
    protected void paintComponent(Graphics g) {
        if (!isInitialized()) {
            return;
        }

        final Graphics2D G2 = (Graphics2D) g.create();

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        G2.translate(getFramelessOffset().getX(), getFramelessOffset().getY());

        final AffineTransform OLD_TRANSFORM = G2.getTransform();

        // Draw combined background image
        G2.drawImage(bImage, 0, 0, null);

        // Highlight active area
        if (isHighlightArea()) {
            for(Section area : getAreas()) {
                if (area.contains(getValue())) {
                    G2.setColor(area.getHighlightColor());
                    G2.fill(area.getFilledArea());
                    break;
                }
            }
        }

        // Highlight active section
        if (isHighlightSection()) {
            for(Section section : getSections()) {
                if (section.contains(getValue())) {
                    G2.setColor(section.getHighlightColor());
                    G2.fill(section.getSectionArea());
                    break;
                }
            }
        }

        // Draw threshold indicator
        if (isThresholdVisible()) {
            if (!isLogScale()) {
                G2.rotate(ROTATION_OFFSET + (getThreshold() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());
            } else {
                G2.rotate(ROTATION_OFFSET + UTIL.logOfBase(BASE, getThreshold() - getMinValue()) * getLogAngleStep(), CENTER.getX(), CENTER.getY());
            }
            G2.drawImage(thresholdImage, (int) (getGaugeBounds().width * 0.480369999), (int) (getGaugeBounds().height * 0.13), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw min measured value indicator
        if (isMinMeasuredValueVisible()) {
            if (!isLogScale()) {
                G2.rotate(ROTATION_OFFSET + (getMinMeasuredValue() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());
            } else {
                G2.rotate(ROTATION_OFFSET + UTIL.logOfBase(BASE, getMinMeasuredValue() - getMinValue()) * getLogAngleStep(), CENTER.getX(), CENTER.getY());
            }
            G2.drawImage(minMeasuredImage, (int) (getGaugeBounds().width * 0.4865), (int) (getGaugeBounds().height * 0.105), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw max measured value indicator
        if (isMaxMeasuredValueVisible()) {
            if (!isLogScale()) {
                G2.rotate(ROTATION_OFFSET + (getMaxMeasuredValue() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());
            } else {
                G2.rotate(ROTATION_OFFSET + UTIL.logOfBase(BASE, getMaxMeasuredValue() - getMinValue()) * getLogAngleStep(), CENTER.getX(), CENTER.getY());
            }
            G2.drawImage(maxMeasuredImage, (int) (getGaugeBounds().width * 0.4865), (int) (getGaugeBounds().height * 0.105), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw LED if enabled
        if (isLedVisible()) {
            G2.drawImage(getCurrentLedImage(), (int) (getGaugeBounds().width * getLedPosition().getX()), (int) (getGaugeBounds().height * getLedPosition().getY()), null);
        }

        // Draw user LED if enabled
        if (isUserLedVisible()) {
            G2.drawImage(getCurrentUserLedImage(), (int) (getGaugeBounds().width * getUserLedPosition().getX()), (int) (getGaugeBounds().height * getUserLedPosition().getY()), null);
        }

        // Draw the pointer
        if (!isLogScale()) {
            angle = ROTATION_OFFSET + (getValue() - getMinValue()) * getAngleStep();
        } else {
            angle = ROTATION_OFFSET + UTIL.logOfBase(BASE, (getValue() - getMinValue())) * getLogAngleStep();
        }
        G2.rotate(angle, CENTER.getX(), CENTER.getY() + 2);
        G2.drawImage(pointerShadowImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);
        G2.rotate(angle, CENTER.getX(), CENTER.getY());
        G2.drawImage(pointerImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw combined foreground image
        G2.drawImage(fImage, 0, 0, null);

        // Draw glow indicator
        if (isGlowVisible()) {
            if (isGlowing()) {
                G2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getGlowAlpha()));
                G2.drawImage(glowImageOn, 0, 0, null);
                G2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
            } else
            {
                G2.drawImage(glowImageOff, 0, 0, null);
            }
        }

        if (!isEnabled()) {
            G2.drawImage(disabledImage, 0, 0, null);
        }

        G2.dispose();
    }
1031385
@Override
    protected void paintComponent(Graphics g) {
        if (!isInitialized()) {
            return;
        }

        final Graphics2D G2 = (Graphics2D) g.create();

        CENTER.setLocation(getGaugeBounds().getCenterX(), getGaugeBounds().getCenterX());

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        // Translate the coordinate system related to the insets
        G2.translate(getFramelessOffset().getX(), getFramelessOffset().getY());

        final AffineTransform OLD_TRANSFORM = G2.getTransform();

        // Draw combined background image
        G2.drawImage(bImage, 0, 0, null);

        // Draw LCD display
        if (isLcdVisible()) {
            if (getLcdColor() == LcdColor.CUSTOM) {
                G2.setColor(getCustomLcdForeground());
            } else {
                G2.setColor(getLcdColor().TEXT_COLOR);
            }
            G2.setFont(getLcdUnitFont());
            if (isLcdUnitStringVisible()) {
                unitLayout = new TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
                UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
                G2.drawString(getLcdUnitString(), (float) (LCD.getX() + (LCD.getWidth() - UNIT_BOUNDARY.getWidth()) - LCD.getWidth() * 0.03), (float) (LCD.getY() + LCD.getHeight() * 0.76));
                unitStringWidth = UNIT_BOUNDARY.getWidth();
            } else {
                unitStringWidth = 0;
            }
            G2.setFont(getLcdValueFont());
            switch (getModel().getNumberSystem()) {
                case HEX:
                    valueLayout = new TextLayout(Integer.toHexString((int) getLcdValue()).toUpperCase(), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(Integer.toHexString((int) getLcdValue()).toUpperCase(), (float) (LCD.getX() + (LCD.getWidth() - unitStringWidth - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09), (float) (LCD.getY() + LCD.getHeight() * 0.76));
                    break;

                case OCT:
                    valueLayout = new TextLayout(Integer.toOctalString((int) getLcdValue()), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(Integer.toOctalString((int) getLcdValue()), (float) (LCD.getX() + (LCD.getWidth() - unitStringWidth - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09), (float) (LCD.getY() + LCD.getHeight() * 0.76));
                    break;

                case DEC:

                default:
                    valueLayout = new TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(formatLcdValue(getLcdValue()), (float) (LCD.getX() + (LCD.getWidth() - unitStringWidth - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09), (float) (LCD.getY() + LCD.getHeight() * 0.76));
                    break;
            }
            // Draw lcd info string
            if (!getLcdInfoString().isEmpty()) {
                G2.setFont(getLcdInfoFont());
                infoLayout = new TextLayout(getLcdInfoString(), G2.getFont(), RENDER_CONTEXT);
                INFO_BOUNDARY.setFrame(infoLayout.getBounds());
                G2.drawString(getLcdInfoString(), LCD.getBounds().x + 5f, LCD.getBounds().y + (float) INFO_BOUNDARY.getHeight() + 5f);
            }
        }

        // Draw the 10000ft pointer
        //final double ANGLE10000FT = ((value10000 - getMinValue()) * angleStep10000ft);
        G2.rotate(((value10000 - getMinValue()) * angleStep10000ft), CENTER.getX(), CENTER.getY());
        G2.drawImage(pointer10000FtImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw the 1000ft pointer
        //final double ANGLE1000FT = ((value1000 - getMinValue()) * angleStep1000ft);
        G2.rotate(((value1000 - getMinValue()) * angleStep1000ft), CENTER.getX(), CENTER.getY());
        G2.drawImage(pointer1000FtImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw the 100ft pointer
        //final double ANGLE100FT = ((value100 - getMinValue()) * angleStep100ft);
        G2.rotate(((value100 - getMinValue()) * angleStep100ft), CENTER.getX(), CENTER.getY());
        G2.drawImage(pointer100FtImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw combined foreground image
        G2.drawImage(fImage, 0, 0, null);

        if (!isEnabled()) {
            G2.drawImage(disabledImage, 0, 0, null);
        }

        // Translate the coordinate system back to original
        G2.translate(-getInnerBounds().x, -getInnerBounds().y);

        G2.dispose();
    }
289185
protected void paintBackground (Graphics g)
    {
        // simply fill our background color
        g.setColor(getBackground());
        g.fillRect(0, 0, getWidth(), getHeight());
    }
43899
public void paint(Graphics g)
    {
        g.drawImage(image, 0, 0, this);
        
        // Notify method splash that the window has been painted.
        if (! paintCalled) {
            paintCalled = true;
            synchronized (this)
            {
                notifyAll();
            }
        }
    }
837120
public void render(OutputStream target, Graph graph) throws IOException {
		
		BufferedImage bi = 
			new BufferedImage(graph.width, graph.height, 
					GraphConfiguration.imageType);
		Graphics2D g2d = bi.createGraphics();
		graph.draw(g2d);
	    ImageIO.write(bi, "png", target);
	}
577114
protected void renderLayer (Graphics2D g, Rectangle bounds, JLayeredPane pane,
                                boolean[] clipped, Integer layer)
    {
        // stop now if there are no components in that layer
        int ccount = pane.getComponentCountInLayer(layer.intValue());
        if (ccount == 0) {
            return;
        }

        // render them up
        Component[] comps = pane.getComponentsInLayer(layer.intValue());
        for (int ii = 0; ii < ccount; ii++) {
            Component comp = comps[ii];
            if (!comp.isVisible() || comp instanceof SafeLayerComponent) {
                continue;
            }

            // if this overlay does not intersect the component we just rendered, we don't need to
            // repaint it
            Rectangle compBounds = new Rectangle(0, 0, comp.getWidth(), comp.getHeight());
            getRoot(comp, compBounds);
            if (!compBounds.intersects(bounds)) {
                continue;
            }

            // if the clipping region has not yet been set during this render pass, the time has
            // come to do so
            if (!clipped[0]) {
                g.setClip(bounds);
                clipped[0] = true;
            }

            // translate into the components coordinate system and render
            g.translate(compBounds.x, compBounds.y);
            try {
                comp.paint(g);
            } catch (Exception e) {
                log.warning("Component choked while rendering.", e);
            }
            g.translate(-compBounds.x, -compBounds.y);
        }
    }
616483
public void paint (Graphics2D gfx)
    {
        gfx.setColor(Color.red);
        Point prev = null;
        int size = size();
        for (int ii = 0; ii < size; ii++) {
            PathNode n = getNode(ii);
            if (prev != null) {
                gfx.drawLine(prev.x, prev.y, n.loc.x, n.loc.y);
            }
            prev = n.loc;
        }
    }
183605
protected void paint(SeaGlassContext context, Graphics g) {
        AbstractButton b = (AbstractButton) context.getComponent();

        g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(context, g, b.getText(), getIcon(b), b.getHorizontalAlignment(),
                                                               b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                                                               b.getVerticalTextPosition(), b.getIconTextGap(),
                                                               b.getDisplayedMnemonicIndex(), getTextShiftOffset(context));
    }
416559
public void paint (Graphics2D gfx)
    {
        int x = (int)(_center.x - _xradius), y = (int)(_center.y - _yradius);
        int width = (int)(2*_xradius), height = (int)(2*_yradius);
        int sangle = (int)(Math.round(180 * _sangle / Math.PI)),
            delta = (int)(Math.round(180 * _delta / Math.PI));

        gfx.setColor(Color.blue);
        gfx.drawRect(x, y, width-1, height-1);

        gfx.setColor(Color.yellow);
        gfx.drawArc(x, y, width-1, height-1, 0, 360);

        gfx.setColor(Color.red);
        gfx.drawArc(x, y, width-1, height-1, 360-sangle, -delta);
    }
449010
public Graphics2D renderContent(Graphics2D g)
    {

        if (g.getClip() == null)
            throw new NullPointerException(
                    "Clip is not set on graphics context");
        ViewFactory factory = getEditorKit().getViewFactory();
        if (factory instanceof SwingBoxViewFactory)
        {
            View view = ((SwingBoxViewFactory) factory).getViewport();
            if (view != null) view.paint(g, g.getClip());
        }

        return g;
    }
1179589
public void paint (Graphics2D gfx)
    {
        gfx.setColor(Color.red);
        gfx.drawLine(_source.x, _source.y, _dest.x, _dest.y);
    }
1161166
private void shearY(Graphics g, int w1, int h1, Color color) {

		int period = RandomUtil.randomInt(40) + 10; // 50;

		boolean borderGap = true;
		int frames = 20;
		int phase = 7;
		for (int i = 0; i < w1; i++) {
			double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
			g.copyArea(i, 0, 1, h1, 0, (int) d);
			if (borderGap) {
				g.setColor(color);
				g.drawLine(i, (int) d, i, 0);
				g.drawLine(i, (int) d + h1, i, h1);
			}

		}

	}
147132
public void paintComponent(Graphics g)
	{
		super.paintComponent(g);

		// setup the graphics
		Graphics2D _g2 = (Graphics2D) (g.create());
		_g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		AffineTransform _at = computeTransformation(true);
		_g2.transform(_at);

		// do the drawing
		paintPaper(_g2);

		if (null != getContent())
		{
			getContent().paint(_g2);
		}
	}