Java 类org.jfree.chart.labels.XYItemLabelGenerator 实例源码

项目:ccu-historian    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:aya-lang    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:mzmine2    文件:DiagonalLineRenderer.java   
public DiagonalLineRenderer() {

    super(true, true);

    setDefaultShapesFilled(true);
    setDrawOutlines(true);
    setUseFillPaint(true);

    for (int i = 0; i < plotDiagonalColors.length; i++) {
        setSeriesShape(i, diagonalPointsShape);
        setSeriesPaint(i, plotDiagonalColors[i]);
        setSeriesFillPaint(i, plotDiagonalColors[i]);
    }

    setDefaultShapesVisible(true);

    XYItemLabelGenerator diagonallabelGenerator = new DiagonalLineLabelGenerator();
    setDefaultItemLabelGenerator(diagonallabelGenerator);
    setDefaultItemLabelsVisible(true);

    setDrawSeriesLineAsPath(true);
    }
项目:mzmine2    文件:ScatterPlotRenderer.java   
public ScatterPlotRenderer() {

    super(false, true);

    ScatterPlotToolTipGenerator toolTipGenerator = new ScatterPlotToolTipGenerator();
    setDefaultToolTipGenerator(toolTipGenerator);

    XYItemLabelGenerator ItemlabelGenerator = new ScatterPlotItemLabelGenerator();
    setDefaultItemLabelGenerator(ItemlabelGenerator);
    setDefaultItemLabelFont(new Font("SansSerif", Font.BOLD, 11));
    setDefaultItemLabelPaint(Color.black);
    setDefaultItemLabelsVisible(false);

    setSeriesItemLabelsVisible(0, false);
    setSeriesPaint(0, pointColor);
    setSeriesShape(0, dataPointsShape);

    setSeriesItemLabelsVisible(1, false);
    setSeriesPaint(1, searchColor);
    setSeriesShape(1, dataPointsShape);

    setDrawSeriesLineAsPath(true);

    }
项目:populus    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:ECG-Viewer    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:opensim-gui    文件:AbstractXYItemRenderer.java   
/**
 * Returns the item label generator for a series.
 *
 * @param series  the series index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
public XYItemLabelGenerator getSeriesItemLabelGenerator(int series) {

    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;

}
项目:odroid-power-measure    文件:Chart.java   
public void createAdditionalDataset(String setTitle, boolean showDataLabels) {
    dataCollection.add(createDataset(setTitle));
    plot.setDataset(dataCollection.size() - 1, dataCollection.get(dataCollection.size() - 1));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    if(showDataLabels){
        XYItemLabelGenerator itemLabelGenerator = new CustomItemLabelGenerator();
        renderer.setBaseItemLabelGenerator(itemLabelGenerator);
        renderer.setSeriesItemLabelsVisible(0, true);
    }

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);
    plot.setRenderer(dataCollection.size() - 1, renderer);
}
项目:group-five    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:manydesigns.cn    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:parabuild-ci    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:ccu-historian    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both <code>null</code>.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGenerator = null;
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGenerator = null;
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:ccu-historian    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:jfreechart    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both {@code null}.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:jfreechart    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly {@code null}).
 */
@Override
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorMap.get(series);
    if (generator == null) {
        generator = this.defaultItemLabelGenerator;
    }
    return generator;
}
项目:jfreechart    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtils.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:aya-lang    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both <code>null</code>.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGenerator = null;
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGenerator = null;
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:aya-lang    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:mzmine2    文件:TICPlot.java   
public synchronized void addLabelledPeakDataset(final XYDataset dataSet,
    final String label) {

// Add standard peak data set.
addPeakDataset(dataSet);

// Do we have a label?
if (label != null && label.length() > 0) {

    // Add peak label renderer and data set.
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(
        false, false);
    renderer.setDefaultItemLabelsVisible(labelsVisible == 2);
    renderer.setDefaultItemLabelPaint(LABEL_COLOR);
    addDataSetRenderer(dataSet, renderer);
    renderer.setDrawSeriesLineAsPath(true);
    renderer.setDefaultItemLabelGenerator(new XYItemLabelGenerator() {

    @Override
    public String generateLabel(final XYDataset xyDataSet,
        final int series, final int item) {

        return ((PeakDataSet) xyDataSet).isPeak(item) ? label
            : null;
    }
    });

    havePeakLabels = true;
}
   }
项目:mzmine2    文件:ScatterPlotRenderer.java   
/**
    * Draws an item label.
    * 
    * @param g2
    *            the graphics device.
    * @param orientation
    *            the orientation.
    * @param dataset
    *            the dataset.
    * @param series
    *            the series index (zero-based).
    * @param item
    *            the item index (zero-based).
    * @param x
    *            the x coordinate (in Java2D space).
    * @param y
    *            the y coordinate (in Java2D space).
    * @param negative
    *            indicates a negative value (which affects the item label
    *            position).
    */
   protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
    XYDataset dataset, int series, int item, double x, double y,
    boolean negative) {

XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
Font labelFont = getItemLabelFont(series, item);
g2.setFont(labelFont);
String label = generator.generateLabel(dataset, series, item);

if ((label == null) || (label.length() == 0))
    return;

// get the label position..
ItemLabelPosition position = null;
if (!negative) {
    position = getPositiveItemLabelPosition(series, item);
} else {
    position = getNegativeItemLabelPosition(series, item);
}

// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
    position.getItemLabelAnchor(), x, y, orientation);

FontMetrics metrics = g2.getFontMetrics(labelFont);
int width = SwingUtilities.computeStringWidth(metrics, label) + 2;
int height = metrics.getHeight();

int X = (int) (anchorPoint.getX() - (width / 2));
int Y = (int) (anchorPoint.getY() - (height));

g2.setPaint(searchColor);
g2.fillRect(X, Y, width, height);

super.drawItemLabel(g2, orientation, dataset, series, item, x, y,
    negative);

   }
项目:HTML5_WebSite    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:HTML5_WebSite    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:populus    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both <code>null</code>.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGenerator = null;
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGenerator = null;
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:populus    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:PI    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:PI    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:openbd-core    文件:CustomClusteredXYBarRenderer.java   
private void drawItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, Rectangle2D bar, boolean negative) {

        XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
        if (generator == null)
            return;

        String label = generator.generateLabel(dataset, series, item);
        if (label == null) {
            return; // nothing to do
        }

        Font labelFont = getItemLabelFont(series, item);
        g2.setFont(labelFont);
        Paint paint = getItemLabelPaint(series, item);
        g2.setPaint(paint);

        // find out where to place the label...
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        } else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar, orientation);

        TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor());
    }
项目:nabs    文件:AbstractXYItemRenderer.java   
/**
 * Returns the label generator for a data item.  This implementation simply
 * passes control to the {@link #getSeriesItemLabelGenerator(int)} method.
 * If, for some reason, you want a different generator for individual
 * items, you can override this method.
 *
 * @param series  the series index (zero based).
 * @param item  the item index (zero based).
 *
 * @return The generator (possibly <code>null</code>).
 */
public XYItemLabelGenerator getItemLabelGenerator(int series, int item) {
    // return the generator for ALL series, if there is one...
    if (this.itemLabelGenerator != null) {
        return this.itemLabelGenerator;
    }

    // otherwise look up the generator table
    XYItemLabelGenerator generator
        = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
    if (generator == null) {
        generator = this.baseItemLabelGenerator;
    }
    return generator;
}
项目:nabs    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:ECG-Viewer    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both <code>null</code>.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGenerator = null;
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGenerator = null;
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:ECG-Viewer    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:astor    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param selected  is the item selected?
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 *
 * @since 1.2.0
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, boolean selected,
        double x, double y, boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item,
            selected);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item, selected);
        Paint paint = getItemLabelPaint(series, item, selected);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item,
                    selected);
        }
        else {
            position = getNegativeItemLabelPosition(series, item,
                    selected);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:opensim-gui    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item 
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y, 
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position = null;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2, 
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), 
                position.getRotationAnchor());
    }

}
项目:group-five    文件:AbstractXYItemRenderer.java   
/**
 * Creates a renderer where the tooltip generator and the URL generator are
 * both <code>null</code>.
 */
protected AbstractXYItemRenderer() {
    super();
    this.itemLabelGenerator = null;
    this.itemLabelGeneratorMap 
            = new HashMap<Integer, XYItemLabelGenerator>();
    this.toolTipGenerator = null;
    this.toolTipGeneratorMap = new HashMap<Integer, XYToolTipGenerator>();
    this.urlGenerator = null;
    this.backgroundAnnotations = new java.util.ArrayList();
    this.foregroundAnnotations = new java.util.ArrayList();
    this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator(
            "{0}");
}
项目:group-five    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:manydesigns.cn    文件:AbstractXYItemRenderer.java   
/**
 * Draws an item label.
 *
 * @param g2  the graphics device.
 * @param orientation  the orientation.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param x  the x coordinate (in Java2D space).
 * @param y  the y coordinate (in Java2D space).
 * @param negative  indicates a negative value (which affects the item
 *                  label position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation,
        XYDataset dataset, int series, int item, double x, double y,
        boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    if (generator != null) {
        Font labelFont = getItemLabelFont(series, item);
        Paint paint = getItemLabelPaint(series, item);
        g2.setFont(labelFont);
        g2.setPaint(paint);
        String label = generator.generateLabel(dataset, series, item);

        // get the label position..
        ItemLabelPosition position;
        if (!negative) {
            position = getPositiveItemLabelPosition(series, item);
        }
        else {
            position = getNegativeItemLabelPosition(series, item);
        }

        // work out the label anchor point...
        Point2D anchorPoint = calculateLabelAnchorPoint(
                position.getItemLabelAnchor(), x, y, orientation);
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }

}
项目:parabuild-ci    文件:XYBarRenderer.java   
/**
 * Draws an item label.  This method is overridden so that the bar can be 
 * used to calculate the label anchor point.
 * 
 * @param g2  the graphics device.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param plot  the plot.
 * @param generator  the label generator.
 * @param bar  the bar.
 * @param negative  a flag indicating a negative value.
 */
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
        int series, int item, XYPlot plot, XYItemLabelGenerator generator, 
        Rectangle2D bar, boolean negative) {

    String label = generator.generateLabel(dataset, series, item);
    if (label == null) {
        return;  // nothing to do   
    }

    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(series, item);
    g2.setPaint(paint);

    // find out where to place the label...
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    }
    else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(
            position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label, 
                g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                }
                else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(
                            position.getItemLabelAnchor(), bar, 
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2, 
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(), 
                position.getRotationAnchor());
    }        
}
项目:ccu-historian    文件:XYBarRenderer.java   
/**
 * Draws an item label.  This method is provided as an alternative to
 * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
 * double, double, boolean)} so that the bar can be used to calculate the
 * label anchor point.
 *
 * @param g2  the graphics device.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param plot  the plot.
 * @param generator  the label generator (<code>null</code> permitted, in
 *         which case the method does nothing, just returns).
 * @param bar  the bar.
 * @param negative  a flag indicating a negative value.
 */
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
        int series, int item, XYPlot plot, XYItemLabelGenerator generator,
        Rectangle2D bar, boolean negative) {

    if (generator == null) {
        return;  // nothing to do
    }
    String label = generator.generateLabel(dataset, series, item);
    if (label == null) {
        return;  // nothing to do
    }

    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(series, item);
    g2.setPaint(paint);

    // find out where to place the label...
    ItemLabelPosition position;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    }
    else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(
            position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtilities.calculateRotatedStringBounds(label,
                g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                }
                else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(
                            position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtilities.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }
}
项目:jfreechart    文件:XYBarRenderer.java   
/**
 * Draws an item label.  This method is provided as an alternative to
 * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int,
 * double, double, boolean)} so that the bar can be used to calculate the
 * label anchor point.
 *
 * @param g2  the graphics device.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param plot  the plot.
 * @param generator  the label generator ({@code null} permitted, in
 *         which case the method does nothing, just returns).
 * @param bar  the bar.
 * @param negative  a flag indicating a negative value.
 */
protected void drawItemLabel(Graphics2D g2, XYDataset dataset,
        int series, int item, XYPlot plot, XYItemLabelGenerator generator,
        Rectangle2D bar, boolean negative) {

    if (generator == null) {
        return;  // nothing to do
    }
    String label = generator.generateLabel(dataset, series, item);
    if (label == null) {
        return;  // nothing to do
    }

    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    Paint paint = getItemLabelPaint(series, item);
    g2.setPaint(paint);

    // find out where to place the label...
    ItemLabelPosition position;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    } else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(
            position.getItemLabelAnchor(), bar, plot.getOrientation());

    if (isInternalAnchor(position.getItemLabelAnchor())) {
        Shape bounds = TextUtils.calculateRotatedStringBounds(label,
                g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());

        if (bounds != null) {
            if (!bar.contains(bounds.getBounds2D())) {
                if (!negative) {
                    position = getPositiveItemLabelPositionFallback();
                }
                else {
                    position = getNegativeItemLabelPositionFallback();
                }
                if (position != null) {
                    anchorPoint = calculateLabelAnchorPoint(
                            position.getItemLabelAnchor(), bar,
                            plot.getOrientation());
                }
            }
        }

    }

    if (position != null) {
        TextUtils.drawRotatedString(label, g2,
                (float) anchorPoint.getX(), (float) anchorPoint.getY(),
                position.getTextAnchor(), position.getAngle(),
                position.getRotationAnchor());
    }
}