Example usage for java.awt.geom Arc2D OPEN

List of usage examples for java.awt.geom Arc2D OPEN

Introduction

In this page you can find the example usage for java.awt.geom Arc2D OPEN.

Prototype

int OPEN

To view the source code for java.awt.geom Arc2D OPEN.

Click Source Link

Document

The closure type for an open arc with no path segments connecting the two ends of the arc segment.

Usage

From source file:org.forester.archaeopteryx.TreePanel.java

final private void drawArc(final double x, final double y, final double width, final double heigth,
        final double start_angle, final double arc_angle, final Graphics2D g) {
    _arc.setArc(x, y, width, heigth, _180_OVER_PI * start_angle, _180_OVER_PI * arc_angle, Arc2D.OPEN);
    g.draw(_arc);//from w  w  w  . j a va 2s .  c  o m
}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Internal implementation to add an image (a world map, though other image data is also fine) to a slide.
 *   Preserves the original image's aspect ratio, leaving blank space below and to the sides of the image.
 * @param slide the slide to add to.// www  .j a v a  2 s .c o  m
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param picture the picture data.
 * @param markers an array of markers to draw over the map.
 * @param polygons
 * @return the picture shape object added to the slide.
 */
private static XSLFPictureShape addMap(final XSLFSlide slide, final Rectangle2D.Double anchor,
        final XSLFPictureData picture, final Marker[] markers, final MapData.Polygon[] polygons) {
    double tgtW = anchor.getWidth(), tgtH = anchor.getHeight();

    final Dimension size = picture.getImageDimension();
    final double ratio = size.getWidth() / size.getHeight();

    if (ratio > tgtW / tgtH) {
        // source image is wider than target, clip fixed width variable height
        tgtH = tgtW / ratio;
    } else {
        tgtW = tgtH * ratio;
    }

    final XSLFPictureShape canvas = slide.createPicture(picture);
    // Vertically align top, horizontally-align center
    final double offsetX = anchor.getMinX() + 0.5 * (anchor.getWidth() - tgtW), offsetY = anchor.getMinY();
    canvas.setAnchor(new Rectangle2D.Double(offsetX, offsetY, tgtW, tgtH));

    if (polygons != null) {
        for (MapData.Polygon polygon : polygons) {
            final Color color = Color.decode(polygon.getColor());
            final double[][] shapes = polygon.getPoints();
            // The ESRI spec version 1.2.1 from http://www.opengeospatial.org/standards/sfa has section 6.1.11.1,
            //    which defines polygons as follows:
            /// A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries.
            //    Each interior boundary defines a hole in the Polygon. A Triangle is a polygon with 3 distinct,
            //    non-collinear vertices and no interior boundary.
            /// The exterior boundary LinearRing defines the top? of the surface which is the side of the surface
            //    from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.
            //    The interior LinearRings will have the opposite orientation, and appear as clockwise
            //    when viewed from the top?
            // so it's even-odd winding (whereas the Path2D default is non-zero-winding).
            final Path2D.Double path = new Path2D.Double(Path2D.WIND_EVEN_ODD);

            for (final double[] points : shapes) {
                for (int ii = 0; ii < points.length; ii += 2) {
                    final double x1 = offsetX + points[ii] * tgtW;
                    final double y1 = offsetY + points[ii + 1] * tgtH;
                    if (ii == 0) {
                        path.moveTo(x1, y1);
                    } else {
                        path.lineTo(x1, y1);
                    }
                }
                path.closePath();
            }

            final XSLFFreeformShape freeform = slide.createFreeform();
            freeform.setPath(path);
            freeform.setStrokeStyle(0.5);
            // There's a 0.5 alpha transparency on the stroke, and a 0.2 alpha transparency on the polygon fill.
            freeform.setLineColor(transparentColor(color, 128));
            freeform.setFillColor(transparentColor(color, 51));

            if (StringUtils.isNotEmpty(polygon.getText())) {
                final PackageRelationship rel = freeform.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the polygon
                final CTHyperlink link = ((CTShape) freeform.getXmlObject()).getNvSpPr().getCNvPr()
                        .addNewHlinkClick();
                link.setTooltip(polygon.getText());
                link.setId(rel.getId());
                link.setAction("ppaction://hlinksldjump");
            }
        }
    }

    for (Marker marker : markers) {
        final Color color = Color.decode(marker.getColor());
        final double centerX = offsetX + marker.getX() * tgtW;
        final double centerY = offsetY + marker.getY() * tgtH;

        if (marker.isCluster()) {
            final XSLFGroupShape group = slide.createGroup();
            double halfMark = 10;
            double mark = halfMark * 2;
            double innerHalfMark = 7;
            double innerMark = innerHalfMark * 2;
            // align these so the middle is the latlng position
            final Rectangle2D.Double groupAnchor = new Rectangle2D.Double(centerX - halfMark,
                    centerY - halfMark, mark, mark);

            group.setAnchor(groupAnchor);
            group.setInteriorAnchor(groupAnchor);

            final XSLFAutoShape shape = group.createAutoShape();
            shape.setShapeType(ShapeType.ELLIPSE);
            final boolean fade = marker.isFade();
            // There's a 0.3 alpha transparency (255 * 0.3 is 76) when a marker is faded out
            final int FADE_ALPHA = 76;
            shape.setFillColor(transparentColor(color, fade ? 47 : 154));
            shape.setAnchor(groupAnchor);

            final XSLFAutoShape inner = group.createAutoShape();
            inner.setFillColor(fade ? transparentColor(color, FADE_ALPHA) : color);
            inner.setLineWidth(0.1);
            inner.setLineColor(new Color((int) (color.getRed() * 0.9), (int) (color.getGreen() * 0.9),
                    (int) (color.getBlue() * 0.9), fade ? FADE_ALPHA : 255));
            inner.setShapeType(ShapeType.ELLIPSE);
            inner.setHorizontalCentered(true);
            inner.setWordWrap(false);
            inner.setVerticalAlignment(VerticalAlignment.MIDDLE);
            inner.clearText();
            final XSLFTextParagraph para = inner.addNewTextParagraph();
            para.setTextAlign(TextParagraph.TextAlign.CENTER);
            final XSLFTextRun text = para.addNewTextRun();
            text.setFontSize(6.0);
            final Color fontColor = Color.decode(StringUtils.defaultString(marker.getFontColor(), "#000000"));
            text.setFontColor(fade ? transparentColor(fontColor, FADE_ALPHA) : fontColor);
            text.setText(marker.getText());
            inner.setAnchor(new Rectangle2D.Double(centerX - innerHalfMark, centerY - innerHalfMark, innerMark,
                    innerMark));
        } else {
            final XSLFGroupShape group = slide.createGroup();

            final XSLFFreeformShape shape = group.createFreeform();
            shape.setHorizontalCentered(true);
            shape.setWordWrap(false);

            shape.setVerticalAlignment(VerticalAlignment.BOTTOM);
            shape.setLineWidth(0.5);
            shape.setLineColor(color.darker());
            shape.setFillColor(transparentColor(color, 210));

            final double halfMark = 8, mark = halfMark * 2, extension = 0.85,
                    markerHeight = (0.5 + extension) * mark, angle = Math.asin(0.5 / extension) * 180 / Math.PI;

            // Set group position
            group.setAnchor(
                    new Rectangle2D.Double(centerX - halfMark, centerY - markerHeight, mark, markerHeight));
            group.setInteriorAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            // Draw a semicircle and a triangle to represent the marker, pointing at the precise x,y location
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(halfMark, markerHeight);
            path.append(new Arc2D.Double(0, 0, mark, mark, -angle, 180 + angle + angle, Arc2D.OPEN), true);
            path.lineTo(halfMark, markerHeight);
            shape.setPath(path);
            shape.setAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            final XSLFAutoShape disc = group.createAutoShape();
            disc.setShapeType(ShapeType.DONUT);
            final double discRadius = 0.25 * mark;
            final double discDiameter = 2 * discRadius;
            disc.setAnchor(new Rectangle2D.Double(halfMark - discRadius, halfMark - discRadius, discDiameter,
                    discDiameter));
            disc.setFillColor(Color.WHITE);
            disc.setLineColor(Color.WHITE);

            if (StringUtils.isNotEmpty(marker.getText())) {
                final PackageRelationship rel = shape.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the marker
                // Annoyingly, you can't put a link on the group, just on the individual shapes.
                for (XSLFShape clickable : group.getShapes()) {
                    final CTHyperlink link = ((CTShape) clickable.getXmlObject()).getNvSpPr().getCNvPr()
                            .addNewHlinkClick();
                    link.setTooltip(marker.getText());
                    link.setId(rel.getId());
                    link.setAction("ppaction://hlinksldjump");
                }
            }
        }
    }

    return canvas;
}

From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java

/**
 * Returns the location for a label//from   w  w w  . ja v a  2s  . com
 *
 * @param labelBounds the label bounds.
 * @param ascent the ascent (height of font).
 * @param plotArea the plot area
 * @param startAngle the start angle for the pie series.
 *
 * @return The location for a label.
 */
protected Point2D calculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea,
        double startAngle) {
    Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN);
    Point2D point1 = arc1.getEndPoint();

    double deltaX = -(point1.getX() - plotArea.getCenterX()) * this.axisLabelGap;
    double deltaY = -(point1.getY() - plotArea.getCenterY()) * this.axisLabelGap;

    double labelX = point1.getX() - deltaX;
    double labelY = point1.getY() - deltaY;

    if (labelX < plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth();
    }

    if (labelX == plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth() / 2;
    }

    if (labelY > plotArea.getCenterY()) {
        labelY += ascent;
    }

    return new Point2D.Double(labelX, labelY);
}

From source file:org.forester.archaeopteryx.TreePanel.java

/**
 * Paint a branch which consists of a vertical and a horizontal bar
 * @param is_ind_found_nodes /*from   w  w w  . j  ava2  s  .co  m*/
 */
final private void paintBranchRectangular(final Graphics2D g, final float x1, final float x2, float y1,
        final float y2, final PhylogenyNode node, final boolean to_pdf, final boolean to_graphics_file) {
    // quick hack
    if (getControlPanel().isShowNodeBoxes()) {
        getOptions().setShowNodeBoxes(true);
    } else {
        getOptions().setShowNodeBoxes(false);
    }

    assignGraphicsForBranchWithColorForParentBranch(node, false, g, to_pdf, to_graphics_file);
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR) {
        drawLine(x1, y1, x2, y2, g);
    } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX) {
        _quad_curve.setCurve(x1, y1, x1, y2, x2, y2);
        g.draw(_quad_curve);
    } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED) {
        final float dx = x2 - x1;
        final float dy = y2 - y1;
        _cubic_curve.setCurve(x1, y1, x1 + (dx * 0.4f), y1 + (dy * 0.2f), x1 + (dx * 0.6f), y1 + (dy * 0.8f),
                x2, y2);
        g.draw(_cubic_curve);
    } else {
        float x2a = x2;
        float x1a = x1;
        // draw the vertical line
        boolean draw_horizontal = true;
        float y2_r = 0;
        if (node.isFirstChildNode() || node.isLastChildNode()
                || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE)
                || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED)) {
            boolean draw_vertical = true;
            final PhylogenyNode parent = node.getParent();
            if (((getOptions().isShowNodeBoxes() && !to_pdf && !to_graphics_file)
                    || ((getControlPanel().isEvents()) && (parent != null) && parent.isHasAssignedEvent()))
                    && (_phylogeny.isRooted() || !((parent != null) && parent.isRoot()))
                    && !((to_pdf || to_graphics_file) && getOptions().isPrintBlackAndWhite()
                            && !parent.isDuplication())) {
                if ((getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE)
                        && (getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.ROUNDED)) {
                    if (Math.abs(y2 - y1) <= TreePanel.HALF_BOX_SIZE) {
                        draw_vertical = false;
                    } else {
                        if (y1 < y2) {
                            y1 += TreePanel.HALF_BOX_SIZE;
                        } else {
                            if (!to_pdf) {
                                y1 -= TreePanel.HALF_BOX_SIZE + 1;
                            } else {
                                y1 -= TreePanel.HALF_BOX_SIZE;
                            }
                        }
                    }
                }
                if ((x2 - x1) <= TreePanel.HALF_BOX_SIZE) {
                    draw_horizontal = false;
                } else if (!draw_vertical) {
                    x1a += TreePanel.HALF_BOX_SIZE;
                }
                if (((x2 - x1a) > TreePanel.HALF_BOX_SIZE) && !((to_pdf || to_graphics_file)
                        && getOptions().isPrintBlackAndWhite() && !node.isDuplication())) {
                    x2a -= TreePanel.HALF_BOX_SIZE;
                }
            }
            if (draw_vertical) {
                if (!to_graphics_file && !to_pdf
                        && (((y2 < getVisibleRect().getMinY() - 20) && (y1 < getVisibleRect().getMinY() - 20))
                                || ((y2 > getVisibleRect().getMaxY() + 20)
                                        && (y1 > getVisibleRect().getMaxY() + 20)))) {
                    // Do nothing.
                } else {
                    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE) {
                        float x2c = x1 + EURO_D;
                        if (x2c > x2a) {
                            x2c = x2a;
                        }
                        drawLine(x1, y1, x2c, y2, g);
                    } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED) {
                        if (y2 > y1) {
                            y2_r = y2 - ROUNDED_D;
                            if (y2_r < y1) {
                                y2_r = y1;
                            }
                            drawLine(x1, y1, x1, y2_r, g);
                        } else {
                            y2_r = y2 + ROUNDED_D;
                            if (y2_r > y1) {
                                y2_r = y1;
                            }
                            drawLine(x1, y1, x1, y2_r, g);
                        }
                    } else {
                        drawLine(x1, y1, x1, y2, g);
                    }
                }
            }
        }
        // draw the horizontal line
        if (!to_graphics_file && !to_pdf
                && ((y2 < getVisibleRect().getMinY() - 20) || (y2 > getVisibleRect().getMaxY() + 20))) {
            return;
        }
        float x1_r = 0;
        if (draw_horizontal) {
            if (!getControlPanel().isWidthBranches() || (PhylogenyMethods.getBranchWidthValue(node) == 1)) {
                if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED) {
                    x1_r = x1a + ROUNDED_D;
                    if (x1_r < x2a) {
                        drawLine(x1_r, y2, x2a, y2, g);
                    }
                } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE) {
                    final float x1c = x1a + EURO_D;
                    if (x1c < x2a) {
                        drawLine(x1c, y2, x2a, y2, g);
                    }
                } else {
                    drawLine(x1a, y2, x2a, y2, g);
                }
            } else {
                final double w = PhylogenyMethods.getBranchWidthValue(node);
                if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED) {
                    x1_r = x1a + ROUNDED_D;
                    if (x1_r < x2a) {
                        drawRectFilled(x1_r, y2 - (w / 2), x2a - x1_r, w, g);
                    }
                } else if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE) {
                    final float x1c = x1a + EURO_D;
                    if (x1c < x2a) {
                        drawRectFilled(x1c, y2 - (w / 2), x2a - x1c, w, g);
                    }
                } else {
                    drawRectFilled(x1a, y2 - (w / 2), x2a - x1a, w, g);
                }
            }
        }
        if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED)) {
            if (x1_r > x2a) {
                x1_r = x2a;
            }
            if (y2 > y2_r) {
                final double diff = y2 - y2_r;
                _arc.setArc(x1, y2_r - diff, 2 * (x1_r - x1), 2 * diff, 180, 90, Arc2D.OPEN);
            } else {
                _arc.setArc(x1, y2, 2 * (x1_r - x1), 2 * (y2_r - y2), 90, 90, Arc2D.OPEN);
            }
            g.draw(_arc);
        }
    }

    paintNodeBox(x2, y2, node, g, to_pdf, to_graphics_file, isInFoundNodes(node));
}

From source file:org.amanzi.awe.render.network.NetworkRenderer.java

/**
 * Create sector//from  www  .jav  a  2 s .  co m
 * 
 * @param point
 * @param radius
 * @param angle
 * @param beamwidth
 * @return sector
 */
private Arc2D createSector(final Point point, final double radius, final double angle, final double beamwidth) {
    int size = getSize();
    Arc2D sector = new Arc2D.Double();
    sector.setArcByCenter(getSectorXCoordinate(point, size), getSectorYCoordinate(point, size), radius, angle,
            beamwidth, Arc2D.OPEN);
    return sector;
}

From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java

/**
 * //from w  w w  .ja  v a 2  s.co m
 * @param iArcStyle
 * @return
 */
protected static final int toG2dArcType(int iArcStyle) {
    switch (iArcStyle) {
    case ArcRenderEvent.OPEN:
        return Arc2D.OPEN;
    case ArcRenderEvent.CLOSED:
        return Arc2D.CHORD;
    case ArcRenderEvent.SECTOR:
        return Arc2D.PIE;
    }
    return -1;
}

From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java

@Override
public void drawArc(ArcRenderEvent are) throws ChartException {
    if (iv != null) {
        iv.modifyEvent(are);//from ww  w  . j  a  v  a2 s  .c  om
    }

    // CHECK IF THE LINE ATTRIBUTES ARE CORRECTLY DEFINED
    final LineAttributes lia = are.getOutline();
    if (!validateLineAttributes(are.getSource(), lia)) {
        return;
    }

    // SETUP THE FOREGROUND COLOR (DARKER BACKGROUND IF DEFINED AS NULL)
    final Color cFG = (Color) validateEdgeColor(lia.getColor(), are.getBackground(), _ids);
    if (cFG == null || cFG.getAlpha() == 0) {
        return;
    }

    // DRAW THE ARC
    Stroke sPrevious = null;
    Stroke sCurrent = getCachedStroke(lia);
    if (sCurrent != null) // SOME STROKE DEFINED?
    {
        sPrevious = _g2d.getStroke();
        _g2d.setStroke(sCurrent);
    }
    _g2d.setColor(cFG);

    if ((are.getInnerRadius() >= 0 && are.getOuterRadius() > 0 && are.getInnerRadius() < are.getOuterRadius())
            || (are.getInnerRadius() > 0 && are.getOuterRadius() <= 0)) {
        Bounds rctOuter = getOuterRectangle(are);
        Bounds rctInner = getInnerRectangle(are);

        Shape outerArc = new Arc2D.Double(rctOuter.getLeft(), rctOuter.getTop(), rctOuter.getWidth(),
                rctOuter.getHeight(), are.getStartAngle(), are.getAngleExtent(), Arc2D.OPEN);
        Shape innerArc = new Arc2D.Double(rctInner.getLeft(), rctInner.getTop(), rctInner.getWidth(),
                rctInner.getHeight(), are.getStartAngle() + are.getAngleExtent(), -are.getAngleExtent(),
                Arc2D.OPEN);

        double startAngle = Math.toRadians(-are.getStartAngle());
        double stopAngle = Math.toRadians(-are.getStartAngle() - are.getAngleExtent());

        double xsOuter = (rctOuter.getLeft() + (Math.cos(startAngle) * 0.5 + 0.5) * rctOuter.getWidth());
        double ysOuter = (rctOuter.getTop() + (Math.sin(startAngle) * 0.5 + 0.5) * rctOuter.getHeight());

        double xeInner = (rctInner.getLeft() + (Math.cos(stopAngle) * 0.5 + 0.5) * rctInner.getWidth());
        double yeInner = (rctInner.getTop() + (Math.sin(stopAngle) * 0.5 + 0.5) * rctInner.getHeight());

        GeneralPath gp = new GeneralPath();
        gp.append(outerArc, false);
        gp.lineTo((float) xeInner, (float) yeInner);
        gp.append(innerArc, false);
        gp.lineTo((float) xsOuter, (float) ysOuter);

        Area area = new Area(gp);
        Shape prevClip = _g2d.getClip();
        Area ar2 = new Area(area);
        if (prevClip != null) {
            Area ar1 = new Area(prevClip);
            ar2.intersect(ar1);
        }
        _g2d.setClip(ar2);
        _g2d.draw(area);
        _g2d.setClip(prevClip);

    } else {
        _g2d.draw(new Arc2D.Double(are.getTopLeft().getX(), are.getTopLeft().getY(), are.getWidth(),
                are.getHeight(), are.getStartAngle(), are.getAngleExtent(), toG2dArcType(are.getStyle())));
    }

    if (sPrevious != null) // RESTORE PREVIOUS STROKE
    {
        _g2d.setStroke(sPrevious);
    }
}

From source file:org.jcurl.demo.tactics.sg.BroomPromptScenario.java

public BroomPromptScenario() {
    // create the scene
    final boolean stickUp = false;
    final boolean bothSides = true;
    final int pieAngle = 150;
    final Color sp = Color.BLACK;
    final Color bgc = new Color(1, 1, 1, 0.5f);
    final Stroke fine = new BasicStroke(0.01f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
    final Stroke bold = new BasicStroke(0.03f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
    // final Font fo = new Font("SansSerif", Font.BOLD, 1);
    final float halo = RockProps.DEFAULT.getRadius();
    final float outer = 0.8f * RockProps.DEFAULT.getRadius();
    stickLength = (stickUp ? 1 : -1) * 5 * outer;
    final float inner = 0.5F * outer;

    final SGGroup me = new SGGroup();
    // the transparent background
    {/* w w w.ja  va2  s . com*/
        final SGShape bg = node(new Arc2D.Float(-halo, -halo, 2 * halo, 2 * halo, 0, 360, Arc2D.OPEN), null,
                null, scale0);
        bg.setFillPaint(bgc);
        bg.addMouseListener(new MoveHandler());
        bg.setMouseBlocker(true);
        bg.setCursor(moveC);
        me.add(bg);
    }
    // the cross-hair and stick
    {
        final int off = 90;
        final int pieOff = 180;
        final int arrowLengthDegrees = 7;
        // colored pie:
        pie = node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off - pieOff, pieAngle, Arc2D.PIE),
                null, null, scale0);
        me.add(pie);
        // inner circle:
        me.add(node(new Arc2D.Float(-inner, -inner, 2 * inner, 2 * inner, off, pieOff + pieAngle, Arc2D.OPEN),
                fine, sp, scale50));
        // outer circle:
        me.add(node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off,
                pieOff + pieAngle - (14 + arrowLengthDegrees), Arc2D.OPEN), fine, sp, scale50));
        // Semantic zooming: me.add(node(new Arc2D.Float(-outer, -outer, 2 *
        // outer, 2 * outer,
        // off, pieOff + pieAngle, Arc2D.OPEN), fine, sp, -scale50));
        final double ar = Math.PI * (off + pieAngle) / 180.0;
        // radius
        // if (pieAngle % 90 != 0)
        me.add(node(new Line2D.Double(0, 0, -outer * Math.cos(ar), outer * Math.sin(ar)), bold, sp, scale0));

        // arrow:
        final float f = outer / 10;
        final SGShape s = node(IceShapes.createArrowHead(f, 3 * f, 0.5f * f), null, null, scale50);
        s.setFillPaint(sp);
        final double a = Math.PI * (off + pieAngle - arrowLengthDegrees) / 180.0;
        final AffineTransform a_ = new AffineTransform();
        a_.translate(-outer * Math.cos(a), outer * Math.sin(a));
        a_.rotate(Math.PI * (90 - (off + pieAngle) + 8 + arrowLengthDegrees) / 180.0);
        final Affine s_ = SGTransform.createAffine(a_, s);
        me.add(s_);
    }
    { // y-axis:
        me.add(node(new Line2D.Float(0, -Math.signum(stickLength) * halo, 0, stickLength), fine, sp, scale0));
        // x-axis:
        me.add(node(new Line2D.Float(-halo, 0, halo, 0), fine, sp, scale0));
    }
    { // slider
        sli = new SGShape();
        sli.setShape(IceShapes.createSlider(0.4f * outer, bothSides));
        // sli.setFillPaint(sp);
        sli.setDrawStroke(fine);
        sli.setDrawPaint(sp);
        sli.setMode(Mode.STROKE_FILL);
        sli.setAntialiasingHint(RenderingHints.VALUE_ANTIALIAS_ON);
        me.add(slider = SGTransform.createAffine(new AffineTransform(), sli));
        slider.setCursor(moveC);
        slider.addMouseListener(new SpeedHandler());
        slider.setMouseBlocker(true);
    }
    handle = SGTransform.createAffine(new AffineTransform(), me);
    scene = SGTransform.createAffine(new AffineTransform(), handle);
    scene.setVisible(false);
}

From source file:org.jcurl.zui.piccolo.BroomPromptSimple.java

public BroomPromptSimple() {
    final boolean stickUp = false;
    final boolean bothSides = true;
    final int pieAngle = 150;
    final Color sp = Color.BLACK;
    final Color bgc = new Color(1, 1, 1, 0.5f);
    final Stroke fine = new BasicStroke(0.01f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
    final Stroke bold = new BasicStroke(0.03f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
    // final Font fo = new Font("SansSerif", Font.BOLD, 1);
    final float halo = RockProps.DEFAULT.getRadius();
    final float outer = 0.8f * RockProps.DEFAULT.getRadius();
    stickLength = (stickUp ? 1 : -1) * 5 * outer;
    final float inner = 0.5F * outer;
    setPickable(false);/*from w  w  w.j a  v a2  s .c  o  m*/
    final BroomPromptSimple self = this;
    handle = new PNode() {
        private static final long serialVersionUID = -7641452321842902940L;

        /**
         * Return true if this node or any pickable descendends are picked.
         * If a pick occurs the pickPath is modified so that this node is
         * always returned as the picked node, event if it was a decendent
         * node that initialy reported the pick.
         * 
         * @see PComposite
         */
        @Override
        public boolean fullPick(final PPickPath pickPath) {
            if (super.fullPick(pickPath)) {
                PNode picked = pickPath.getPickedNode();
                // this code won't work with internal cameras, because
                // it doesn't pop
                // the cameras view transform.
                while (picked != self) {
                    pickPath.popTransform(picked.getTransformReference(false));
                    pickPath.popNode(picked);
                    picked = pickPath.getPickedNode();
                }
                return true;
            }
            return false;
        }
    };
    { // opaque Background
        final PNode bg = node(new Arc2D.Float(-halo, -halo, 2 * halo, 2 * halo, 0, 360, Arc2D.OPEN), null, null,
                scale0);
        bg.setPaint(bgc);
        bg.setPickable(true);
        handle.addChild(bg);
    }
    { // Cross-hair circles and pie
        final int off = 90;
        final int pieOff = 180;
        final int arrowLengthDegrees = 7;
        // colored pie:
        pie = node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off - pieOff, pieAngle, Arc2D.PIE),
                null, null, scale0);
        handle.addChild(pie);
        // inner circle:
        handle.addChild(
                node(new Arc2D.Float(-inner, -inner, 2 * inner, 2 * inner, off, pieOff + pieAngle, Arc2D.OPEN),
                        fine, sp, scale50));
        // outer circle:
        handle.addChild(node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off,
                pieOff + pieAngle - (14 + arrowLengthDegrees), Arc2D.OPEN), fine, sp, scale50));
        handle.addChild(
                node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off, pieOff + pieAngle, Arc2D.OPEN),
                        fine, sp, -scale50));
        final double ar = Math.PI * (off + pieAngle) / 180.0;
        // radius
        // if (pieAngle % 90 != 0)
        handle.addChild(
                node(new Line2D.Double(0, 0, -outer * Math.cos(ar), outer * Math.sin(ar)), bold, sp, scale0));

        // arrow:
        final float f = outer / 10;
        final PPath s = node(IceShapes.createArrowHead(f, 3 * f, 0.5f * f), null, null, scale50);
        s.setPaint(sp);
        final double a = Math.PI * (off + pieAngle - arrowLengthDegrees) / 180.0;
        s.translate(-outer * Math.cos(a), outer * Math.sin(a));
        s.rotate(Math.PI * (90 - (off + pieAngle) + 8 + arrowLengthDegrees) / 180.0);
        handle.addChild(s);

        this.addChild(handle);
    }
    { // y-axis:
        handle.addChild(
                node(new Line2D.Float(0, -Math.signum(stickLength) * halo, 0, stickLength), fine, sp, scale0));
        // x-axis:
        handle.addChild(node(new Line2D.Float(-halo, 0, halo, 0), fine, sp, scale0));
    }
    { // slider
        slider = new PPath(IceShapes.createSlider(0.4f * outer, bothSides), fine);
        slider.setStrokePaint(sp);
        slider.setPickable(true);
        this.addChild(slider);
    }
    // Set up Event handling
    addInputEventListener(new PDragEventHandler() {

        /** double-click: flip handle */
        @Override
        public void mouseClicked(final PInputEvent arg0) {
            super.mouseClicked(arg0);
            if (arg0.getClickCount() > 1) {
                arg0.setHandled(true);
                first = new HandleMemento(getModel(), getModel().getOutTurn());
                last = new HandleMemento(getModel(), !getModel().getOutTurn());
                ChangeManager.getTrivial(changer).undoable(first, last);
                first = last = null;
            }
        }

        /** drag/move */
        @Override
        public void mouseDragged(final PInputEvent arg0) {
            arg0.setHandled(true);
            getModel().setValueIsAdjusting(true);
            if (false) {
                final Point2D p = arg0.getPositionRelativeTo(self.getParent());
                getModel().setBroom(p);
            } else
                view2model(new XYMemento(getModel(), arg0.getPositionRelativeTo(self.getParent())));
        }

        @Override
        public void mouseEntered(final PInputEvent arg0) {
            super.mouseEntered(arg0);
            arg0.pushCursor(MOVE_CURSOR);
        }

        @Override
        public void mouseExited(final PInputEvent arg0) {
            super.mouseExited(arg0);
            arg0.popCursor();
        }

        @Override
        public void mousePressed(final PInputEvent arg0) {
            arg0.setHandled(true);
            first = new XYMemento(getModel(), getModel().getBroom());
        }

        @Override
        public void mouseReleased(final PInputEvent pinputevent) {
            getModel().setValueIsAdjusting(false);
            if (first != null && last != null && first != last)
                ChangeManager.getTrivial(changer).undoable(first, last);
            first = last = null;
        }
    });
    slider.addInputEventListener(new PDragEventHandler() {
        @Override
        protected void endDrag(final PInputEvent pinputevent) {
            log.debug("speed");
        }

        /** adjust the slider */
        @Override
        public void mouseDragged(final PInputEvent arg0) {
            arg0.setHandled(true);
            final Point2D p = arg0.getPositionRelativeTo(self);
            final BoundedRangeModel r = self.getModel().getSplitTimeMillis();
            if (r == null)
                return;
            r.setValueIsAdjusting(true);
            view2model(new SplitMemento(getModel(), ratio2value(p.getY() / stickLength, r)));
        }

        @Override
        public void mouseEntered(final PInputEvent arg0) {
            super.mouseEntered(arg0);
            arg0.pushCursor(UPDN_CURSOR);
        }

        @Override
        public void mouseExited(final PInputEvent arg0) {
            super.mouseExited(arg0);
            arg0.popCursor();
        }

        @Override
        public void mousePressed(final PInputEvent arg0) {
            arg0.setHandled(true);
            first = new SplitMemento(getModel(), getModel().getSplitTimeMillis().getValue());
        }

        @Override
        public void mouseReleased(final PInputEvent pinputevent) {
            log.debug("speed");
            final BoundedRangeModel r = self.getModel().getSplitTimeMillis();
            if (r == null)
                return;
            r.setValueIsAdjusting(false);
            if (first != null && last != null && first != last)
                ChangeManager.getTrivial(changer).undoable(first, last);
            first = last = null;
        }
    });
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * @see Graphics#drawArc(int, int, int, int, int, int)
 *///  w w w.  j a  va  2 s .co  m
@Override
public void drawArc(final int x, final int y, final int width, final int height, final int startAngle,
        final int arcAngle) {
    final Arc2D arc = new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
    draw(arc);

}