Example usage for java.awt.geom GeneralPath GeneralPath

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

Introduction

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

Prototype

public GeneralPath() 

Source Link

Document

Constructs a new empty single precision GeneralPath object with a default winding rule of #WIND_NON_ZERO .

Usage

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.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
 *///from   w ww  .j  a  v  a 2 s . co  m
private void createGlyphsAndAddToPlot(XYPlot plot, double glyphScaleFactor) {
    XYShapeAnnotation glyph;
    Shape glyphShape = null;
    Color glyphColor;

    double glyphSize = 8.0; //pixels

    double glyphIncrement = (glyphSize * glyphScaleFactor) / 2.0;
    float gi = (float) glyphIncrement;

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

        x = pcaPoint.getComponentValue(component1);
        y = pcaPoint.getComponentValue(component2);

        Double mriPctChange = pcaPoint.getTumorMRIpctChange();

        if (mriPctChange == null) {
            //data is missing
            Rectangle2D.Double rect = new Rectangle2D.Double();
            //rect.setFrameFromCenter(x,y, x+1.25,y+1.25);
            rect.setFrameFromCenter(x, y, x + glyphIncrement, y + glyphIncrement);
            glyphShape = rect;
        } else if (mriPctChange <= -30.0) {

            //tumor shrank by more than 30% (down arrow)
            GeneralPath gp = new GeneralPath();
            float xf = (float) x;
            float yf = (float) y;

            //make a triangle
            gp.moveTo(xf, yf);
            gp.lineTo(xf - gi, yf + gi);
            gp.lineTo(xf + gi, yf + gi);
            gp.closePath();
            glyphShape = gp;
        } else if (mriPctChange > 0.0) {
            //tumor size increased (up arrow)

            GeneralPath gp = new GeneralPath();
            float xf = (float) x;
            float yf = (float) y;
            //make a triangle
            gp.moveTo(xf, yf);
            gp.lineTo(xf + gi, yf - gi);
            gp.lineTo(xf - gi, yf - gi);
            gp.closePath();
            glyphShape = gp;

            //         Ellipse2D.Double circle = new Ellipse2D.Double();
            //         circle.setFrameFromCenter(x,y, x+2, y+2);

        } else if ((mriPctChange > -30.0) && (mriPctChange <= 0.0)) {
            //no change or reduction in tumor size but less than 30% reduction
            Ellipse2D.Double circle = new Ellipse2D.Double();
            //circle.setFrameFromCenter(x,y,x+1.25,y+1.25);
            circle.setFrameFromCenter(x, y, x + gi, y + gi);
            glyphShape = circle;

        }

        glyphColor = getColorForDataPoint(pcaPoint);
        glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor);

        String tooltip = pcaPoint.toString();

        glyph.setToolTipText(tooltip);
        plot.addAnnotation(glyph);
    }

}

From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

@Override
public void resetView() {
    AttackManager.getSingleton().addManagerListener(this);
    //setup renderer and general view
    // ((DoItYourselfAttackTableModel) jAttackTable.getModel()).clear();

    HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0, 1, 2,
            3, 6);//from w  ww. j  a va2  s .  c o  m
    jAttackTable.setRowHeight(24);
    jAttackTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jAttackTable.setHighlighters(new CompoundHighlighter(colu,
            HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)));
    jAttackTable.setColumnControlVisible(true);
    jAttackTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor());
    jAttackTable.setDefaultEditor(Village.class, new VillageCellEditor());
    jAttackTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jAttackTable.setDefaultRenderer(Integer.class,
            new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    jAttackTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jAttackTable.setDefaultRenderer(Long.class, new ColoredCoutdownCellRenderer());
    jAttackTable.setDefaultEditor(Date.class, new DateSpinEditor());
    jAttackTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE));
    BufferedImage back = ImageUtils.createCompatibleBufferedImage(5, 5, BufferedImage.BITMASK);
    Graphics2D g = back.createGraphics();
    GeneralPath p = new GeneralPath();
    p.moveTo(0, 0);
    p.lineTo(5, 0);
    p.lineTo(5, 5);
    p.closePath();
    g.setColor(Color.GREEN.darker());
    g.fill(p);
    g.dispose();
    jAttackTable.addHighlighter(new PainterHighlighter(HighlightPredicate.EDITABLE,
            new ImagePainter(back, HorizontalAlignment.RIGHT, VerticalAlignment.TOP)));

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    DefaultComboBoxModel model2 = new DefaultComboBoxModel();
    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        model.addElement(unit);
        model2.addElement(unit);
    }
    jUnitBox.setModel(model);
    jUnitComboBox.setModel(model2);
    jUnitBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitComboBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitBox.setRenderer(new UnitListCellRenderer());
    jAttackTypeComboBox.setRenderer(new StandardAttackListCellRenderer());

    DefaultComboBoxModel typeModel = new DefaultComboBoxModel();

    for (ManageableType t : StandardAttackManager.getSingleton().getAllElements()) {
        StandardAttack a = (StandardAttack) t;
        typeModel.addElement(a);
    }
    jAttackTypeComboBox.setModel(typeModel);

    jUnitComboBox.setRenderer(new UnitListCellRenderer());

    jSourceVillage.setValue(new Point(500, 500));
    jTargetVillage.setValue(new Point(500, 500));
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jSourceVillage.updateUI();
            jTargetVillage.updateUI();
        }
    });

}

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 {//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.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
 *///from  ww w.  jav  a2  s .  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:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

public BufferedImage getFlattenedImage(boolean overlayAscan) {

    ROIPanel pan = view;//from  w w w . j  a  v  a2 s.com
    BufferedImage rst = previewPanel.getImage();
    if (axis == AXIS_Y) {
        int wide = 0;
        for (int i = 0; i < pan.getImage().getWidth(); i++) {
            if (getUseData(i)) {
                wide++;
            }
        }

        if (rst == null || rst.getWidth() != wide || rst.getHeight() != pan.getImage().getHeight()) {
            rst = ImageOperations.getBi(wide, pan.getImage().getHeight());
        } else {
            ImageOperations.setImage(Color.BLACK, rst);
        }
        // This will get the smoothed out aScan from the Dynamic?Range panel
        int posX = 0;
        int posY = 0;

        for (int i = 0; i < pan.getImage().getWidth(); i++) {
            posY = 0;

            if (getUseData(i)) {
                int start = (int) (pan.getImage().getHeight() * (1 - getSelectionValue(i)));
                for (int j = start; j < pan.getImage().getHeight(); j++) {
                    if (j > 0 && i > 0) {
                        try {
                            rst.setRGB(posX, posY, pan.getImage().getRGB(i, j));
                        } catch (Exception e) {
                            System.out.println("Org [" + i + "," + j + "], Pos :[" + posX + "," + posY);
                        }
                    }
                    posY++;
                }
                posX++;
            }

        }
    } else if (axis == AXIS_X) {
        int high = 0;
        for (int i = 0; i < pan.getImage().getHeight(); i++) {
            if (getUseData(i)) {
                high++;
            }
        }

        if (rst == null || rst.getHeight() != high || rst.getWidth() != pan.getImage().getWidth()) {
            rst = ImageOperations.getBi(pan.getImage().getWidth(), high);
        } else {
            ImageOperations.setImage(Color.BLACK, rst);
        }
        // This will get the smoothed out aScan from the Dynamic?Range panel
        int posX = 0;
        int posY = 0;

        for (int i = 0; i < pan.getImage().getHeight(); i++) {
            posX = 0;

            if (getUseData(i)) {
                int start = (int) (pan.getImage().getWidth() * (1 - getSelectionValue(i)));
                for (int j = start; j < pan.getImage().getWidth(); j++) {
                    if (j > 0 && i > 0) {
                        try {
                            rst.setRGB(posX, posY, pan.getImage().getRGB(j, i));
                        } catch (Exception e) {
                            System.out.println("Org [" + i + "," + j + "], Pos :[" + posX + "," + posY);
                        }
                    }
                    posX++;
                }
                posY++;
            }

        }
    }

    if (overlayAscan) {
        Graphics2D g = rst.createGraphics();
        g.setColor(Color.cyan);
        GraphicsToolkit.setRenderingQuality(g, GraphicsToolkit.HIGH_QUALITY);
        float max = DataAnalysisToolkit.getMaxf(aScan);
        float min = DataAnalysisToolkit.getMinf(aScan);
        Line2D.Double line = new Line2D.Double();

        GeneralPath path = new GeneralPath();
        for (int i = 0; i < aScan.length; i++) {
            int xP = 0;
            int yP = 0;

            float p1 = ((aScan[i] - min) / (max - min));

            double x = 0;
            double y = 0;

            if (axis == AXIS_Y) {

                y = rst.getHeight() / (double) (aScan.length - 1) * i;
                x = rst.getWidth() * (1 - p1);

            } else if (axis == AXIS_X) {
                x = rst.getWidth() / (double) (aScan.length - 1) * i;
                y = rst.getHeight() * (1 - p1);

            }

            if (i == 0) {
                path.moveTo(x, y);
            } else {
                path.lineTo(x, y);
            }

        }
        g.draw(path);
    }
    return rst;
}

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;/*from w ww. j a  va  2s.c o m*/
            y = dummy;
        }
        if (path == null) {
            path = new GeneralPath();
            path.moveTo(x, y);
        } else {
            path.lineTo(x, y);
        }
    }
    return path;
}

From source file:com.cburch.draw.shapes.Poly.java

private GeneralPath getPath() {
    GeneralPath p = path;//from w  w  w  .j  a  v a2 s  . co  m
    if (p == null) {
        p = new GeneralPath();
        Handle[] hs = handles;
        if (hs.length > 0) {
            boolean first = true;
            for (Handle h : hs) {
                if (first) {
                    p.moveTo(h.getX(), h.getY());
                    first = false;
                } else {
                    p.lineTo(h.getX(), h.getY());
                }
            }
        }
        path = p;
    }
    return p;
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.MapPNode.java

private void init(JFrame parentFrame, SOMLibFormatInputReader inputReader, CommonSOMViewerStateData state,
        GrowingLayer growingLayer, boolean inizializeVis) {
    this.state = state;
    state.somInputReader = inputReader;/*w  ww .j  av  a 2 s  . co  m*/

    this.parentFrame = parentFrame;

    state.mapPNode = this;

    state.growingLayer = growingLayer;
    state.growingSOM = gsom;
    inputObjects = state.inputDataObjects;
    gsom.setSharedInputObjects(inputObjects);

    classInfo = inputObjects.getClassInfo();
    dataInfo = inputObjects.getDataInfo();

    // rudi: read input mapping shifts. note: has to be done before the units are constructed & displayed
    SOMVisualisationData inputCorrectionContainer = state.inputDataObjects
            .getObject(SOMVisualisationData.INPUT_CORRECTIONS);
    String fileName = inputCorrectionContainer.getFileName();
    if (fileName != null && !fileName.trim().equals("")) {
        try {
            InputCorrections inputCorrections = new InputCorrections(fileName, growingLayer,
                    state.inputDataObjects.getInputData());
            inputCorrectionContainer.setData(inputCorrections);
        } catch (SOMToolboxException e) {
            Logger.getLogger("at.tuwien.ifs.somtoolbox").severe(e.getMessage());
        }
    } else if (inputCorrectionContainer.getData() == null) { // create an empty object
        inputCorrectionContainer.setData(new InputCorrections());
    }

    // create unit nodes
    units = new GeneralUnitPNode[growingLayer.getXSize()][growingLayer.getYSize()];
    unitsNode = new PNode();
    unitsNode.addAttribute("type", "unitsNode");
    addChild(unitsNode);
    try {
        if (inputObjects.getDataWinnerMapping() == null) {
            state.exactUnitPlacementEnabled = false;
        }
        ProgressListener progress = new StdErrProgressWriter(growingLayer.getUnitCount(), "Initialising unit ",
                50);
        for (int j = 0; j < growingLayer.getYSize(); j++) {
            for (int i = 0; i < growingLayer.getXSize(); i++) {
                if (growingLayer.getUnit(i, j) != null) { // check needed for mnemonic SOMs (might not have all
                    // units != null)
                    Unit unit = growingLayer.getUnit(i, j);
                    Point[][] locations = null;
                    if (inputObjects.getDataWinnerMapping() != null) {
                        locations = initInputLocations(unit);
                    }
                    units[i][j] = new GeneralUnitPNode(unit, state, classInfo, dataInfo, locations, UNIT_WIDTH,
                            UNIT_HEIGHT);
                    unitsNode.addChild(units[i][j]);
                }
                progress.progress();
            }
        }
    } catch (LayerAccessException e) {
        Logger.getLogger("at.tuwien.ifs.somtoolbox").severe(e.getMessage());
        System.exit(-1);
    }

    // if we have a class info on startup, we show classes
    if (classInfo != null) {
        state.setClassPiechartMode(SOMViewer.TOGGLE_PIE_CHARTS_SHOW);
        setClassColors(classInfo.getClassColors());
    }

    // create tooltip object and add event listener
    // final ToolTipPNode tooltipNode = new ToolTipPNode();
    // this.addChild(tooltipNode);
    // this.addInputEventListener(new MyMapInputEventHandler(tooltipNode, this));

    // initialize available visualizations
    if (inizializeVis) {
        Visualizations.initVisualizations(inputObjects, inputReader, this);
    }
    visualizations = Visualizations.getAvailableVisualizations();

    // Angela: add the empty nodes for manually created labels
    this.addChild(manualLabels);
    manualLabels.moveToFront();

    // add input correction arrows
    addChild(inputCorrectionsPNode);
    inputCorrectionsPNode.moveToFront();

    // rudi: display linkages between data items
    if (state.inputDataObjects.getLinkageMap() != null) {
        Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Drawing constellations.");
        GeneralPath path = new GeneralPath();
        Map<String, String> linkageMap = state.inputDataObjects.getLinkageMap();
        for (String beginName : linkageMap.keySet()) {
            String endName = linkageMap.get(beginName);
            Point beginPoint = getPointLocation(beginName);
            Point endPoint = getPointLocation(endName);
            if (beginPoint != null && endPoint != null) {
                path.append(new Line2D.Double(beginPoint, endPoint), false);
            }
        }
        inputLinkagePath = new PPath(path);
        inputLinkagePath.setStrokePaint(new Color(232, 232, 57));
        inputLinkagePath.setStroke(new BasicStroke(1.5f));
        inputLinkagePath.setPickable(false);
        if (state.displayInputLinkage) {
            addChild(inputLinkagePath);
            inputLinkagePath.moveToBack();
        }
        Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Drawing constellations done.");
    }

    // display input mapping shifts. note: has to be done after the units are constructed
    createInputCorrectionArrows();

    imageDataNode = new PNode();
    this.addChild(imageDataNode);
    // if we have a SOM of image types, create image nodes
    if (gsom.getDataContentType() != null && gsom.getDataContentType().isImage()
            || org.apache.commons.lang.StringUtils.isNotBlank(CommonSOMViewerStateData.imagePrefix)
            || org.apache.commons.lang.StringUtils.isNotBlank(CommonSOMViewerStateData.imageSuffix)) {

        createDataImages();
    }
}

From source file:org.trade.ui.chart.renderer.PivotRenderer.java

/**
 * Draws the annotation./*from ww w  . j  a  v  a  2  s.  c  o  m*/
 * 
 * @param g2
 *            the graphics device.
 * @param plot
 *            the plot.
 * @param dataArea
 *            the data area.
 * @param domainAxis
 *            the domain axis.
 * @param rangeAxis
 *            the range axis.
 * @param rendererIndex
 *            the renderer index.
 * @param info
 *            the plot rendering info.
 * @param angle
 *            double
 * @param x
 *            double
 * @param y
 *            double
 * @param ledgend
 *            String
 */
public void drawPivotArrow(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis,
        ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info, double angle, double x, double y,
        String ledgend) {

    double tipRadius = DEFAULT_TIP_RADIUS;
    double baseRadius = DEFAULT_BASE_RADIUS;
    double arrowLength = DEFAULT_ARROW_LENGTH;
    double arrowWidth = DEFAULT_ARROW_WIDTH;
    double labelOffset = DEFAULT_LABEL_OFFSET;
    Font font = DEFAULT_FONT;
    Paint paint = DEFAULT_PAINT;
    boolean outlineVisible = false;
    Paint outlinePaint = Color.black;
    Stroke outlineStroke = new BasicStroke(0.5f);

    TextAnchor textAnchor = DEFAULT_TEXT_ANCHOR;
    TextAnchor rotationAnchor = DEFAULT_ROTATION_ANCHOR;
    double rotationAngle = DEFAULT_ROTATION_ANGLE;

    Stroke arrowStroke = new BasicStroke(1.0f);
    Paint arrowPaint = Color.black;

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation);
    double j2DX = domainAxis.valueToJava2D(x, dataArea, domainEdge);
    double j2DY = rangeAxis.valueToJava2D(y, dataArea, rangeEdge);
    if (orientation == PlotOrientation.HORIZONTAL) {
        double temp = j2DX;
        j2DX = j2DY;
        j2DY = temp;
    }
    double startX = j2DX + (Math.cos(angle) * baseRadius);
    double startY = j2DY + (Math.sin(angle) * baseRadius);

    double endX = j2DX + (Math.cos(angle) * tipRadius);
    double endY = j2DY + (Math.sin(angle) * tipRadius);

    double arrowBaseX = endX + (Math.cos(angle) * arrowLength);
    double arrowBaseY = endY + (Math.sin(angle) * arrowLength);

    double arrowLeftX = arrowBaseX + (Math.cos(angle + (Math.PI / 2.0)) * arrowWidth);
    double arrowLeftY = arrowBaseY + (Math.sin(angle + (Math.PI / 2.0)) * arrowWidth);

    double arrowRightX = arrowBaseX - (Math.cos(angle + (Math.PI / 2.0)) * arrowWidth);
    double arrowRightY = arrowBaseY - (Math.sin(angle + (Math.PI / 2.0)) * arrowWidth);

    GeneralPath arrow = new GeneralPath();
    arrow.moveTo((float) endX, (float) endY);
    arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
    arrow.lineTo((float) arrowRightX, (float) arrowRightY);
    arrow.closePath();

    g2.setStroke(arrowStroke);
    g2.setPaint(arrowPaint);
    Line2D line = new Line2D.Double(startX, startY, endX, endY);
    g2.draw(line);
    g2.fill(arrow);

    // draw the label
    double labelX = j2DX + (Math.cos(angle) * (baseRadius + labelOffset));
    double labelY = j2DY + (Math.sin(angle) * (baseRadius + labelOffset));
    g2.setFont(font);
    Shape hotspot = TextUtilities.calculateRotatedStringBounds(ledgend, g2, (float) labelX, (float) labelY,
            textAnchor, rotationAngle, rotationAnchor);
    g2.setPaint(paint);
    TextUtilities.drawRotatedString(ledgend, g2, (float) labelX, (float) labelY, textAnchor, rotationAngle,
            rotationAnchor);
    if (outlineVisible) {
        g2.setStroke(outlineStroke);
        g2.setPaint(outlinePaint);
        g2.draw(hotspot);
    }

    // String toolTip = getToolTipText();
    // String url = getURL();
    // if (toolTip != null || url != null) {
    // addEntity(info, hotspot, rendererIndex, toolTip, url);
    // }

}

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

private void buildLegend() {
    LegendTitle legend = corrChart.getLegend();
    LegendItemSource[] sources = new LegendItemSource[1];
    CorrLegendItemSource legendSrc = new CorrLegendItemSource();
    LegendItem item = null;/*from   www . jav a2  s  .c  om*/

    //Rect=survival less than 10 months

    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);

    item = new LegendItem("Tumor size change N/A", null, null, null, new Rectangle2D.Double(0, 0, 8, 8),
            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);
        }
    } else if ((colorBy == ColorByType.IHC_EXPRESSION_X) || (colorBy == ColorByType.IHC_EXPRESSION_Y)) {
        //         for (CorrScatterColorByIHCType ihcType : CorrScatterColorByIHCType.values()) {
        //          item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0,0,6,6), new BasicStroke(3.0f), ihcType.getColor());
        //         legendSrc.addLegendItem(item);  
        //         }
        if (ihcBiomarkerType == IHCBiomarkerType.BCL2) {
            for (BCL2ihcType ihcType : BCL2ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.EGFR) {
            for (EGFRihcType ihcType : EGFRihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.FAK) {
            for (FAKihcType ihcType : FAKihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.HER2) {
            for (HER2ihcType ihcType : HER2ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.KI67) {
            for (Ki67ihcType ihcType : Ki67ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.P27) {
            for (P27ihcType ihcType : P27ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.P53) {
            for (P53ihcType ihcType : P53ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        } else if (ihcBiomarkerType == IHCBiomarkerType.CYCLIN_D1) {
            for (CCND1ihcType ihcType : CCND1ihcType.values()) {
                item = new LegendItem(ihcType.toString(), null, null, null, new Line2D.Double(0, 0, 6, 6),
                        new BasicStroke(3.0f), ihcType.getColor());
                legendSrc.addLegendItem(item);
            }
        }

    }

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

}