Example usage for java.awt BasicStroke CAP_BUTT

List of usage examples for java.awt BasicStroke CAP_BUTT

Introduction

In this page you can find the example usage for java.awt BasicStroke CAP_BUTT.

Prototype

int CAP_BUTT

To view the source code for java.awt BasicStroke CAP_BUTT.

Click Source Link

Document

Ends unclosed subpaths and dash segments with no added decoration.

Usage

From source file:beproject.MainGUI.java

void liveTweetAnalysis() {
    new DataGenerator(1000).start();
    rate = new TimeSeries("Total count", Second.class);
    rate.setMaximumItemAge(15);//ww w  .j  av  a  2  s . c  o m
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(rate);
    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Tweet Count");
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);
    range.setTickLabelsVisible(true);

    plot.setDomainGridlinesVisible(false);
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    renderer.setBaseItemLabelsVisible(true);

    JFreeChart liveTweetAnalysisChart = new JFreeChart("Tweets Per Second", new Font("Tahoma", Font.BOLD, 24),
            plot, true);
    liveTweetAnalysisChart.setBorderVisible(false);
    liveTweetAnalysisChart.setBorderPaint(null);

    ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart);

    domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS);
    range.setTickMarksVisible(false);
    range.setTickLabelInsets(RectangleInsets.ZERO_INSETS);
    domain.setTickMarksVisible(false);
    liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS);

    ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true);
    liveTweetAnalysisChartPanel.setBorder(null);

    liveTweetsAnalysisPanel.add(liveTweetAnalysisChartPanel, BorderLayout.CENTER);
    liveTweetsAnalysisPanel.validate();
}

From source file:org.apache.fop.render.java2d.Java2DBorderPainter.java

/** {@inheritDoc} */
protected void drawBorderLine( // CSOK: ParameterNumber
        int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) {
    float w = x2 - x1;
    float h = y2 - y1;
    if ((w < 0) || (h < 0)) {
        log.error("Negative extent received. Border won't be painted.");
        return;/*from w ww  .j av a 2s .  c o m*/
    }
    switch (style) {
    case Constants.EN_DASHED:
        getG2D().setColor(color);
        if (horz) {
            float unit = Math.abs(2 * h);
            int rep = (int) (w / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = w / rep;
            float ym = y1 + (h / 2);
            BasicStroke s = new BasicStroke(h, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float unit = Math.abs(2 * w);
            int rep = (int) (h / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = h / rep;
            float xm = x1 + (w / 2);
            BasicStroke s = new BasicStroke(w, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
        break;
    case Constants.EN_DOTTED:
        getG2D().setColor(color);
        if (horz) {
            float unit = Math.abs(2 * h);
            int rep = (int) (w / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = w / rep;
            float ym = y1 + (h / 2);
            BasicStroke s = new BasicStroke(h, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { 0, unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float unit = Math.abs(2 * w);
            int rep = (int) (h / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = h / rep;
            float xm = x1 + (w / 2);
            BasicStroke s = new BasicStroke(w, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { 0, unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
        break;
    case Constants.EN_DOUBLE:
        getG2D().setColor(color);
        if (horz) {
            float h3 = h / 3;
            float ym1 = y1 + (h3 / 2);
            float ym2 = ym1 + h3 + h3;
            BasicStroke s = new BasicStroke(h3);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
            getG2D().draw(new Line2D.Float(x1, ym2, x2, ym2));
        } else {
            float w3 = w / 3;
            float xm1 = x1 + (w3 / 2);
            float xm2 = xm1 + w3 + w3;
            BasicStroke s = new BasicStroke(w3);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
            getG2D().draw(new Line2D.Float(xm2, y1, xm2, y2));
        }
        break;
    case Constants.EN_GROOVE:
    case Constants.EN_RIDGE:
        float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
        if (horz) {
            Color uppercol = ColorUtil.lightenColor(color, -colFactor);
            Color lowercol = ColorUtil.lightenColor(color, colFactor);
            float h3 = h / 3;
            float ym1 = y1 + (h3 / 2);
            getG2D().setStroke(new BasicStroke(h3));
            getG2D().setColor(uppercol);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(x1, ym1 + h3, x2, ym1 + h3));
            getG2D().setColor(lowercol);
            getG2D().draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3));
        } else {
            Color leftcol = ColorUtil.lightenColor(color, -colFactor);
            Color rightcol = ColorUtil.lightenColor(color, colFactor);
            float w3 = w / 3;
            float xm1 = x1 + (w3 / 2);
            getG2D().setStroke(new BasicStroke(w3));
            getG2D().setColor(leftcol);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(xm1 + w3, y1, xm1 + w3, y2));
            getG2D().setColor(rightcol);
            getG2D().draw(new Line2D.Float(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2));
        }
        break;
    case Constants.EN_INSET:
    case Constants.EN_OUTSET:
        colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
        if (horz) {
            color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
            getG2D().setStroke(new BasicStroke(h));
            float ym1 = y1 + (h / 2);
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
        } else {
            color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
            float xm1 = x1 + (w / 2);
            getG2D().setStroke(new BasicStroke(w));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
        }
        break;
    case Constants.EN_HIDDEN:
        break;
    default:
        getG2D().setColor(color);
        if (horz) {
            float ym = y1 + (h / 2);
            getG2D().setStroke(new BasicStroke(h));
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float xm = x1 + (w / 2);
            getG2D().setStroke(new BasicStroke(w));
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
    }
}

From source file:org.apache.fop.render.java2d.Java2DGraphicsPainter.java

public void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style,
        Color color) throws IOException {
    float w = x2 - x1;
    float h = y2 - y1;
    if ((w < 0) || (h < 0)) {
        log.error("Negative extent received. Border won't be painted.");
        return;//from  w ww.ja va 2  s.  c o m
    }
    switch (style) {
    case Constants.EN_DASHED:
        getG2D().setColor(color);
        if (horz) {
            float unit = Math.abs(2 * h);
            int rep = (int) (w / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = w / rep;
            float ym = y1 + (h / 2);
            BasicStroke s = new BasicStroke(h, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float unit = Math.abs(2 * w);
            int rep = (int) (h / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = h / rep;
            float xm = x1 + (w / 2);
            BasicStroke s = new BasicStroke(w, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
        break;
    case Constants.EN_DOTTED:
        getG2D().setColor(color);
        if (horz) {
            float unit = Math.abs(2 * h);
            int rep = (int) (w / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = w / rep;
            float ym = y1 + (h / 2);
            BasicStroke s = new BasicStroke(h, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { 0, unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float unit = Math.abs(2 * w);
            int rep = (int) (h / unit);
            if (rep % 2 == 0) {
                rep++;
            }
            unit = h / rep;
            float xm = x1 + (w / 2);
            BasicStroke s = new BasicStroke(w, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f,
                    new float[] { 0, unit }, 0);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
        break;
    case Constants.EN_DOUBLE:
        getG2D().setColor(color);
        if (horz) {
            float h3 = h / 3;
            float ym1 = y1 + (h3 / 2);
            float ym2 = ym1 + h3 + h3;
            BasicStroke s = new BasicStroke(h3);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
            getG2D().draw(new Line2D.Float(x1, ym2, x2, ym2));
        } else {
            float w3 = w / 3;
            float xm1 = x1 + (w3 / 2);
            float xm2 = xm1 + w3 + w3;
            BasicStroke s = new BasicStroke(w3);
            getG2D().setStroke(s);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
            getG2D().draw(new Line2D.Float(xm2, y1, xm2, y2));
        }
        break;
    case Constants.EN_GROOVE:
    case Constants.EN_RIDGE:
        float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
        if (horz) {
            Color uppercol = ColorUtil.lightenColor(color, -colFactor);
            Color lowercol = ColorUtil.lightenColor(color, colFactor);
            float h3 = h / 3;
            float ym1 = y1 + (h3 / 2);
            getG2D().setStroke(new BasicStroke(h3));
            getG2D().setColor(uppercol);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(x1, ym1 + h3, x2, ym1 + h3));
            getG2D().setColor(lowercol);
            getG2D().draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3));
        } else {
            Color leftcol = ColorUtil.lightenColor(color, -colFactor);
            Color rightcol = ColorUtil.lightenColor(color, colFactor);
            float w3 = w / 3;
            float xm1 = x1 + (w3 / 2);
            getG2D().setStroke(new BasicStroke(w3));
            getG2D().setColor(leftcol);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(xm1 + w3, y1, xm1 + w3, y2));
            getG2D().setColor(rightcol);
            getG2D().draw(new Line2D.Float(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2));
        }
        break;
    case Constants.EN_INSET:
    case Constants.EN_OUTSET:
        colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
        if (horz) {
            color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
            getG2D().setStroke(new BasicStroke(h));
            float ym1 = y1 + (h / 2);
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
        } else {
            color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
            float xm1 = x1 + (w / 2);
            getG2D().setStroke(new BasicStroke(w));
            getG2D().setColor(color);
            getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
        }
        break;
    case Constants.EN_HIDDEN:
        break;
    default:
        getG2D().setColor(color);
        if (horz) {
            float ym = y1 + (h / 2);
            getG2D().setStroke(new BasicStroke(h));
            getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
        } else {
            float xm = x1 + (w / 2);
            getG2D().setStroke(new BasicStroke(w));
            getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
        }
    }
}

From source file:org.apache.pdfbox.rendering.PageDrawer.java

/**
 * Draws the page to the requested context.
 * //from w  ww  .j  av  a2s. c o  m
 * @param g The graphics context to draw onto.
 * @param pageSize The size of the page to draw.
 * @throws IOException If there is an IO error while drawing the page.
 */
public void drawPage(Graphics g, PDRectangle pageSize) throws IOException {
    graphics = (Graphics2D) g;
    xform = graphics.getTransform();
    this.pageSize = pageSize;

    setRenderingHints();

    graphics.translate(0, pageSize.getHeight());
    graphics.scale(1, -1);

    // TODO use getStroke() to set the initial stroke
    graphics.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));

    // adjust for non-(0,0) crop box
    graphics.translate(-pageSize.getLowerLeftX(), -pageSize.getLowerLeftY());

    processPage(getPage());

    for (PDAnnotation annotation : getPage().getAnnotations()) {
        showAnnotation(annotation);
    }

    graphics = null;
}

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
    {//from   w  ww. j a v a  2 s.  c om
        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);//w ww  . jav  a  2 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.kalypso.zml.core.base.TSLinkWithName.java

public Stroke getStroke() {
    final float width = getLineWidth();
    final float[] dash = getLineDash();

    return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, dash, 1f);
}

From source file:org.n52.v3d.terrainserver.povraywts.WebTerrainServlet.java

private void addAnnotations(BufferedImage pImage, int pHeight, int pWidth, double pPitch, double pYaw,
        boolean pDrawNorthArrow) {
    if (mCopyrightTextContent.length() > 0) {
        Graphics2D g = pImage.createGraphics();
        g.drawImage(pImage, 0, 0, null);
        g.setColor(new java.awt.Color(mCopyrightTextColor.getRed(), mCopyrightTextColor.getGreen(),
                mCopyrightTextColor.getBlue()));

        // 1. Copyright-Vermerk
        // Etwas unschn: Durch JPEG-Komprimierung wird Text (insb. bei kleiner Font-Gre) wird unscharf...
        // TODO: Abhilfe evtl. durch Hintergrund?
        Font font = new Font(mCopyrightTextFont, Font.BOLD /* Style als int, siehe ggf. API-Dok.*/,
                mCopyrightTextSize);/*from  w  ww.  j  ava  2  s  .  c  om*/
        g.setFont(font);
        // mehrzeilige Copyright-Texte erlauben:
        StringTokenizer str = new StringTokenizer(mCopyrightTextContent, "\n");
        int spacePerRow = mCopyrightTextSize;
        int rows = str.countTokens();
        int startPos = spacePerRow * rows;
        int currRow = 0;
        while (str.hasMoreTokens()) {
            int yPos = pHeight - (startPos - (currRow * spacePerRow)) + spacePerRow / 2;
            g.drawString(str.nextToken().trim(), 5, yPos);
            currRow++;
        }

        // 2. Nordpfeil
        if (pDrawNorthArrow) {
            // Zeichenparameter:
            double radius = 35.;
            double phi = 15.;
            // Symbolkonstruktion:
            int rx = (int) radius;
            int ry = (int) Math.round(radius * Math.sin(-pPitch * Math.PI / 180.));
            int mx = pWidth - rx - 5;
            int my = pHeight - ry - 5;
            int dx = (int) (radius * Math.sin(pYaw * Math.PI / 180.));
            int dy = (int) (radius * Math.sin(-pPitch * Math.PI / 180.) * Math.cos(pYaw * Math.PI / 180.));
            int px = mx - dx, py = my - dy; // Pfeilspitze
            int qlx = mx + (int) (radius * Math.sin((pYaw + phi) * Math.PI / 180.));
            int qly = my + (int) (radius * Math.sin(-pPitch * Math.PI / 180.)
                    * Math.cos((pYaw + phi) * Math.PI / 180.));
            int qrx = mx + (int) (radius * Math.sin((pYaw - phi) * Math.PI / 180.));
            int qry = my + (int) (radius * Math.sin(-pPitch * Math.PI / 180.)
                    * Math.cos((pYaw - phi) * Math.PI / 180.));
            // Ellipse zeichnen:
            g.setStroke(new BasicStroke(2.f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
            g.drawOval(mx - rx, my - ry, 2 * rx, 2 * ry);
            // Striche fr Pfeil zeichnen:

            g.setStroke(new BasicStroke(1.f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));

            boolean fillArrow = true;
            if (fillArrow)
                g.fill(new Polygon(new int[] { px, qlx, qrx }, new int[] { py, qly, qry }, 3));
            else {
                g.drawLine(px, py, qlx, qly);
                g.drawLine(px, py, qrx, qry);
                g.drawLine(qlx, qly, qrx, qry);
            }
        }

        g.dispose();
    }
}

From source file:org.pentaho.chart.plugin.jfreechart.utils.StrokeFactory.java

/**
* This method creates a BasicStroke object for border-style/line-style like dotted, solid etc
* It also incorporates border-width for the border/line width for the line.
* <p/>//from  w ww .java2  s .com
* NONE, HIDDEN, SOLID, DASHED, DOT-DASH and DOTTED are the only border-style/line-style
* that we currently support.
* The border-width/line-width: thin, medium and thick have been mapped to static widths.
*
* @param chartElement The current series element
* @param widthStyleKey The Width style key. 
* @param styleStyleKey The Style style key.
* @return BasicStroke  The basic stroke object that implements the style and width.
*/
private BasicStroke getBasicStroke(final ChartElement chartElement, final StyleKey styleStyleKey,
        final StyleKey widthStyleKey) {
    CSSValue cssValue = chartElement.getLayoutStyle().getValue(widthStyleKey);
    final String borderWidth = (cssValue != null ? cssValue.getCSSText() : null);

    float width = 0f;
    if (borderWidth != null) {
        if (borderWidth.equalsIgnoreCase(BorderWidth.THIN.toString())) {
            width = THIN;
        } else if (borderWidth.equalsIgnoreCase(BorderWidth.MEDIUM.toString())) {
            width = MEDIUM;
        } else if (borderWidth.equalsIgnoreCase(BorderWidth.THICK.toString())) {
            width = THICK;
        } else if (borderWidth.endsWith(PIXEL)) {
            final String borderWidthPixels = (borderWidth.substring(0, borderWidth.indexOf(PIXEL))).trim();
            width = Integer.parseInt(borderWidthPixels);
        } else if (borderWidth.endsWith(CENTIMETER)) {
            final String borderWidthCms = (borderWidth.substring(0, borderWidth.indexOf(CENTIMETER))).trim();
            // Convert centimeter to pixels
            width = Integer.parseInt(borderWidthCms) * CENTIMETER_TO_PIXEL;
        }
    }

    final CSSValue borderStyle = chartElement.getLayoutStyle().getValue(styleStyleKey);
    if ((borderStyle == null) || BorderStyle.NONE.getCSSText().equals(borderStyle.getCSSText())) {
        // TODO mlowery figure out why logging won't output a "lesser" priority for this call
        logger.warn(String.format("************style %s has value %s; stroke will be null", styleStyleKey.name,
                BorderStyle.NONE.getCSSText()));
        return null;
    }

    BasicStroke stroke = null;

    if (BorderStyle.SOLID.equals(borderStyle)) {
        stroke = new BasicStroke(width);
    } else if (BorderStyle.DASHED.equals(borderStyle)) {
        stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0F,
                new float[] { 10.0F, 3.0F }, 0.F);
    } else if (BorderStyle.DOT_DASH.equals(borderStyle)) {
        stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0F,
                new float[] { 10.0F, 3.0F, 2.0F, 2.0F }, 0.F);
    } else if (BorderStyle.DOTTED.equals(borderStyle)) {
        stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0,
                new float[] { 0, 6, 0, 6 }, 0);
    }
    return stroke;
}

From source file:org.pentaho.di.core.gui.SwingDirectGC.java

private Stroke createStroke() {
    float[] dash;
    switch (lineStyle) {
    case SOLID://from   www .  j a va2s.c  o  m
        dash = null;
        break;
    case DOT:
        dash = new float[] { 5, };
        break;
    case DASHDOT:
        dash = new float[] { 10, 5, 5, 5, };
        break;
    case PARALLEL:
        dash = new float[] { 10, 5, 10, 5, };
        break;
    default:
        throw new RuntimeException("Unhandled line style!");
    }
    return new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 2, dash, 0);
}