java.awt.geom.Line2D#Float ( )源码实例Demo

下面列出了java.awt.geom.Line2D#Float ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: Underline.java
Shape getUnderlineShape(float thickness,
                        float x1,
                        float x2,
                        float y) {

    GeneralPath gp = new GeneralPath();

    Line2D.Float line = new Line2D.Float(x1, y, x2, y);
    gp.append(stroke.createStrokedShape(line), false);

    line.y1 += DEFAULT_THICKNESS;
    line.y2 += DEFAULT_THICKNESS;
    line.x1 += DEFAULT_THICKNESS;

    gp.append(stroke.createStrokedShape(line), false);

    return gp;
}
 
源代码2 项目: openstock   文件: ChartPanel.java
/**
 * Draws a horizontal line used to trace the mouse position to the vertical
 * axis.
 *
 * @param g2 the graphics device.
 * @param y  the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(Graphics2D g2, int y) {

    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(Color.orange);
    if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {

        if (this.horizontalTraceLine != null) {
            g2.draw(this.horizontalTraceLine);
            this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y,
                    (int) dataArea.getMaxX(), y);
        }
        else {
            this.horizontalTraceLine = new Line2D.Float(
                    (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(),
                    y);
        }
        g2.draw(this.horizontalTraceLine);
    }

    // Reset to the default 'overwrite' mode
    g2.setPaintMode();
}
 
源代码3 项目: hottub   文件: Underline.java
Shape getUnderlineShape(float thickness,
                        float x1,
                        float x2,
                        float y) {

    GeneralPath gp = new GeneralPath();

    Line2D.Float line = new Line2D.Float(x1, y, x2, y);
    gp.append(stroke.createStrokedShape(line), false);

    line.y1 += DEFAULT_THICKNESS;
    line.y2 += DEFAULT_THICKNESS;
    line.x1 += DEFAULT_THICKNESS;

    gp.append(stroke.createStrokedShape(line), false);

    return gp;
}
 
源代码4 项目: opensim-gui   文件: ChartPanel.java
/**
 * Draws a horizontal line used to trace the mouse position to the vertical
 * axis.
 *
 * @param y  the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(int y) {

    Graphics2D g2 = (Graphics2D) getGraphics();
    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(java.awt.Color.orange);
    if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {

        if (this.horizontalTraceLine != null) {
            g2.draw(this.horizontalTraceLine);
            this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, 
                    (int) dataArea.getMaxX(), y);
        }
        else {
            this.horizontalTraceLine = new Line2D.Float(
                    (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), 
                    y);
        }
        g2.draw(this.horizontalTraceLine);
    }

}
 
源代码5 项目: snap-desktop   文件: StatisticsUtilsTest.java
@Test
public void testCreateTransectProfileText_Byte() throws IOException {
    final Product product = new Product("X", "Y", 2, 1);
    Band node = product.addBand("name", ProductData.TYPE_INT8);
    node.setSynthetic(true);
    node.setNoDataValue(0);
    node.setNoDataValueUsed(true);
    final byte[] data = new byte[product.getSceneRasterWidth() * product.getSceneRasterHeight()];
    Arrays.fill(data, (byte) 1);
    data[0] = 0; // no data
    node.setData(ProductData.createInstance(data));

    final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f);
    final TransectProfileData profileData = node.createTransectProfileData(shape);
    final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData);
    assertTrue(profileDataString.contains("NaN"));
    assertFalse(profileDataString.toLowerCase().contains("no data"));
}
 
源代码6 项目: opensim-gui   文件: ChartPanel.java
/**
 * Draws a vertical line used to trace the mouse position to the horizontal 
 * axis.
 *
 * @param x  the x-coordinate of the trace line.
 */
private void drawHorizontalAxisTrace(int x) {

    Graphics2D g2 = (Graphics2D) getGraphics();
    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(java.awt.Color.orange);
    if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) {

        if (this.verticalTraceLine != null) {
            g2.draw(this.verticalTraceLine);
            this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, 
                    (int) dataArea.getMaxY());
        }
        else {
            this.verticalTraceLine = new Line2D.Float(x, 
                    (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
        }
        g2.draw(this.verticalTraceLine);
    }

}
 
源代码7 项目: TencentKona-8   文件: Underline.java
void drawUnderline(Graphics2D g2d,
                   float thickness,
                   float x1,
                   float x2,
                   float y) {

    Stroke saveStroke = g2d.getStroke();
    g2d.setStroke(stroke);

    Line2D.Float drawLine = new Line2D.Float(x1, y, x2, y);
    g2d.draw(drawLine);

    drawLine.y1 += DEFAULT_THICKNESS;
    drawLine.y2 += DEFAULT_THICKNESS;
    drawLine.x1 += DEFAULT_THICKNESS;

    g2d.draw(drawLine);

    g2d.setStroke(saveStroke);
}
 
源代码8 项目: ccu-historian   文件: ChartPanel.java
/**
 * Draws a horizontal line used to trace the mouse position to the vertical
 * axis.
 *
 * @param g2 the graphics device.
 * @param y  the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(Graphics2D g2, int y) {

    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(Color.orange);
    if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {

        if (this.horizontalTraceLine != null) {
            g2.draw(this.horizontalTraceLine);
            this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y,
                    (int) dataArea.getMaxX(), y);
        }
        else {
            this.horizontalTraceLine = new Line2D.Float(
                    (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(),
                    y);
        }
        g2.draw(this.horizontalTraceLine);
    }

    // Reset to the default 'overwrite' mode
    g2.setPaintMode();
}
 
源代码9 项目: ccu-historian   文件: ShapeUtilitiesTest.java
/**
 * Tests the equal() method.
 */
public void testEqualLine2Ds() {

    assertTrue(ShapeUtilities.equal((Line2D) null, (Line2D) null));
    Line2D l1 = new Line2D.Float(1.0f, 2.0f, 3.0f, 4.0f);
    Line2D l2 = new Line2D.Float(1.0f, 2.0f, 3.0f, 4.0f);
    assertTrue(ShapeUtilities.equal(l1, l2));

    l1 = new Line2D.Float(4.0f, 3.0f, 2.0f, 1.0f);
    assertFalse(ShapeUtilities.equal(l1, l2));
    l2 = new Line2D.Float(4.0f, 3.0f, 2.0f, 1.0f);
    assertTrue(ShapeUtilities.equal(l1, l2));

    l1 = new Line2D.Double(4.0f, 3.0f, 2.0f, 1.0f);
    assertTrue(ShapeUtilities.equal(l1, l2));

}
 
源代码10 项目: jdk8u-jdk   文件: Underline.java
void drawUnderline(Graphics2D g2d,
                   float thickness,
                   float x1,
                   float x2,
                   float y) {

    Stroke saveStroke = g2d.getStroke();
    g2d.setStroke(stroke);

    Line2D.Float drawLine = new Line2D.Float(x1, y, x2, y);
    g2d.draw(drawLine);

    drawLine.y1 += DEFAULT_THICKNESS;
    drawLine.y2 += DEFAULT_THICKNESS;
    drawLine.x1 += DEFAULT_THICKNESS;

    g2d.draw(drawLine);

    g2d.setStroke(saveStroke);
}
 
源代码11 项目: radiance   文件: CookbookBorderLeft.java
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    SubstanceColorScheme scheme = SubstanceCortex.ComponentScope.getCurrentSkin(c)
            .getColorScheme(c, ColorSchemeAssociationKind.BORDER, ComponentState.ENABLED);

    Graphics2D g2d = (Graphics2D) g.create();

    // light line on the left-hand side
    g2d.setComposite(AlphaComposite.SrcOver);
    Color baseColor = scheme.getLightColor();
    g2d.setPaint(new GradientPaint(x, y,
            new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(),
                    (int) (baseColor.getAlpha() * this.alphaTop)),
            x, y + height, new Color(baseColor.getRed(), baseColor.getGreen(),
                    baseColor.getBlue(), (int) (baseColor.getAlpha() * this.alphaBottom))));
    // start one pixel lower so that the top border painted by the
    // decoration painter on footers doesn't get overriden
    float borderStrokeWidth = 1.0f / (float) NeonCortex.getScaleFactor();
    g2d.setStroke(new BasicStroke(borderStrokeWidth));
    float topY = y + (skipTopPixel ? borderStrokeWidth : 0);
    float bottomY = y + height - borderStrokeWidth - (skipBottomPixel ? borderStrokeWidth : 0);
    Line2D.Float line = new Line2D.Float(x, topY, x, bottomY);
    g2d.draw(line);

    g2d.dispose();
}
 
源代码12 项目: ccu-historian   文件: Line2DObjectDescription.java
/**
 * Creates an object based on this description.
 *
 * @return The object.
 */
public Object createObject() {
    final Line2D line = new Line2D.Float();

    final float x1 = getFloatParameter("x1");
    final float x2 = getFloatParameter("x2");
    final float y1 = getFloatParameter("y1");
    final float y2 = getFloatParameter("y2");
    line.setLine(x1, y1, x2, y2);
    return line;
}
 
源代码13 项目: orson-charts   文件: StandardCategoryAxis3D.java
/**
 * Draws the axis between the two points {@code pt0} and {@code pt1} in 
 * Java2D space.
 * 
 * @param g2  the graphics target ({@code null} not permitted).
 * @param pt0  the starting point for the axis ({@code null} not 
 *     permitted).
 * @param pt1  the ending point for the axis ({@code null} not 
 *     permitted).
 * @param opposingPt  a point on the opposite side of the line from the 
 *         labels ({@code null} not permitted).
 * @param tickData  the tick data, contains positioning anchors calculated 
 *     by the 3D engine ({@code null} not permitted).
 * @param info  an object to be populated with rendering info 
 *     ({@code null} permitted).
 * @param hinting  perform element hinting?
 */
@Override
public void draw(Graphics2D g2, Point2D pt0, Point2D pt1, 
        Point2D opposingPt, List<TickData> tickData, RenderingInfo info,
        boolean hinting) {
    
    if (!isVisible()) {
        return;
    }
    if (pt0.equals(pt1)) { // if the axis starts and ends on the same point
        return;            // there is nothing we can draw
    }
    
    // draw the axis line (if you want no line, setting the line color
    // to fully transparent will achieve this)
    g2.setStroke(getLineStroke());
    g2.setPaint(getLineColor());
    Line2D axisLine = new Line2D.Float(pt0, pt1);
    g2.draw(axisLine);
 
    // draw the tick marks - during this pass we will also find the maximum
    // tick label width
    g2.setPaint(this.tickMarkPaint);
    g2.setStroke(this.tickMarkStroke);
    g2.setFont(getTickLabelFont());
    double maxTickLabelWidth = 0.0;
    for (TickData t : tickData) {
        if (this.tickMarkLength > 0.0) {
            Line2D tickLine = Utils2D.createPerpendicularLine(axisLine, 
                    t.getAnchorPt(), this.tickMarkLength, opposingPt);
            g2.draw(tickLine);
        }
        String tickLabel = t.getKeyLabel();
        maxTickLabelWidth = Math.max(maxTickLabelWidth, 
                g2.getFontMetrics().stringWidth(tickLabel));
    }

    double maxTickLabelDim = maxTickLabelWidth;
    if (getTickLabelsVisible()) {
        g2.setPaint(getTickLabelColor());
        if (this.tickLabelOrientation.equals(
                LabelOrientation.PERPENDICULAR)) {
            drawPerpendicularTickLabels(g2, axisLine, opposingPt, tickData,
                    info, hinting);
        } else if (this.tickLabelOrientation.equals(
                LabelOrientation.PARALLEL)) {
            maxTickLabelDim = drawParallelTickLabels(g2, axisLine, 
                    opposingPt, tickData, maxTickLabelWidth, info, hinting);
        }
    } else {
        maxTickLabelDim = 0.0;
    }

    // draw the axis label if there is one
    if (getLabel() != null) {
        Shape labelBounds = drawAxisLabel(getLabel(), g2, axisLine, 
                opposingPt, maxTickLabelDim + this.tickMarkLength 
                + this.tickLabelOffset + getLabelOffset(), info, hinting);
    }
}
 
源代码14 项目: astor   文件: BarRenderer.java
/**
 * Returns a legend item for a series.
 *
 * @param datasetIndex  the dataset index (zero-based).
 * @param series  the series index (zero-based).
 *
 * @return The legend item (possibly <code>null</code>).
 */
public LegendItem getLegendItem(int datasetIndex, int series) {

    CategoryPlot cp = getPlot();
    if (cp == null) {
        return null;
    }

    // check that a legend item needs to be displayed...
    if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) {
        return null;
    }

    CategoryDataset dataset = cp.getDataset(datasetIndex);
    String label = getLegendItemLabelGenerator().generateLabel(dataset, 
            series);
    String description = label;
    String toolTipText = null; 
    if (getLegendItemToolTipGenerator() != null) {
        toolTipText = getLegendItemToolTipGenerator().generateLabel(
                dataset, series);   
    }
    String urlText = null;
    if (getLegendItemURLGenerator() != null) {
        urlText = getLegendItemURLGenerator().generateLabel(dataset, 
                series);   
    }
    Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);
    Paint paint = lookupSeriesPaint(series);
    Paint outlinePaint = lookupSeriesOutlinePaint(series);
    Stroke outlineStroke = lookupSeriesOutlineStroke(series);

    LegendItem result = new LegendItem(label, description, toolTipText, 
            urlText, true, shape, true, paint, isDrawBarOutline(), 
            outlinePaint, outlineStroke, false, new Line2D.Float(), 
            new BasicStroke(1.0f), Color.black);
    result.setDataset(dataset);
    result.setDatasetIndex(datasetIndex);
    result.setSeriesKey(dataset.getRowKey(series));
    result.setSeriesIndex(series);
    if (this.gradientPaintTransformer != null) {
        result.setFillPaintTransformer(this.gradientPaintTransformer);
    }
    return result;
}
 
源代码15 项目: tabula-java   文件: CohenSutherlandClipping.java
/**
 * Clips a given line against the clip rectangle.
 * The modification (if needed) is done in place.
 * @param line the line to clip
 * @return true if line is clipped, false if line is
 * totally outside the clip rect.
 */
public boolean clip(Line2D.Float line) {

    double p1x = line.getX1();
    double p1y = line.getY1();
    double p2x = line.getX2();
    double p2y = line.getY2();

    double qx = 0d;
    double qy = 0d;

    boolean vertical = p1x == p2x;

    double slope = vertical 
        ? 0d
        : (p2y-p1y)/(p2x-p1x);

    int c1 = regionCode(p1x, p1y);
    int c2 = regionCode(p2x, p2y);

    while (c1 != INSIDE || c2 != INSIDE) {

        if ((c1 & c2) != INSIDE)
            return false;

        int c = c1 == INSIDE ? c2 : c1;

        if ((c & LEFT) != INSIDE) {
            qx = xMin;
            qy = (Utils.feq(qx, p1x) ? 0 : qx-p1x)*slope + p1y;
        }
        else if ((c & RIGHT) != INSIDE) {
            qx = xMax;
            qy = (Utils.feq(qx, p1x) ? 0 : qx-p1x)*slope + p1y;
        }
        else if ((c & BOTTOM) != INSIDE) {
            qy = yMin;
            qx = vertical
                ? p1x
                : (Utils.feq(qy, p1y) ? 0 : qy-p1y)/slope + p1x;
        }
        else if ((c & TOP) != INSIDE) {
            qy = yMax;
            qx = vertical
                ? p1x
                : (Utils.feq(qy, p1y) ? 0 : qy-p1y)/slope + p1x;
        }

        if (c == c1) {
            p1x = qx;
            p1y = qy;
            c1  = regionCode(p1x, p1y);
        }
        else {
            p2x = qx;
            p2y = qy;
            c2 = regionCode(p2x, p2y);
        }
    }
    line.setLine(p1x, p1y, p2x, p2y);
    return true;
}
 
源代码16 项目: buffer_bci   文件: PiePlot.java
/**
 * Returns a collection of legend items for the pie chart.
 *
 * @return The legend items (never <code>null</code>).
 */
@Override
public LegendItemCollection getLegendItems() {

    LegendItemCollection result = new LegendItemCollection();
    if (this.dataset == null) {
        return result;
    }
    List keys = this.dataset.getKeys();
    int section = 0;
    Shape shape = getLegendItemShape();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        Number n = this.dataset.getValue(key);
        boolean include;
        if (n == null) {
            include = !this.ignoreNullValues;
        }
        else {
            double v = n.doubleValue();
            if (v == 0.0) {
                include = !this.ignoreZeroValues;
            }
            else {
                include = v > 0.0;
            }
        }
        if (include) {
            String label = this.legendLabelGenerator.generateSectionLabel(
                    this.dataset, key);
            if (label != null) {
                String description = label;
                String toolTipText = null;
                if (this.legendLabelToolTipGenerator != null) {
                    toolTipText = this.legendLabelToolTipGenerator
                            .generateSectionLabel(this.dataset, key);
                }
                String urlText = null;
                if (this.legendLabelURLGenerator != null) {
                    urlText = this.legendLabelURLGenerator.generateURL(
                            this.dataset, key, this.pieIndex);
                }
                Paint paint = lookupSectionPaint(key);
                Paint outlinePaint = lookupSectionOutlinePaint(key);
                Stroke outlineStroke = lookupSectionOutlineStroke(key);
                LegendItem item = new LegendItem(label, description,
                        toolTipText, urlText, true, shape, true, paint,
                        true, outlinePaint, outlineStroke,
                        false,          // line not visible
                        new Line2D.Float(), new BasicStroke(), Color.black);
                item.setDataset(getDataset());
                item.setSeriesIndex(this.dataset.getIndex(key));
                item.setSeriesKey(key);
                result.add(item);
            }
            section++;
        }
        else {
            section++;
        }
    }
    return result;
}
 
源代码17 项目: openbd-core   文件: CustomBarRenderer.java
/**
 * Returns a legend item for a series.
 * 
 * @param datasetIndex
 *          the dataset index (zero-based).
 * @param series
 *          the series index (zero-based).
 * 
 * @return The legend item.
 */
public LegendItem getLegendItem(int datasetIndex, int series) {

	CategoryPlot cp = getPlot();
	if (cp == null) {
		return null;
	}

	CategoryDataset dataset;
	dataset = cp.getDataset(datasetIndex);
	String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
	String description = label;
	String toolTipText = null;
	if (getLegendItemToolTipGenerator() != null) {
		toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
	}
	String urlText = null;
	if (getLegendItemURLGenerator() != null) {
		urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
	}
	Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);
	Paint paint = getSeriesPaint(series);
	Paint outlinePaint = getSeriesOutlinePaint(series);
	Stroke outlineStroke = getSeriesOutlineStroke(series);

	// This is the fix for bug #2695
	if (paint instanceof java.awt.GradientPaint) {
		// When the paintstyle is "shade" use the lighter
		// color while with "light" use the darker color
		// NOTE: if we take the lighter color (Color2) and make it darker
		// and it equals the darker color (Color1) then the paintstyle
		// is "shade".
		GradientPaint gp = ((GradientPaint) paint);
		if (cfCHART.getDarkerColor(gp.getColor2()).equals(gp.getColor1()))
			paint = gp.getColor2(); // the lighter color
		else
			paint = gp.getColor1(); // the darker color
	}

	return new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black);
}
 
源代码18 项目: openbd-core   文件: CustomBarRenderer3D.java
/**
 * Returns a legend item for a series.
 * 
 * @param datasetIndex
 *          the dataset index (zero-based).
 * @param series
 *          the series index (zero-based).
 * 
 * @return The legend item.
 */
public LegendItem getLegendItem(int datasetIndex, int series) {

	CategoryPlot cp = getPlot();
	if (cp == null) {
		return null;
	}

	CategoryDataset dataset;
	dataset = cp.getDataset(datasetIndex);
	String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
	String description = label;
	String toolTipText = null;
	if (getLegendItemToolTipGenerator() != null) {
		toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
	}
	String urlText = null;
	if (getLegendItemURLGenerator() != null) {
		urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
	}
	Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);
	Paint paint = getSeriesPaint(series);
	Paint outlinePaint = getSeriesOutlinePaint(series);
	Stroke outlineStroke = getSeriesOutlineStroke(series);

	// This is the fix for bug #2695
	if (paint instanceof java.awt.GradientPaint) {
		// When the paintstyle is "shade" use the lighter
		// color while with "light" use the darker color
		// NOTE: if we take the lighter color (Color2) and make it darker
		// and it equals the darker color (Color1) then the paintstyle
		// is "shade".
		GradientPaint gp = ((GradientPaint) paint);
		if (cfCHART.getDarkerColor(gp.getColor2()).equals(gp.getColor1()))
			paint = gp.getColor2(); // the lighter color
		else
			paint = gp.getColor1(); // the darker color
	}

	return new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black);
}
 
源代码19 项目: astor   文件: PiePlot.java
/**
 * Returns a collection of legend items for the pie chart.
 *
 * @return The legend items (never <code>null</code>).
 */
public LegendItemCollection getLegendItems() {

    LegendItemCollection result = new LegendItemCollection();
    if (this.dataset == null) {
        return result;
    }
    List keys = this.dataset.getKeys();
    int section = 0;
    Shape shape = getLegendItemShape();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        Number n = this.dataset.getValue(key);
        boolean include = true;
        if (n == null) {
            include = !this.ignoreNullValues;
        }
        else {
            double v = n.doubleValue();
            if (v == 0.0) {
                include = !this.ignoreZeroValues;
            }
            else {
                include = v > 0.0;
            }
        }
        if (include) {
            String label = this.legendLabelGenerator.generateSectionLabel(
                    this.dataset, key);
            if (label != null) {
                String description = label;
                String toolTipText = null;
                if (this.legendLabelToolTipGenerator != null) {
                    toolTipText = this.legendLabelToolTipGenerator
                            .generateSectionLabel(this.dataset, key);
                }
                String urlText = null;
                if (this.legendLabelURLGenerator != null) {
                    urlText = this.legendLabelURLGenerator.generateURL(
                            this.dataset, key, this.pieIndex);
                }
                Paint paint = lookupSectionPaint(key, false);
                Paint outlinePaint = lookupSectionOutlinePaint(key, false);
                Stroke outlineStroke = lookupSectionOutlineStroke(key,
                        false);
                LegendItem item = new LegendItem(label, description,
                        toolTipText, urlText, true, shape, true, paint,
                        true, outlinePaint, outlineStroke,
                        false,          // line not visible
                        new Line2D.Float(), new BasicStroke(), Color.black);
                item.setDataset(getDataset());
                item.setSeriesIndex(this.dataset.getIndex(key));
                item.setSeriesKey(key);
                result.add(item);
            }
            section++;
        }
        else {
            section++;
        }
    }
    return result;
}
 
源代码20 项目: SIMVA-SoS   文件: BarRenderer.java
/**
 * Returns a legend item for a series.
 *
 * @param datasetIndex  the dataset index (zero-based).
 * @param series  the series index (zero-based).
 *
 * @return The legend item (possibly <code>null</code>).
 */
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {

    CategoryPlot cp = getPlot();
    if (cp == null) {
        return null;
    }

    // check that a legend item needs to be displayed...
    if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) {
        return null;
    }

    CategoryDataset dataset = cp.getDataset(datasetIndex);
    String label = getLegendItemLabelGenerator().generateLabel(dataset,
            series);
    String description = label;
    String toolTipText = null;
    if (getLegendItemToolTipGenerator() != null) {
        toolTipText = getLegendItemToolTipGenerator().generateLabel(
                dataset, series);
    }
    String urlText = null;
    if (getLegendItemURLGenerator() != null) {
        urlText = getLegendItemURLGenerator().generateLabel(dataset,
                series);
    }
    Shape shape = lookupLegendShape(series);
    Paint paint = lookupSeriesPaint(series);
    Paint outlinePaint = lookupSeriesOutlinePaint(series);
    Stroke outlineStroke = lookupSeriesOutlineStroke(series);

    LegendItem result = new LegendItem(label, description, toolTipText,
            urlText, true, shape, true, paint, isDrawBarOutline(),
            outlinePaint, outlineStroke, false, new Line2D.Float(),
            new BasicStroke(1.0f), Color.black);
    result.setLabelFont(lookupLegendTextFont(series));
    Paint labelPaint = lookupLegendTextPaint(series);
    if (labelPaint != null) {
        result.setLabelPaint(labelPaint);
    }
    result.setDataset(dataset);
    result.setDatasetIndex(datasetIndex);
    result.setSeriesKey(dataset.getRowKey(series));
    result.setSeriesIndex(series);
    if (this.gradientPaintTransformer != null) {
        result.setFillPaintTransformer(this.gradientPaintTransformer);
    }
    return result;
}