Java 类org.jfree.chart.plot.Marker 实例源码

项目:ta4j    文件:BuyAndSellSignalsToChart.java   
/**
 * Runs a strategy over a time series and adds the value markers
 * corresponding to buy/sell signals to the plot.
 * @param series a time series
 * @param strategy a trading strategy
 * @param plot the plot
 */
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
    // Running the strategy
    TimeSeriesManager seriesManager = new TimeSeriesManager(series);
    List<Trade> trades = seriesManager.run(strategy).getTrades();
    // Adding markers to plot
    for (Trade trade : trades) {
        // Buy signal
        double buySignalTickTime = new Minute(Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
        Marker buyMarker = new ValueMarker(buySignalTickTime);
        buyMarker.setPaint(Color.GREEN);
        buyMarker.setLabel("B");
        plot.addDomainMarker(buyMarker);
        // Sell signal
        double sellSignalTickTime = new Minute(Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
        Marker sellMarker = new ValueMarker(sellSignalTickTime);
        sellMarker.setPaint(Color.RED);
        sellMarker.setLabel("S");
        plot.addDomainMarker(sellMarker);
    }
}
项目:crypto-bot    文件:Chart.java   
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
    // Running the strategy
    TimeSeriesManager seriesManager = new TimeSeriesManager(series);
    List<Trade> trades = seriesManager.run(strategy).getTrades();
    // Adding markers to plot
    for (Trade trade : trades) {
        // Buy signal
        double buySignalTickTime = new Minute(
                Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant()))
                        .getFirstMillisecond();
        Marker buyMarker = new ValueMarker(buySignalTickTime);
        buyMarker.setPaint(Color.GREEN);
        buyMarker.setLabel("B");
        plot.addDomainMarker(buyMarker);
        // Sell signal
        double sellSignalTickTime = new Minute(
                Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant()))
                        .getFirstMillisecond();
        Marker sellMarker = new ValueMarker(sellSignalTickTime);
        sellMarker.setPaint(Color.RED);
        sellMarker.setLabel("S");
        plot.addDomainMarker(sellMarker);
    }
}
项目:jasperreports    文件:RangeIntervalMarkerCustomizer.java   
@Override
protected void addMarker(Plot plot, Marker marker)
{
    if (plot instanceof XYPlot)
    {
        ((XYPlot)plot).addRangeMarker(
            marker, 
            getLayer()
            );
    }
    else if (plot instanceof CategoryPlot)
    {
        ((CategoryPlot)plot).addRangeMarker(
            marker, 
            getLayer()
            );
    }
}
项目:OpenCyclos    文件:SimulateConversionAction.java   
/**
 * replaces the marker keys with their message labels from the resource bundle. Also sets the subTitle of the graph.
 */
private void attachLabels(final StatisticalResultDTO rawDataObject, final ConversionSimulationDTO dto, final ActionContext context) {
    final Marker[] markers = rawDataObject.getDomainMarkers();
    if (markers != null) {
        for (final Marker marker : markers) {
            final String key = marker.getLabel();
            if (key != null) {
                final String title = context.message(key);
                marker.setLabel(title);
            }
        }
    }
    final LocalSettings localSettings = settingsService.getLocalSettings();
    TransferType transferType = dto.getTransferType();
    transferType = transferTypeService.load(transferType.getId(), TransferType.Relationships.TRANSACTION_FEES, RelationshipHelper.nested(TransferType.Relationships.FROM, AccountType.Relationships.CURRENCY));
    final String unitsPattern = transferType.getFrom().getCurrency().getPattern();
    final NumberConverter<BigDecimal> numberConverter = localSettings.getUnitsConverter(unitsPattern);
    final String numberString = numberConverter.toString(dto.getAmount());
    final String subTitle = context.message("conversionSimulation.result.graph.subtitle", numberString);
    rawDataObject.setSubTitle(subTitle);
}
项目:OpenCyclos    文件:ChartPostProcessorImpl.java   
@SuppressWarnings("rawtypes")
private void setMarkers(final CategoryPlot plot, final Map params) {
    final Marker[] domainMarkers = (Marker[]) params.get("domainMarkers");
    // this method may be extended for range markers in future.
    if (domainMarkers != null && domainMarkers.length > 0) {
        for (final Marker marker : domainMarkers) {
            final CategoryMarker cmarker = (CategoryMarker) marker;
            cmarker.setDrawAsLine(true);
            if (cmarker.getLabel() != null) {
                cmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                cmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
            }
            plot.addDomainMarker(cmarker);
        }
    }
}
项目:ta4j-origins    文件:BuyAndSellSignalsToChart.java   
/**
 * Runs a strategy over a time series and adds the value markers
 * corresponding to buy/sell signals to the plot.
 * @param series a time series
 * @param strategy a trading strategy
 * @param plot the plot
 */
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
    // Running the strategy
    TimeSeriesManager seriesManager = new TimeSeriesManager(series);
    List<Trade> trades = seriesManager.run(strategy).getTrades();
    // Adding markers to plot
    for (Trade trade : trades) {
        // Buy signal
        double buySignalTickTime = new Minute(Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
        Marker buyMarker = new ValueMarker(buySignalTickTime);
        buyMarker.setPaint(Color.GREEN);
        buyMarker.setLabel("B");
        plot.addDomainMarker(buyMarker);
        // Sell signal
        double sellSignalTickTime = new Minute(Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
        Marker sellMarker = new ValueMarker(sellSignalTickTime);
        sellMarker.setPaint(Color.RED);
        sellMarker.setLabel("S");
        plot.addDomainMarker(sellMarker);
    }
}
项目:open-cyclos    文件:SimulateConversionAction.java   
/**
 * replaces the marker keys with their message labels from the resource bundle. Also sets the subTitle of the graph.
 */
private void attachLabels(final StatisticalResultDTO rawDataObject, final ConversionSimulationDTO dto, final ActionContext context) {
    final Marker[] markers = rawDataObject.getDomainMarkers();
    if (markers != null) {
        for (final Marker marker : markers) {
            final String key = marker.getLabel();
            if (key != null) {
                final String title = context.message(key);
                marker.setLabel(title);
            }
        }
    }
    final LocalSettings localSettings = settingsService.getLocalSettings();
    TransferType transferType = dto.getTransferType();
    transferType = transferTypeService.load(transferType.getId(), TransferType.Relationships.TRANSACTION_FEES, RelationshipHelper.nested(TransferType.Relationships.FROM, AccountType.Relationships.CURRENCY));
    final String unitsPattern = transferType.getFrom().getCurrency().getPattern();
    final NumberConverter<BigDecimal> numberConverter = localSettings.getUnitsConverter(unitsPattern);
    final String numberString = numberConverter.toString(dto.getAmount());
    final String subTitle = context.message("conversionSimulation.result.graph.subtitle", numberString);
    rawDataObject.setSubTitle(subTitle);
}
项目:open-cyclos    文件:ChartPostProcessorImpl.java   
@SuppressWarnings("rawtypes")
private void setMarkers(final CategoryPlot plot, final Map params) {
    final Marker[] domainMarkers = (Marker[]) params.get("domainMarkers");
    // this method may be extended for range markers in future.
    if (domainMarkers != null && domainMarkers.length > 0) {
        for (final Marker marker : domainMarkers) {
            final CategoryMarker cmarker = (CategoryMarker) marker;
            cmarker.setDrawAsLine(true);
            if (cmarker.getLabel() != null) {
                cmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                cmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
            }
            plot.addDomainMarker(cmarker);
        }
    }
}
项目:nmonvisualizer    文件:LineChartPanel.java   
@Override
public void addMarkers(List<Marker> markers) {
    if (getChart() != null) {
        XYPlot plot = getChart().getXYPlot();

        plot.clearDomainMarkers();
        plot.clearRangeMarkers();

        for (Marker marker : markers) {
            if (marker instanceof RangeValueMarker) {
                plot.addRangeMarker(marker);
            }
            else if (marker instanceof DomainValueMarker) {
                plot.addDomainMarker(marker);
            }

            firePropertyChange("annotation", null, marker);
        }
    }
}
项目:ezScrum    文件:ChartUtil.java   
@SuppressWarnings("unused")
private void setMarker(XYPlot plot) {
    Iterator<Date> ir = m_dateMarkerMap.keySet().iterator();
    int index = 1;
    while (ir.hasNext()) {

        Date key = ir.next();

        final Marker marker = new IntervalMarker(key.getTime(),
                m_dateMarkerMap.get(key).getTime());

        if (this.m_visualMarkerLabel)
            marker.setLabel("#" + index);
        // marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        // marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);

        marker.setAlpha(0.3f);
        //marker.setPaint(this.m_markerColor);

        plot.addDomainMarker(marker);
        index++;
    }
}
项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * Some tests for the addDomainMarker() method(s).
 */
public void testAddDomainMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addDomainMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearDomainMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:parabuild-ci    文件:CategoryPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    CategoryPlot plot = new CategoryPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:PhET    文件:QTRegionMarkerManager.java   
private void addRegionMarker( double x ) {

        Marker marker = new ValueMarker( x );
        marker.setPaint( _markerColor );
        marker.setStroke( QTConstants.REGION_MARKER_STROKE );

        Iterator i = _plots.iterator();
        while ( i.hasNext() ) {
            XYPlot plot = (XYPlot) i.next();
            plot.addDomainMarker( marker );
        }
    }
项目:jasperreports    文件:DomainIntervalMarkerCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (jfc.getPlot() instanceof XYPlot)
    {
        Marker marker = createMarker();
        if (marker != null)
        {
            addMarker(jfc.getPlot(), marker);
        }
    }
}
项目:jasperreports    文件:DomainIntervalMarkerCustomizer.java   
@Override
protected void addMarker(Plot plot, Marker marker)
{
    ((XYPlot)plot).addDomainMarker(
        marker, 
        getLayer()
        );
}
项目:jasperreports    文件:AbstractMarkerCustomizer.java   
protected void configureStroke(Marker marker)
{
    Float strokeWidth = getFloatProperty(PROPERTY_STROKE_WIDTH);
    if (strokeWidth == null)
    {
        strokeWidth = 1f;
    }

    BasicStroke basicStroke = getStroke(strokeWidth);

    marker.setStroke(basicStroke);
}
项目:jasperreports    文件:RangeValueMarkerCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (jfc.getPlot() instanceof XYPlot)
    {
        Marker marker = createMarker();
        if (marker != null)
        {
            addMarker(jfc.getXYPlot(), marker);
        }
    }
}
项目:jasperreports    文件:RangeValueMarkerCustomizer.java   
@Override
protected void addMarker(Plot plot, Marker marker) 
{
    ((XYPlot)plot).addRangeMarker(
        marker, 
        getLayer()
        );
}
项目:jasperreports    文件:RangeIntervalMarkerCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (
        jfc.getPlot() instanceof XYPlot
        || jfc.getPlot() instanceof CategoryPlot
        )
    {
        Marker marker = createMarker();
        if (marker != null)
        {
            addMarker(jfc.getPlot(), marker);
        }
    }
}
项目:jasperreports    文件:CategoryMarkerCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (jfc.getPlot() instanceof CategoryPlot)
    {
        Marker marker = createMarker(jrc);
        if (marker != null)
        {
            addMarker(jfc.getPlot(), marker);
        }
    }
}
项目:jasperreports    文件:CategoryMarkerCustomizer.java   
@Override
protected void addMarker(Plot plot, Marker marker) 
{
    ((CategoryPlot)plot).addDomainMarker(
        (CategoryMarker)marker, 
        getLayer()
        );
}
项目:jasperreports    文件:DomainValueMarkerCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (jfc.getPlot() instanceof XYPlot)
    {
        Marker marker = createMarker();
        if (marker != null)
        {
            addMarker(jfc.getPlot(), marker);
        }
    }
}
项目:jasperreports    文件:DomainValueMarkerCustomizer.java   
@Override
protected void addMarker(Plot plot, Marker marker) 
{
    ((XYPlot)plot).addDomainMarker(
        marker, 
        getLayer()
        );
}
项目:MLDA    文件:ChartUtils.java   
/**
 * Update values of a bar chart
 * 
 * @param labelsByFreq Labels ordered by frequency
 * @param nInstances Number of instances
 * @param cp CategoryPlot
 */
public static void updateValuesBarChart(ImbalancedFeature[] labelsByFreq, 
        int nInstances, CategoryPlot cp)
{
    DefaultCategoryDataset data = new DefaultCategoryDataset();

    double prob;

    labelsByFreq = MetricUtils.sortByFrequency(labelsByFreq);

    double sum = 0.0;
    for(int i=0; i<labelsByFreq.length;i++)
    {
        prob = labelsByFreq[i].getAppearances()*1.0/nInstances;
        sum += prob;

        data.setValue(prob, labelsByFreq[i].getName()," ");
    }

    cp.setDataset(data);

    // add mean mark
    sum = sum/labelsByFreq.length;
    Marker start = new ValueMarker(sum);
    start.setPaint(Color.red);
    start.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    start.setLabel("                        Mean: "+MetricUtils.truncateValue(sum, 3));
    cp.addRangeMarker(start);
}
项目:MLDA    文件:ChartUtils.java   
/**
 * Update IR bar chart
 * 
 * @param labelsByFrequency Labels ordered by frequency
 * @param IR Imbalance Ratio values
 * @param cp CategoryPlot
 */
public static void updateIRBarChart(ImbalancedFeature[] labelsByFrequency, 
        double[] IR, CategoryPlot cp)
{
    DefaultCategoryDataset myData = new DefaultCategoryDataset();

    double prob = 0;

    labelsByFrequency = MetricUtils.sortByFrequency(labelsByFrequency);

    double sum = 0.0;
    for(int i=labelsByFrequency.length-1; i>=0; i--)
    {
        prob= IR[i];
        sum += prob;
        myData.setValue(prob, labelsByFrequency[i].getName()," ");
    }

    cp.setDataset(myData);

    // add mean mark
    sum = sum/labelsByFrequency.length;
    Marker meanMark = new ValueMarker(sum);
    meanMark.setPaint(Color.red);
    meanMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    meanMark.setLabel("                        Mean: "+MetricUtils.truncateValue(sum, 3));
    cp.addRangeMarker(meanMark);

    //Add Imbalance limit mark
    Marker limitMark = new ValueMarker(1.5);
    limitMark.setPaint(Color.black);
    limitMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));

    if((sum < 1.3) || (sum > 1.7)){
        limitMark.setLabel("                                                Imbalance limit (IR=1.5)");
    }            
    cp.addRangeMarker(limitMark);
}
项目:AgileAlligators    文件:DefaultChartService.java   
/**
 * Returns a horizontal line marker for the given x value and label.
 */
private Marker getMarker( Double value, String label )
{
    Marker marker = new ValueMarker( value );
    marker.setPaint( Color.BLACK );
    marker.setStroke( new BasicStroke( 1.1f ) );
    marker.setLabel( label );
    marker.setLabelOffset( new RectangleInsets( -10, 50, 0, 0 ) );
    marker.setLabelFont( SUB_TITLE_FONT );

    return marker;
}
项目:oStorybook    文件:ChartUtil.java   
public static Marker getAverageMarker(double paramDouble) {
    ValueMarker localValueMarker = new ValueMarker(paramDouble, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(I18N.getMsg("msg.common.average"));
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    return localValueMarker;
}
项目:oStorybook    文件:ChartUtil.java   
public static Marker getDateMarker(Date paramDate, String paramString, boolean paramBoolean) {
    double d = paramDate.getTime();
    ValueMarker localValueMarker = new ValueMarker(d, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(paramString);
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
    if (paramBoolean) {
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    } else {
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    }
    return localValueMarker;
}
项目:oStorybook    文件:ChartUtil.java   
public static Marker getDateIntervalMarker(Date paramDate1, Date paramDate2, String paramString) {
    double d1 = paramDate1.getTime();
    double d2 = paramDate2.getTime();
    BasicStroke localBasicStroke = new BasicStroke(0.3F);
    IntervalMarker localIntervalMarker = new IntervalMarker(d1, d2, Color.pink, localBasicStroke, Color.black, localBasicStroke, 0.5F);
    localIntervalMarker.setLabel(paramString);
    localIntervalMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
    localIntervalMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
    return localIntervalMarker;
}
项目:SE-410-Project    文件:ChartUtil.java   
public static Marker getAverageMarker(double paramDouble) {
    ValueMarker localValueMarker = new ValueMarker(paramDouble, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(I18N.getMsg("msg.common.average"));
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    return localValueMarker;
}
项目:SE-410-Project    文件:ChartUtil.java   
public static Marker getDateMarker(Date paramDate, String paramString, boolean paramBoolean) {
    double d = paramDate.getTime();
    ValueMarker localValueMarker = new ValueMarker(d, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(paramString);
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
    if (paramBoolean) {
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    } else {
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    }
    return localValueMarker;
}
项目:SE-410-Project    文件:ChartUtil.java   
public static Marker getDateIntervalMarker(Date paramDate1, Date paramDate2, String paramString) {
    double d1 = paramDate1.getTime();
    double d2 = paramDate2.getTime();
    BasicStroke localBasicStroke = new BasicStroke(0.3F);
    IntervalMarker localIntervalMarker = new IntervalMarker(d1, d2, Color.pink, localBasicStroke, Color.black, localBasicStroke, 0.5F);
    localIntervalMarker.setLabel(paramString);
    localIntervalMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
    localIntervalMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
    return localIntervalMarker;
}
项目:nabs    文件:XYPlotTests.java   
/**
 * Some tests for the addDomainMarker() method(s).
 */
public void testAddDomainMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addDomainMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearDomainMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:nabs    文件:XYPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:nabs    文件:CategoryPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    CategoryPlot plot = new CategoryPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:astor    文件:XYPlotTests.java   
/**
 * Some tests for the addDomainMarker() method(s).
 */
public void testAddDomainMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addDomainMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearDomainMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:astor    文件:XYPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    XYPlot plot = new XYPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:astor    文件:CategoryPlotTests.java   
/**
 * Some tests for the addRangeMarker() method(s).
 */
public void testAddRangeMarker() {
    CategoryPlot plot = new CategoryPlot();
    Marker m = new ValueMarker(1.0);
    plot.addRangeMarker(m);
    List listeners = Arrays.asList(m.getListeners(
            MarkerChangeListener.class));
    assertTrue(listeners.contains(plot));
    plot.clearRangeMarkers();
    listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
    assertFalse(listeners.contains(plot));
}
项目:astor    文件:ChartFactory.java   
/**
 * Creates a waterfall chart.  The chart object returned by this method
 * uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link WaterfallBarRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A waterfall chart.
 */
public static JFreeChart createWaterfallChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    ItemLabelPosition position = new ItemLabelPosition(
            ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 0.0);
    renderer.setBasePositiveItemLabelPosition(position);
    renderer.setBaseNegativeItemLabelPosition(position);
    StandardCategoryToolTipGenerator generator
            = new StandardCategoryToolTipGenerator();
    renderer.setBaseToolTipGenerator(generator);
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.clearRangeMarkers();
    Marker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.black);
    plot.addRangeMarker(baseline, Layer.FOREGROUND);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}