Example usage for java.awt.geom GeneralPath lineTo

List of usage examples for java.awt.geom GeneralPath lineTo

Introduction

In this page you can find the example usage for java.awt.geom GeneralPath lineTo.

Prototype

public abstract void lineTo(double x, double y);

Source Link

Document

Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.

Usage

From source file:net.sf.maltcms.chromaui.annotations.PeakAnnotationRenderer.java

private VisualPeakAnnotation generateTriangle(double startX, double startY, double apexX, double apexY,
        double stopX, double stopY) {
    GeneralPath path = new GeneralPath();
    path.moveTo(startX, startY);/*from w  w w .j  a  va 2s  .c  o m*/
    path.lineTo(apexX, apexY);
    path.lineTo(stopX, stopY);
    path.closePath();
    Rectangle2D r = path.getBounds2D();
    return new VisualPeakAnnotation(path, new Point2D.Double(r.getCenterX(), r.getMaxY()),
            PeakAnnotationType.POINTER);
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlArea.java

private GeneralPath parsePoly() {
    final String[] coords = StringUtils.split(getCoordsAttribute(), ',');
    final GeneralPath path = new GeneralPath();
    for (int i = 0; i + 1 < coords.length; i += 2) {
        if (i == 0) {
            path.moveTo(Float.parseFloat(coords[i]), Float.parseFloat(coords[i + 1]));
        } else {/*from w w w .j  a  v  a2  s .  c o m*/
            path.lineTo(Float.parseFloat(coords[i]), Float.parseFloat(coords[i + 1]));
        }
    }
    path.closePath();
    return path;
}

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.java

/**
 * Build the legend//w  w w  .  ja v  a 2s . c om
 *
 */
private void buildLegend() {

    LegendTitle legend = pcaChart.getLegend();
    LegendItemSource[] sources = new LegendItemSource[1];
    PcaLegendItemSource legendSrc = new PcaLegendItemSource();
    LegendItem item = null;

    //Rect=survival less than 10 months
    item = new LegendItem("Tumor size change (MRI): Unknown", null, null, null,
            new Rectangle2D.Double(0, 0, 8, 8), Color.BLACK);
    legendSrc.addLegendItem(item);

    GeneralPath downtriangle = new GeneralPath();
    downtriangle.moveTo(-4.0f, -4.0f);
    downtriangle.lineTo(4.0f, -4.0f);
    downtriangle.lineTo(0.0f, 4.0f);
    downtriangle.closePath();
    item = new LegendItem("Tumor size reduced by 30% or more (MRI)", null, null, null, downtriangle,
            Color.BLACK);
    legendSrc.addLegendItem(item);

    item = new LegendItem("Tumor size reduced less than 30% or no change (MRI)", null, null, null,
            new Ellipse2D.Double(0, 0, 8, 8), Color.BLACK);
    legendSrc.addLegendItem(item);

    GeneralPath uptriangle = new GeneralPath();
    uptriangle.moveTo(0.0f, -4.0f);
    uptriangle.lineTo(4.0f, 4.0f);
    uptriangle.lineTo(-4.0f, 4.0f);
    uptriangle.closePath();
    item = new LegendItem("Tumor size increased (MRI)", null, null, null, uptriangle, Color.BLACK);
    legendSrc.addLegendItem(item);

    if (colorBy == ColorByType.CLINICALRESPONSE) {

        for (ClinicalResponseType cr : ClinicalResponseType.values()) {
            item = new LegendItem(cr.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                    new BasicStroke(3.0f), cr.getColor());
            legendSrc.addLegendItem(item);
        }

    } else if (colorBy == ColorByType.DISEASESTAGE) {

        for (ClinicalStageType ds : ClinicalStageType.values()) {
            if (!ds.name().endsWith("ALL")) {
                item = new LegendItem(ds.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ds.getColor());
                legendSrc.addLegendItem(item);
            }
        }
    } else if (colorBy == ColorByType.TIMEPOINT) {
        for (TimepointType tp : TimepointType.values()) {
            item = new LegendItem(tp.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                    new BasicStroke(3.0f), tp.getColor());
            legendSrc.addLegendItem(item);
        }
    }

    sources[0] = legendSrc;
    legend.setSources(sources);
}

From source file:net.sf.maltcms.chromaui.charts.events.XYAnnotationAdder.java

/**
 *
 * @param x//from   w  ww  . j av a  2  s  .com
 * @param y
 * @param w
 * @param h
 * @return
 */
public Shape getCrosshairShape(double x, double y, double w, double h) {
    // draw GeneralPath (polyline)
    //we draw two lines, one from
    //x-5,y to x+5,y and one from
    //x,y-5 to x,y+5
    double x2Points[] = { x - w, x + w, x, x };
    double y2Points[] = { y, y, y - h, y + h };
    GeneralPath crosshair = new GeneralPath(GeneralPath.WIND_EVEN_ODD, x2Points.length);

    crosshair.moveTo(x2Points[0], y2Points[0]);
    crosshair.lineTo(x2Points[1], y2Points[1]);
    crosshair.moveTo(x2Points[2], y2Points[2]);
    crosshair.lineTo(x2Points[3], y2Points[3]);

    return crosshair;

}

From source file:net.sf.maltcms.chromaui.annotations.PeakAnnotationRenderer.java

private VisualPeakAnnotation generateOutline(IChromatogramDescriptor chromatogram,
        IPeakAnnotationDescriptor peakDescr, ADataset1D<IChromatogram1D, IScan> dataset, int seriesIndex) {
    boolean baselineAvailable = false;
    if (!(Double.isNaN(peakDescr.getBaselineStartIntensity())
            && Double.isNaN(peakDescr.getBaselineStopIntensity())
            && Double.isNaN(peakDescr.getBaselineStartTime())
            && Double.isNaN(peakDescr.getBaselineStopTime()))) {
        Logger.getLogger(getClass().getName()).warning("Using baseline for peak outline");
        baselineAvailable = true;/*from   www.  j a v  a 2s.co m*/
    }
    double sat = peakDescr.getApexTime();
    double peakStartTime = peakDescr.getStartTime();
    double peakStopTime = peakDescr.getStopTime();
    if (Double.isNaN(peakStartTime) || Double.isNaN(peakStopTime)) {
        return null;
    }
    int scan = chromatogram.getChromatogram().getIndexFor(sat);
    int startIdx = chromatogram.getChromatogram().getIndexFor(peakStartTime);
    int stopIdx = chromatogram.getChromatogram().getIndexFor(peakStopTime);
    double peakStartValue = peakDescr.getStartIntensity();
    double peakStopValue = peakDescr.getStopIntensity();
    double blStartTime, blStopTime, blStartVal, blStopVal;
    if (baselineAvailable) {
        blStartTime = peakDescr.getBaselineStartTime();
        blStopTime = peakDescr.getBaselineStopTime();
        blStartVal = peakDescr.getBaselineStartIntensity();
        blStopVal = peakDescr.getBaselineStopIntensity();
    } else {
        blStartTime = peakStartTime;
        blStopTime = peakStopTime;
        //FIXME baseline is not correctly shown
        if (Double.isNaN(peakDescr.getStartIntensity()) || Double.isNaN(peakDescr.getStopIntensity())) {
            blStartVal = dataset.getYValue(seriesIndex, startIdx);
            blStopVal = dataset.getYValue(seriesIndex, stopIdx);
        } else {
            blStartVal = dataset.getYValue(seriesIndex, startIdx);
            blStopVal = dataset.getYValue(seriesIndex, stopIdx);
        }
    }
    peakStartValue = dataset.getYValue(seriesIndex, startIdx);
    peakStopValue = dataset.getYValue(seriesIndex, stopIdx);
    double peakApexValue = dataset.getYValue(seriesIndex, scan);

    GeneralPath gp = new GeneralPath();
    gp.moveTo(blStartTime, dataset.getYValue(seriesIndex, startIdx) + blStartVal);
    gp.lineTo(peakStartTime, peakStartValue);
    for (int j = startIdx + 1; j <= stopIdx; j++) {
        gp.lineTo(dataset.getXValue(seriesIndex, j), dataset.getYValue(seriesIndex, j));
    }
    gp.lineTo(blStopTime, dataset.getYValue(seriesIndex, stopIdx) + blStopVal);
    gp.closePath();
    Logger.getLogger(getClass().getName()).log(Level.WARNING,
            "Generating peak outline: ({0};{1})({2};{3}" + ")" + "({4};{5})",
            new Object[] { peakStartTime, peakStartValue, sat, peakApexValue, peakStopTime, peakStopValue });
    VisualPeakAnnotation vpa = new VisualPeakAnnotation(gp,
            new Point2D.Double(sat, Math.min(peakStartValue, Math.min(peakApexValue, peakStopValue))),
            PeakAnnotationType.OUTLINE);//generate(peakStartTime, peakStartValue, sat, peakApexValue, peakStopTime, peakStopValue);
    return vpa;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java

/**
 * This chart uses the XYAnnotation as a glyph to represent
 * a single pca data point. Glyph shape is determined by survival time.
 * Survival of more than 10 months is represented by a circle. 10 months or less
 * is represented by a square. Component1 values are represented by X 
 * Component2 values are represented by Y
 *//*www.  ja va  2s.c om*/
protected void createGlyphsAndAddToPlot(XYPlot plot) {
    XYShapeAnnotation glyph;
    Shape glyphShape;
    Color glyphColor;

    PrincipalComponentAnalysisDataPoint pcaPoint;
    double x, y;
    for (Iterator i = dataPoints.iterator(); i.hasNext();) {
        pcaPoint = (PrincipalComponentAnalysisDataPoint) i.next();

        x = pcaPoint.getComponentValue(component1);
        y = pcaPoint.getComponentValue(component2);
        double survival = pcaPoint.getSurvivalInMonths();
        if ((survival > 0) && (survival < 10.0)) {
            Rectangle2D.Double rect = new Rectangle2D.Double();
            rect.setFrameFromCenter(x, y, x + 2, y + 2);
            glyphShape = rect;
        } else if ((survival > 0) && (survival >= 10.0)) {
            Ellipse2D.Double circle = new Ellipse2D.Double();
            circle.setFrameFromCenter(x, y, x + 2, y + 2);
            glyphShape = circle;
        } else {
            //Rectangle2D.Double rect = new Rectangle2D.Double();
            //rect.setFrameFromCenter(x,y, x+2,y+2);
            GeneralPath gp = new GeneralPath();
            float xf = (float) x;
            float yf = (float) y;
            //make a triangle
            gp.moveTo(xf, yf);
            gp.lineTo(xf + 3.0f, yf - 3.0f);
            gp.lineTo(xf - 3.0f, yf - 3.0f);
            gp.closePath();
            glyphShape = gp;
        }

        glyphColor = getColorForDataPoint(pcaPoint);
        glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor);
        String tooltip = "";
        if (pcaPoint.getSurvivalInMonths() <= 0.0) {
            tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName();
        } else {
            tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName() + " survivalMonths="
                    + nf.format(pcaPoint.getSurvivalInMonths());
        }
        glyph.setToolTipText(tooltip);
        plot.addAnnotation(glyph);
    }

}

From source file:io.github.dsheirer.spectrum.SpectrumPanel.java

/**
 * Draws the current fft spectrum with a line and a gradient fill.
 *//*w  ww . jav  a 2 s .  c  om*/
private void drawSpectrum(Graphics2D graphics) {
    Dimension size = getSize();

    //Draw the background
    Rectangle background = new Rectangle(0, 0, size.width, size.height);
    graphics.setColor(mColorSpectrumBackground);
    graphics.draw(background);
    graphics.fill(background);

    //Define the gradient
    GradientPaint gradient = new GradientPaint(0, (getSize().height - mSpectrumInset) / 2,
            mColorSpectrumGradientTop, 0, getSize().height, mColorSpectrumGradientBottom);

    graphics.setBackground(mColorSpectrumBackground);

    GeneralPath spectrumShape = new GeneralPath();

    //Start at the lower right inset point
    spectrumShape.moveTo(size.getWidth(), size.getHeight() - mSpectrumInset);

    //Draw to the lower left
    spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset);

    float[] bins = getBins();

    //If we have FFT data to display ...
    if (bins != null) {
        float insideHeight = size.height - mSpectrumInset;

        float scalor = insideHeight / -mDBScale;

        /* Calculate based on bin size - 1, since bin 0 is rendered at zero
           * and the last bin is rendered at the width */
        float binSize = (float) size.width / ((float) (bins.length));

        for (int x = 0; x < bins.length; x++) {
            float height;

            height = bins[x] * scalor;

            if (height > insideHeight) {
                height = insideHeight;
            }

            if (height < 0) {
                height = 0;
            }

            float xAxis = (float) x * binSize;

            spectrumShape.lineTo(xAxis, height);
        }
    }
    //Otherwise show an empty spectrum
    else {
        //Draw Left Size
        graphics.setPaint(gradient);
        spectrumShape.lineTo(0, size.getHeight() - mSpectrumInset);
        //Draw Middle
        spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset);
    }

    //Draw Right Side
    spectrumShape.lineTo(size.getWidth(), size.getHeight() - mSpectrumInset);

    graphics.setPaint(gradient);
    graphics.draw(spectrumShape);
    graphics.fill(spectrumShape);

    graphics.setPaint(mColorSpectrumLine);

    //Draw the bottom line under the spectrum
    graphics.draw(new Line2D.Float(0, size.height - mSpectrumInset, size.width, size.height - mSpectrumInset));
}

From source file:gda.plots.TurboXYItemRenderer.java

private GeneralPath addPointToLine(GeneralPath path, PlotOrientation orientation, int x, int y) {
    if (drawLines) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            int dummy = x;
            x = y;/*  w ww  .j  a  va  2  s.c  om*/
            y = dummy;
        }
        if (path == null) {
            path = new GeneralPath();
            path.moveTo(x, y);
        } else {
            path.lineTo(x, y);
        }
    }
    return path;
}

From source file:org.operamasks.faces.render.graph.CurveAndShapeRenderer.java

private void drawSeriesCurve(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
        ValueAxis rangeAxis, CategoryDataset dataset, int series) {
    // do nothing if item is not visible
    if (!(getItemVisible(series, 0) && (getItemLineVisible(series, 0) || drawArea))) {
        return;//from  w w  w. j a v  a 2  s  . c  o  m
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    PlotOrientation orientation = plot.getOrientation();

    int itemCount = dataset.getColumnCount();
    double[][] points = new double[itemCount][2];
    int count = 0;

    // get data points
    for (int i = 0; i < itemCount; i++) {
        Number value = dataset.getValue(series, i);
        if (value != null) {
            points[count][0] = domainAxis.getCategoryMiddle(i, itemCount, dataArea, xAxisLocation);
            points[count][1] = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, yAxisLocation);
            count++;
        }
    }

    if (count < 2) {
        return;
    }

    // draw curve
    CubicSplineFunction2D f = new CubicSplineFunction2D(points, count);
    GeneralPath path = new GeneralPath();

    double startX = points[0][0];
    double startY = points[0][1];
    double endX = points[count - 1][0];
    double endY = points[count - 1][1];
    double yz = rangeAxis.valueToJava2D(0.0, dataArea, yAxisLocation);

    if (orientation == PlotOrientation.HORIZONTAL) {
        if (drawArea) {
            path.moveTo((float) yz, (float) startX);
            path.lineTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
            path.lineTo((float) yz, (float) endX);
            path.closePath();
        } else {
            path.moveTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
        }
    } else {
        if (drawArea) {
            path.moveTo((float) startX, (float) yz);
            path.lineTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
            path.lineTo((float) endX, (float) yz);
            path.closePath();
        } else {
            path.moveTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
        }
    }

    Paint paint = getSeriesPaint(series);
    Stroke stroke = getSeriesStroke(series);

    if (drawArea) {
        g2.setPaint(paint);
        g2.fill(path);

        // create paint for outline
        if (paint instanceof Color) {
            paint = ((Color) paint).darker();
        } else if (paint instanceof GradientPaint) {
            paint = ((GradientPaint) paint).getColor1().darker();
        }
    }

    if (getItemLineVisible(series, 0)) {
        g2.setPaint(paint);
        g2.setStroke(stroke);
        g2.draw(path);
    }
}

From source file:org.openmeetings.app.data.record.BatikMethods.java

public void drawArrow(SVGGraphics2D g2d, GeomPoint start, GeomPoint end, float thickness, float alpha,
        Color linecoler, Color fillColor) {

    if (start.equals(end))
        return;// ww w  .j a  va  2 s  .  co  m

    //      (double edgeControlPosition, double edgeControlSize,
    //            double headLength, double headWidth, double shaftControlPosition,
    //            double shaftControlSize, float shaftPosition, double shaftThickness)
    ArrowStyle arrowStyle = new ArrowStyle(0.5, 0.5, thickness * 5, thickness * 5, 0.5, 0.5, 0, thickness);

    GeomPoint fullVect = end.subtract(start);
    double halfWidth = (arrowStyle.headWidth != -1) ? arrowStyle.headWidth / 2 : arrowStyle.headLength / 2;

    //Figure out the line start/end points
    GeomPoint startNorm = new GeomPoint();
    startNorm.setLocation(fullVect.getY(), -fullVect.getX());
    startNorm.normalize(arrowStyle.shaftThickness / 2);
    GeomPoint start1 = start.add(startNorm);
    GeomPoint start2 = start.subtract(startNorm);
    GeomPoint end1 = end.add(startNorm);
    GeomPoint end2 = end.subtract(startNorm);

    //log.debug("startNorm: "+startNorm.toString());
    //log.debug("start1: "+start1.toString());
    //log.debug("start2: "+start2.toString());
    //log.debug("end1: "+end1.toString());
    //log.debug("end2: "+end2.toString());

    //figure out where the arrow head starts
    GeomPoint headPnt = fullVect.clone();
    //log.debug("headPnt 1: "+headPnt.toString());
    //log.debug("headPnt.length 1: "+headPnt.length());
    //log.debug("arrowStyle.headLength 1: "+arrowStyle.headLength);
    headPnt.normalize(headPnt.length() - arrowStyle.headLength);
    //log.debug("headPnt 2: "+headPnt.toString());
    headPnt = headPnt.add(start);
    //log.debug("headPnt 3: "+headPnt.toString());

    //calculate the arrowhead corners
    GeomPoint headPntNorm = startNorm.clone();
    //log.debug("headPntNorm ^^: "+headPntNorm.toString());
    //log.debug("halfWidth ^^: "+halfWidth);
    headPntNorm.normalize(halfWidth);
    //log.debug("headPntNorm: "+headPntNorm.toString());
    GeomPoint edge1 = headPnt.add(headPntNorm);
    GeomPoint edge2 = headPnt.subtract(headPntNorm);

    //log.debug("edge1: "+edge1.toString());
    //log.debug("edge2: "+edge2.toString());

    //Figure out where the arrow connects the the shaft, then calc the intersections
    GeomPoint shaftCenter = GeomPoint.interpolate(end, headPnt, arrowStyle.shaftPosition);
    //log.debug("end"+end.toString());
    //log.debug("headPnt: "+headPnt.toString());
    //log.debug("arrowStyle.shaftPosition: "+arrowStyle.shaftPosition);
    //log.debug("shaftCenter: "+shaftCenter);
    //log.debug("edge1: "+edge1);
    //shaftCenter.setLocation(185.857864376269, 185.857864376269);
    GeomPoint inter1 = GeomPoint.getLineIntersection(start1, end1, shaftCenter, edge1);
    GeomPoint inter2 = GeomPoint.getLineIntersection(start2, end2, shaftCenter, edge2);

    //log.debug("inter1: "+inter1.toString());
    //log.debug("inter2: "+inter2.toString());

    //Figure out the control points
    GeomPoint edgeCenter = GeomPoint.interpolate(end, headPnt, (float) arrowStyle.edgeControlPosition);
    GeomPoint edgeNorm = startNorm.clone();
    edgeNorm.normalize(halfWidth * arrowStyle.edgeControlSize);
    //log.debug("halfWidth*arrowStyle.edgeControlSize: "+(halfWidth*arrowStyle.edgeControlSize));
    //log.debug("edgeNorm: "+edgeNorm.toString());
    GeomPoint edgeCntrl1 = edgeCenter.add(edgeNorm);
    GeomPoint edgeCntrl2 = edgeCenter.subtract(edgeNorm);

    //log.debug("edgeCntrl1: "+edgeCntrl1.toString());
    //log.debug("edgeCntrl2: "+edgeCntrl2.toString());

    g2d.setPaint(new Color(255, 0, 0));

    //      graphics.moveTo(start1.x,start1.y);
    //      graphics.lineTo(inter1.x,inter1.y);
    //      graphics.lineTo(edge1.x,edge1.y);
    //      graphics.curveTo(edgeCntrl1.x,edgeCntrl1.y,end.x,end.y);
    //      graphics.curveTo(edgeCntrl2.x,edgeCntrl2.y,edge2.x,edge2.y);
    //      graphics.lineTo(inter2.x,inter2.y);
    //      graphics.lineTo(start2.x,start2.y);
    //      graphics.lineTo(start1.x,start1.y);

    //      log.debug("moveTo"+start1.x+","+start1.y);
    //      log.debug("lineTo"+inter1.x+","+inter1.y);
    //      log.debug("lineTo"+edge1.x+","+edge1.y);
    //      log.debug("quadTo"+edgeCntrl1.x+","+edgeCntrl1.y+","+end.x+","+end.y);
    //      log.debug("quadTo"+edgeCntrl2.x+","+edgeCntrl2.y+","+edge2.x+","+edge2.y);
    //      log.debug("lineTo"+inter2.x+","+inter2.y);
    //      log.debug("lineTo"+start2.x+","+start2.y);
    //      log.debug("lineTo"+start1.x+","+start1.y);

    GeneralPath graphics = new GeneralPath();
    graphics.moveTo(start1.x, start1.y);
    graphics.lineTo(inter1.x, inter1.y);
    graphics.lineTo(edge1.x, edge1.y);
    graphics.quadTo(edgeCntrl1.x, edgeCntrl1.y, end.x, end.y);
    graphics.quadTo(edgeCntrl2.x, edgeCntrl2.y, edge2.x, edge2.y);
    graphics.lineTo(inter2.x, inter2.y);
    graphics.lineTo(start2.x, start2.y);
    graphics.lineTo(start1.x, start1.y);
    graphics.closePath();

    int[] rules = new int[8];

    //all possible Compositing Rules:
    rules[0] = AlphaComposite.SRC_OVER;
    rules[1] = AlphaComposite.DST_OVER;
    rules[2] = AlphaComposite.CLEAR;
    rules[3] = AlphaComposite.SRC;
    rules[4] = AlphaComposite.SRC_IN;
    rules[5] = AlphaComposite.DST_IN;
    rules[6] = AlphaComposite.SRC_OUT;
    rules[7] = AlphaComposite.DST_OUT;

    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, alpha));
    g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));

    if (linecoler != null) {
        g2d.setPaint(linecoler);
        g2d.draw(graphics);
    }

    if (fillColor != null) {
        g2d.setPaint(fillColor);
        g2d.fill(graphics);
    }

}