Example usage for java.awt Graphics2D getPaint

List of usage examples for java.awt Graphics2D getPaint

Introduction

In this page you can find the example usage for java.awt Graphics2D getPaint.

Prototype

public abstract Paint getPaint();

Source Link

Document

Returns the current Paint of the Graphics2D context.

Usage

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

/**
 * Draws zoom rectangle (if present)./*from   w ww  . j  a  va  2s  . co m*/
 * The drawing is performed in XOR mode, therefore
 * when this method is called twice in a row,
 * the second call will completely restore the state
 * of the canvas.
 *
 * @param g2 the graphics device.
 */
private void drawCoElutionRegion(Graphics2D g2) {
    // Set XOR mode to draw the zoom rectangle
    if (g2 == null)
        return;
    Paint origColor = g2.getPaint();
    //        g2.setXORMode(Color.gray);
    g2.setXORMode(new Color(30, 10, 30, 5));
    if (this.coElutionRegion != null) {
        g2.fill(this.coElutionRegion);
        g2.setPaint(Color.white);
        g2.setStroke(new BasicStroke(3.0f));
        g2.draw(this.coElutionRegion);
    }
    g2.setPaintMode();
    g2.setPaint(origColor);
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private void drawMarker(Point2D.Double point, Graphics2D g2, Color color) {
    Stroke oldStroke = g2.getStroke();
    Paint oldPaint = g2.getPaint();
    g2.setPaint(color);// w  w w . ja  va 2s  . com
    //Shape line = new Line2D.Double(point, point);
    Shape marker = new Ellipse2D.Double(point.getX() - 1.5, point.getY() - 1.5, 3, 3);
    g2.fill(marker);
    g2.setPaint(oldPaint);
}

From source file:com.projity.pm.graphic.gantt.GanttRenderer.java

public void paintNonWorkingDays(Graphics2D g2, Rectangle bounds) {
    BarFormat calFormat = getCalendarFormat();
    if (calFormat == null)
        return;/*from   w  w  w. ja va2s.co  m*/
    //non working days
    Color oldColor = g2.getColor();
    Paint oldPaint = g2.getPaint();
    CoordinatesConverter coord = ((GanttParams) graphInfo).getCoord();
    Project project = coord.getProject();
    WorkingCalendar wc = (WorkingCalendar) project.getWorkCalendar();

    if (coord.getTimescaleManager().isShowWholeDays()) {
        boolean useScale2 = coord.getTimescaleManager().getCurrentScaleIndex() == 0; //valid only for current time scales
        TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), useScale2);
        long startNonworking = -1L, endNonWorking = -1L;
        Calendar cal = DateTime.calendarInstance();

        PredefinedPaint paint = (PredefinedPaint) calFormat.getMiddle().getPaint();//new PredefinedPaint(PredefinedPaint.DOT_LINE,Colors.VERY_LIGHT_GRAY,Color.WHITE);
        paint.applyPaint(g2, useTextures());
        while (i.hasNext()) {
            TimeInterval interval = i.next();
            long s = interval.getStart();
            if (CalendarService.getInstance().getDay(wc, s).isWorking()) {
                if (startNonworking != -1L) {
                    drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2);
                    startNonworking = endNonWorking = -1L;
                }
            } else {
                if (startNonworking == -1L)
                    startNonworking = s;
                endNonWorking = s;

            }
        }
        if (startNonworking != -1L) {
            drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2);
            startNonworking = endNonWorking = -1L;
        }
    }

    if (container != null) {
        //scale2 separation lines
        TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), true);
        g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GRAY, g2.getBackground()));
        while (i.hasNext()) {
            TimeInterval interval = i.next();
            int startX = (int) Math.round(coord.toX(interval.getStart()));
            g2.drawLine(startX, bounds.y, startX, bounds.y + bounds.height);
        }

        //project start
        int projectStartX = (int) Math.round(coord.toX(project.getStart()));
        if (projectStartX >= bounds.getX() && projectStartX <= bounds.getMaxX()) {
            g2.setPaint(new PredefinedPaint(PredefinedPaint.DASH_LINE, Color.GRAY, g2.getBackground()));
            g2.drawLine(projectStartX, bounds.y, projectStartX, bounds.y + bounds.height);
        }

        //project start
        long statusDate = project.getStatusDate();
        if (statusDate != 0) {
            int statusDateX = (int) Math.round(coord.toX(statusDate));
            if (statusDateX >= bounds.getX() && statusDateX <= bounds.getMaxX()) {
                g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GREEN, g2.getBackground()));
                g2.drawLine(statusDateX, bounds.y, statusDateX, bounds.y + bounds.height);
            }
        }

        if (oldColor != null)
            g2.setColor(oldColor);
        if (oldPaint != null)
            g2.setPaint(oldPaint);

    }
}

From source file:de.tor.tribes.ui.algo.TimeFrameVisualizer.java

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (mTimeFrame == null) {
        renderNoInfoView(g);/*from  w w  w .j  a v  a 2 s  . c  o m*/
    } else {
        updateSize();
        LongRange startRange = mTimeFrame.getStartRange();
        LongRange arriveRange = mTimeFrame.getArriveRange();
        HashMap<LongRange, TimeSpan> startRanges = mTimeFrame
                .startTimespansToRangesMap(AnyTribe.getSingleton());
        HashMap<LongRange, TimeSpan> arriveRanges = mTimeFrame.arriveTimespansToRangesMap(null);
        long minValue = startRange.getMinimumLong();
        long maxValue = arriveRange.getMaximumLong();
        Graphics2D g2d = (Graphics2D) g;
        g2d.setPaint(new TexturePaint(STROKED, new Rectangle(0, 0, 3, 3)));
        g2d.fillRect(0, 0, getWidth(), getHeight());

        //draw frame around the entire range
        renderRange(new LongRange(startRange.getMinimumLong(), arriveRange.getMaximumLong()), startRange,
                arriveRange, false, false, g2d, null, popupInfo);
        g2d.setColor(Constants.DS_BACK);
        popupInfo.clear();
        //fill start range
        renderRange(startRange, startRange, arriveRange, true, false, g2d, null, popupInfo);
        //fill arrive range
        renderRange(arriveRange, startRange, arriveRange, false, true, g2d, null, popupInfo);
        Paint p = g2d.getPaint();
        Iterator<LongRange> rangeKeys = startRanges.keySet().iterator();
        while (rangeKeys.hasNext()) {
            LongRange currentRange = rangeKeys.next();

            TimeSpan spanForRange = startRanges.get(currentRange);
            if (spanForRange != null) {
                if (spanForRange.isValidAtEveryDay()) {
                    g2d.setPaint(new TexturePaint(DAILY_START_FRAME_FILL, new Rectangle(0, 0, 3, 3)));
                } else if (spanForRange.isValidAtExactTime()) {
                    g2d.setPaint(new TexturePaint(EXACT_START_FRAME_FILL, new Rectangle(0, 0, 3, 3)));
                } else {
                    g2d.setPaint(new TexturePaint(ONE_DAY_START_FRAME_FILL, new Rectangle(0, 0, 3, 3)));
                }
            }
            renderRange(currentRange, startRange, arriveRange, false, false, g2d, spanForRange, popupInfo);
        }

        Composite c = g2d.getComposite();
        rangeKeys = arriveRanges.keySet().iterator();
        while (rangeKeys.hasNext()) {
            LongRange currentRange = rangeKeys.next();
            g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
            g2d.setPaint(new TexturePaint(ARRIVE_FRAME_FILL, new Rectangle(0, 0, 3, 3)));
            TimeSpan spanForRange = arriveRanges.get(currentRange);
            renderRange(currentRange, startRange, arriveRange, false, false, g2d, spanForRange, popupInfo);
        }
        g2d.setComposite(c);
        g2d.setPaint(p);
        renderDayMarkers(minValue, maxValue, g2d);
        renderPopup(popupInfo, g2d);
    }
}

From source file:edu.uci.ics.jung.visualization.PluggableRenderer.java

public void paintShapeForVertex(Graphics2D g2d, Vertex v, Shape shape) {
    Paint oldPaint = g2d.getPaint();
    Paint fillPaint = vertexPaintFunction.getFillPaint(v);
    if (fillPaint != null) {
        g2d.setPaint(fillPaint);//w  ww .  j a va 2 s.  c  o  m
        g2d.fill(shape);
        g2d.setPaint(oldPaint);
    }
    Paint drawPaint = vertexPaintFunction.getDrawPaint(v);
    if (drawPaint != null) {
        g2d.setPaint(drawPaint);
        g2d.draw(shape);
        g2d.setPaint(oldPaint);
    }
}

From source file:edu.uci.ics.jung.visualization.PluggableRenderer.java

/**
 * Draws the edge <code>e</code>, whose endpoints are at <code>(x1,y1)</code>
 * and <code>(x2,y2)</code>, on the graphics context <code>g</code>.
 * The <code>Shape</code> provided by the <code>EdgeShapeFunction</code> instance
 * is scaled in the x-direction so that its width is equal to the distance between
 * <code>(x1,y1)</code> and <code>(x2,y2)</code>.
 *///from   w w  w  .j a v  a  2  s  .  com
protected void drawSimpleEdge(Graphics2D g, Edge e, int x1, int y1, int x2, int y2) {
    Pair endpoints = e.getEndpoints();
    Vertex v1 = (Vertex) endpoints.getFirst();
    Vertex v2 = (Vertex) endpoints.getSecond();
    boolean isLoop = v1.equals(v2);
    Shape s2 = vertexShapeFunction.getShape(v2);
    Shape edgeShape = edgeShapeFunction.getShape(e);

    boolean edgeHit = true;
    boolean arrowHit = true;
    Rectangle deviceRectangle = null;
    if (screenDevice != null) {
        Dimension d = screenDevice.getSize();
        if (d.width <= 0 || d.height <= 0) {
            d = screenDevice.getPreferredSize();
        }
        deviceRectangle = new Rectangle(0, 0, d.width, d.height);
    }

    AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1);

    if (isLoop) {
        // this is a self-loop. scale it is larger than the vertex
        // it decorates and translate it so that its nadir is
        // at the center of the vertex.
        Rectangle2D s2Bounds = s2.getBounds2D();
        xform.scale(s2Bounds.getWidth(), s2Bounds.getHeight());
        xform.translate(0, -edgeShape.getBounds2D().getWidth() / 2);
    } else {
        // this is a normal edge. Rotate it to the angle between
        // vertex endpoints, then scale it to the distance between
        // the vertices
        float dx = x2 - x1;
        float dy = y2 - y1;
        float thetaRadians = (float) Math.atan2(dy, dx);
        xform.rotate(thetaRadians);
        float dist = (float) Math.sqrt(dx * dx + dy * dy);
        xform.scale(dist, 1.0);
    }

    edgeShape = xform.createTransformedShape(edgeShape);

    edgeHit = viewTransformer.transform(edgeShape).intersects(deviceRectangle);

    if (edgeHit == true) {

        Paint oldPaint = g.getPaint();

        // get Paints for filling and drawing
        // (filling is done first so that drawing and label use same Paint)
        Paint fill_paint = edgePaintFunction.getFillPaint(e);
        if (fill_paint != null) {
            g.setPaint(fill_paint);
            g.fill(edgeShape);
        }
        Paint draw_paint = edgePaintFunction.getDrawPaint(e);
        if (draw_paint != null) {
            g.setPaint(draw_paint);
            g.draw(edgeShape);
        }

        float scalex = (float) g.getTransform().getScaleX();
        float scaley = (float) g.getTransform().getScaleY();
        // see if arrows are too small to bother drawing
        if (scalex < .3 || scaley < .3)
            return;

        if (edgeArrowPredicate.evaluate(e)) {

            Shape destVertexShape = vertexShapeFunction.getShape((Vertex) e.getEndpoints().getSecond());
            AffineTransform xf = AffineTransform.getTranslateInstance(x2, y2);
            destVertexShape = xf.createTransformedShape(destVertexShape);

            arrowHit = viewTransformer.transform(destVertexShape).intersects(deviceRectangle);
            if (arrowHit) {

                AffineTransform at;
                if (edgeShape instanceof GeneralPath)
                    at = getArrowTransform((GeneralPath) edgeShape, destVertexShape);
                else
                    at = getArrowTransform(new GeneralPath(edgeShape), destVertexShape);
                if (at == null)
                    return;
                Shape arrow = edgeArrowFunction.getArrow(e);
                arrow = at.createTransformedShape(arrow);
                // note that arrows implicitly use the edge's draw paint
                g.fill(arrow);
            }
            if (e instanceof UndirectedEdge) {
                Shape vertexShape = vertexShapeFunction.getShape((Vertex) e.getEndpoints().getFirst());
                xf = AffineTransform.getTranslateInstance(x1, y1);
                vertexShape = xf.createTransformedShape(vertexShape);

                arrowHit = viewTransformer.transform(vertexShape).intersects(deviceRectangle);

                if (arrowHit) {
                    AffineTransform at;
                    if (edgeShape instanceof GeneralPath)
                        at = getReverseArrowTransform((GeneralPath) edgeShape, vertexShape, !isLoop);
                    else
                        at = getReverseArrowTransform(new GeneralPath(edgeShape), vertexShape, !isLoop);
                    if (at == null)
                        return;
                    Shape arrow = edgeArrowFunction.getArrow(e);
                    arrow = at.createTransformedShape(arrow);
                    g.fill(arrow);
                }
            }
        }
        // use existing paint for text if no draw paint specified
        if (draw_paint == null)
            g.setPaint(oldPaint);
        String label = edgeStringer.getLabel(e);
        if (label != null) {
            labelEdge(g, e, label, x1, x2, y1, y2);
        }

        // restore old paint
        g.setPaint(oldPaint);
    }
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/** {@inheritDoc} */
public void paintComponent(final Graphics graphics) {
    Graphics2D g = (Graphics2D) graphics;
    Paint oldPaint = g.getPaint();
    g.setPaint(backgroundColor);/*from   ww  w.  j a  v  a2s  .  c o m*/
    g.fill(getBounds());
    g.setPaint(oldPaint);
}

From source file:org.dwfa.ace.graph.AceGraphRenderer.java

/**
 * Draws the edge <code>e</code>, whose endpoints are at
 * <code>(x1,y1)</code> and <code>(x2,y2)</code>, on the graphics context
 * <code>g</code>.//  www . j a v  a  2  s. co m
 * The <code>Shape</code> provided by the <code>EdgeShapeFunction</code>
 * instance
 * is scaled in the x-direction so that its width is equal to the distance
 * between <code>(x1,y1)</code> and <code>(x2,y2)</code>.
 */
protected void drawSimpleEdge(Graphics2D g, Edge e, int x1, int y1, int x2, int y2) {
    Pair endpoints = e.getEndpoints();
    Vertex v1 = (Vertex) endpoints.getFirst();
    Vertex v2 = (Vertex) endpoints.getSecond();
    boolean isLoop = v1.equals(v2);
    Shape s2 = vertexShapeFunction.getShape(v2);
    Shape edgeShape = edgeShapeFunction.getShape(e);

    boolean edgeHit = true;
    boolean arrowHit = true;
    Rectangle deviceRectangle = null;
    if (screenDevice != null) {
        Dimension d = screenDevice.getSize();
        if (d.width <= 0 || d.height <= 0) {
            d = screenDevice.getPreferredSize();
        }
        deviceRectangle = new Rectangle(0, 0, d.width, d.height);
    }

    AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1);

    if (isLoop) {
        // this is a self-loop. scale it is larger than the vertex
        // it decorates and translate it so that its nadir is
        // at the center of the vertex.
        Rectangle2D s2Bounds = s2.getBounds2D();
        xform.scale(s2Bounds.getWidth(), s2Bounds.getHeight());
        xform.translate(0, -edgeShape.getBounds2D().getWidth() / 2);
    } else {
        // this is a normal edge. Rotate it to the angle between
        // vertex endpoints, then scale it to the distance between
        // the vertices
        float dx = x2 - x1;
        float dy = y2 - y1;
        float thetaRadians = (float) Math.atan2(dy, dx);
        xform.rotate(thetaRadians);
        float dist = (float) Math.sqrt(dx * dx + dy * dy);
        xform.scale(dist, 1.0);
    }

    edgeShape = xform.createTransformedShape(edgeShape);

    if (deviceRectangle == null) {
        edgeHit = false;
    } else {
        edgeHit = viewTransformer.transform(edgeShape).intersects(deviceRectangle);
    }

    if (edgeHit == true) {

        Paint oldPaint = g.getPaint();

        // get Paints for filling and drawing
        // (filling is done first so that drawing and label use same Paint)
        Paint fill_paint = edgePaintFunction.getFillPaint(e);
        if (fill_paint != null) {
            g.setPaint(fill_paint);
            g.fill(edgeShape);
        }
        Paint draw_paint = edgePaintFunction.getDrawPaint(e);
        if (draw_paint != null) {
            g.setPaint(draw_paint);
            g.draw(edgeShape);
        }

        float scalex = (float) g.getTransform().getScaleX();
        float scaley = (float) g.getTransform().getScaleY();
        // see if arrows are too small to bother drawing
        if (scalex < .3 || scaley < .3)
            return;

        if (edgeArrowPredicate.evaluate(e)) {

            Shape destVertexShape = vertexShapeFunction.getShape((Vertex) e.getEndpoints().getSecond());
            AffineTransform xf = AffineTransform.getTranslateInstance(x2, y2);
            destVertexShape = xf.createTransformedShape(destVertexShape);

            arrowHit = viewTransformer.transform(destVertexShape).intersects(deviceRectangle);
            if (arrowHit) {

                AffineTransform at;
                if (edgeShape instanceof GeneralPath)
                    at = getArrowTransform((GeneralPath) edgeShape, destVertexShape);
                else
                    at = getArrowTransform(new GeneralPath(edgeShape), destVertexShape);
                if (at == null)
                    return;
                Shape arrow = edgeArrowFunction.getArrow(e);
                arrow = at.createTransformedShape(arrow);
                // note that arrows implicitly use the edge's draw paint
                g.fill(arrow);
            }
            if (e instanceof UndirectedEdge) {
                Shape vertexShape = vertexShapeFunction.getShape((Vertex) e.getEndpoints().getFirst());
                xf = AffineTransform.getTranslateInstance(x1, y1);
                vertexShape = xf.createTransformedShape(vertexShape);

                arrowHit = viewTransformer.transform(vertexShape).intersects(deviceRectangle);

                if (arrowHit) {
                    AffineTransform at;
                    if (edgeShape instanceof GeneralPath)
                        at = getReverseArrowTransform((GeneralPath) edgeShape, vertexShape, !isLoop);
                    else
                        at = getReverseArrowTransform(new GeneralPath(edgeShape), vertexShape, !isLoop);
                    if (at == null)
                        return;
                    Shape arrow = edgeArrowFunction.getArrow(e);
                    arrow = at.createTransformedShape(arrow);
                    g.fill(arrow);
                }
            }
        }
        // use existing paint for text if no draw paint specified
        if (draw_paint == null)
            g.setPaint(oldPaint);
        String label = edgeStringer.getLabel(e);
        if (label != null) {
            labelEdge(g, e, label, x1, x2, y1, y2);
        }

        // restore old paint
        g.setPaint(oldPaint);
    }
}

From source file:org.processmining.analysis.performance.sequence.Pattern.java

/**
 * Draws a rectangle of width 20, height length and starting point
 * (startX,startY) in the northwest corner of the rectangle. In case
 * logicSteps is true, the height is 10.
 * // w  ww  .  j a v a  2 s . c  om
 * @param startX
 *            double
 * @param startY
 *            double
 * @param length
 *            double
 * @param logicSteps
 *            boolean
 * @param g
 *            Graphics2D
 */
public void drawRectangle(double startX, double startY, double length, boolean logicSteps, Graphics2D g) {
    Rectangle2D r = new Rectangle2D.Double(startX, startY, 20, length);
    if (logicSteps) {
        r = new Rectangle2D.Double(startX, startY, 20, 10);
    }
    Color initialColor = g.getColor();
    Paint initialPaint = g.getPaint();
    GradientPaint towhite = new GradientPaint(((Double) startX).floatValue(), ((Double) startY).floatValue(),
            initialColor, ((Double) startX).floatValue() + 20, ((Double) (startY)).floatValue(), Color.WHITE);
    g.setPaint(towhite);
    g.fill(r);
    g.setPaint(initialPaint);
    g.setColor(Color.BLACK);
    g.draw(r);
    g.setColor(initialColor);
}

From source file:statechum.analysis.learning.Visualiser.java

protected static PluggableRenderer constructRenderer(Graph g, final LayoutOptions options) {
    final LayoutOptions graphLayoutOptions = options != null ? options : new LayoutOptions();

    PluggableRenderer r = new PluggableRenderer() {
        /**/* www .  j a va2s  .  co  m*/
         * Draws the edge <code>e</code>, whose endpoints are at <code>(x1,y1)</code>
         * and <code>(x2,y2)</code>, on the graphics context <code>g</code>.
         * The <code>Shape</code> provided by the <code>EdgeShapeFunction</code> instance
         * is scaled in the x-direction so that its width is equal to the distance between
         * <code>(x1,y1)</code> and <code>(x2,y2)</code>.
         */
        @Override
        protected void drawSimpleEdge(Graphics2D g2d, Edge e, int x1, int y1, int x2, int y2) {
            final Vertex v1 = (Vertex) e.getEndpoints().getFirst();
            final Vertex v2 = (Vertex) e.getEndpoints().getSecond();
            boolean isLoop = v1.equals(v2);
            final Shape s2 = vertexShapeFunction.getShape(v2);
            Shape edgeShape = edgeShapeFunction.getShape(e);
            final double dx = x2 - x1;
            final double dy = y2 - y1;

            boolean edgeHit = true;
            boolean arrowHit = true;
            Rectangle deviceRectangle = null;
            if (screenDevice != null) {
                Dimension d = screenDevice.getSize();
                if (d.width <= 0 || d.height <= 0) {
                    d = screenDevice.getPreferredSize();
                }
                deviceRectangle = new Rectangle(0, 0, d.width, d.height);
            }

            String label = edgeStringer.getLabel(e);
            assert (label != null);
            Component labelComponent = prepareRenderer(graphLabelRenderer, label, isPicked(e), e);
            Dimension d = labelComponent.getPreferredSize();
            Rectangle2D EdgeShapeBoundaries = edgeShape.getBounds2D();
            AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1);
            double yMin = 0, yMax = 0;
            double thetaRadians = 0;
            if (isLoop) {
                // this is a self-loop. scale it is larger than the vertex
                // it decorates and translate it so that its nadir is
                // at the center of the vertex.
                int edgeIndex = ParallelEdgeIndexSingleton.getInstance().getIndex(e);
                Rectangle2D s2Bounds = s2.getBounds2D();
                double scaleBy = 1 + (graphLayoutOptions.scaleLines - 1) * 1. / 3.;
                double translation = s2Bounds.getHeight() * (1. / 4. + edgeIndex / 4.);

                xform.translate(0, -scaleBy * translation);
                xform.scale(scaleBy * s2Bounds.getWidth(), scaleBy * s2Bounds.getHeight());
                yMin = scaleBy * (EdgeShapeBoundaries.getMinY() * s2Bounds.getHeight()) - translation;
                yMax = scaleBy * (EdgeShapeBoundaries.getMaxY() * s2Bounds.getHeight()) - translation;

            } else {
                // this is a normal edge. Rotate it to the angle between
                // vertex endpoints, then scale it to the distance between
                // the vertices
                thetaRadians = Math.atan2(dy, dx);
                double dist = Math.sqrt(dx * dx + dy * dy);
                xform.rotate(thetaRadians);
                xform.scale(dist, 1.0);
                yMin = EdgeShapeBoundaries.getMinY();
                yMax = EdgeShapeBoundaries.getMaxY();
            }

            edgeShape = xform.createTransformedShape(edgeShape);
            // Debug code
            /*
            if (!isLoop)
            {
            g2d.setPaint(new Color( 250, 250, 0));
               AffineTransform rect = AffineTransform.getTranslateInstance(x1, y1+yMin);
               rect.rotate(thetaRadians);
               g2d.fill(rect.createTransformedShape(
              new Rectangle(0,0,(int)Math.sqrt(dx*dx + dy*dy),(int)(yMax-yMin))));
            }
            else
            {
            g2d.setPaint(new Color( 100, 250, 0));
            AffineTransform rect = AffineTransform.getTranslateInstance(x1-s2.getBounds2D().getWidth()/2, y1+yMin);
               rect.rotate(thetaRadians);
               g2d.fill(rect.createTransformedShape(
              new Rectangle(0,0,(int)s2.getBounds2D().getWidth(),(int)(yMax-yMin))));
            }*/

            edgeHit = viewTransformer.transform(edgeShape).intersects(deviceRectangle);

            if (edgeHit == true) {
                Paint oldPaint = g2d.getPaint();

                // get Paints for filling and drawing
                // (filling is done first so that drawing and label use same Paint)
                Paint fill_paint = edgePaintFunction.getFillPaint(e);
                if (fill_paint != null) {
                    g2d.setPaint(fill_paint);
                    g2d.fill(edgeShape);
                }
                Paint draw_paint = edgePaintFunction.getDrawPaint(e);
                if (draw_paint != null) {
                    g2d.setPaint(draw_paint);
                    g2d.draw(edgeShape);
                }

                double scalex = g2d.getTransform().getScaleX();
                double scaley = g2d.getTransform().getScaleY();
                // see if arrows are too small to bother drawing
                if (scalex < .3 || scaley < .3)
                    return;

                if (edgeArrowPredicate.evaluate(e)) {

                    Shape destVertexShape = vertexShapeFunction.getShape((Vertex) e.getEndpoints().getSecond());
                    AffineTransform xf = AffineTransform.getTranslateInstance(x2, y2);
                    destVertexShape = xf.createTransformedShape(destVertexShape);

                    arrowHit = viewTransformer.transform(destVertexShape).intersects(deviceRectangle);
                    if (arrowHit) {

                        AffineTransform at;
                        if (edgeShape instanceof GeneralPath)
                            at = getArrowTransform((GeneralPath) edgeShape, destVertexShape);
                        else
                            at = getArrowTransform(new GeneralPath(edgeShape), destVertexShape);
                        if (at == null)
                            return;
                        Shape arrow = edgeArrowFunction.getArrow(e);
                        arrow = at.createTransformedShape(arrow);
                        // note that arrows implicitly use the edge's draw paint
                        g2d.fill(arrow);
                    }
                    assert !(e instanceof UndirectedEdge);
                }

                // For difference visualisation only
                boolean labelBelow = false;
                if (graphLayoutOptions.showDIFF && (draw_paint == null
                        || draw_paint instanceof Color && ((Color) draw_paint).equals(Color.BLACK)))
                    labelBelow = true;

                // Now draw the label.
                double xLabel = 0, yLabel = 0, xa = 0, ya = 0, rotation = thetaRadians;
                if (isLoop) {
                    double displacementY = labelBelow ? -yMin + d.height : -yMin + d.height,
                            displacementX = d.width / 2;
                    xa = x1 + dx / 2 + displacementY * Math.sin(thetaRadians);
                    ya = y1 + dy / 2 - displacementY * Math.cos(thetaRadians);
                    xLabel = xa - displacementX * Math.cos(thetaRadians);
                    yLabel = ya - displacementX * Math.sin(thetaRadians);
                } else if (dx < 0) {
                    double displacementY = labelBelow ? yMax - d.height : (-yMax - d.height),
                            displacementX = d.width / 2;
                    xa = x1 + dx / 2 + displacementY * Math.sin(thetaRadians);
                    ya = y1 + dy / 2 - displacementY * Math.cos(thetaRadians);
                    xLabel = xa + displacementX * Math.cos(thetaRadians);
                    yLabel = ya + displacementX * Math.sin(thetaRadians);
                    rotation = thetaRadians + Math.PI;
                } else {
                    double displacementY = labelBelow ? yMax : -yMax, displacementX = d.width / 2;
                    xa = x1 + dx / 2 + displacementY * Math.sin(thetaRadians);
                    ya = y1 + dy / 2 - displacementY * Math.cos(thetaRadians);
                    xLabel = xa - displacementX * Math.cos(thetaRadians);
                    yLabel = ya - displacementX * Math.sin(thetaRadians);
                }

                AffineTransform old = g2d.getTransform();
                AffineTransform labelTransform = new AffineTransform();
                // Debug code: 
                //g2d.drawLine((int)(x1+dx/2), (int)(y1+dy/2), (int)(xa), (int)(ya));g2d.drawLine((int)(xa), (int)(ya), (int)(xLabel), (int)(yLabel));
                labelTransform.translate(xLabel, yLabel);
                labelTransform.rotate(rotation);
                g2d.setTransform(labelTransform);
                rendererPane.paintComponent(g2d, labelComponent, screenDevice, 0, 0, d.width, d.height, true);
                g2d.setTransform(old);

                // restore old paint
                g2d.setPaint(oldPaint);
            } // if edgeHit == true
        }
    };
    r = labelEdges(g, r, graphLayoutOptions);
    r = labelVertices(r, g, graphLayoutOptions);
    r.setVertexIncludePredicate(new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            if (!graphLayoutOptions.showIgnored && graphLayoutOptions.ignoredStates != null
                    && graphLayoutOptions.ignoredStates.contains(object.toString()))
                return false;

            if (graphLayoutOptions.showNegatives)
                return true;
            else
                return DeterministicDirectedSparseGraph.isAccept((Vertex) object);
        }
    });
    return r;
}