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

项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelOffset() and setLabelOffset() methods.
 */
public void testGetSetLabelOffset() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset());
    m.setLabelOffset(new RectangleInsets(1, 2, 3, 4));
    assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelOffset(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目: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);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getPaint() and setPaint() methods.
 */
public void testGetSetPaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getPaint());
    m.setPaint(Color.blue);
    assertEquals(Color.blue, m.getPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getStroke() and setStroke() methods.
 */
public void testGetSetStroke() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getStroke());
    m.setStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setStroke(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getOutlinePaint() and setOutlinePaint() methods.
 */
public void testGetSetOutlinePaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getOutlinePaint());
    m.setOutlinePaint(Color.yellow);
    assertEquals(Color.yellow, m.getOutlinePaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlinePaint(null);
    assertEquals(null, m.getOutlinePaint());
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getOutlineStroke() and setOutlineStroke() methods.
 */
public void testGetSetOutlineStroke() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getOutlineStroke());
    m.setOutlineStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getOutlineStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlineStroke(null);
    assertEquals(null, m.getOutlineStroke());
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabel() and setLabel() methods.
 */
public void testGetSetLabel() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(null, m.getLabel());
    m.setLabel("XYZ");
    assertEquals("XYZ", m.getLabel());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setLabel(null);
    assertEquals(null, m.getLabel());
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelFont() and setLabelFont() methods.
 */
public void testGetSetLabelFont() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new Font("SansSerif", Font.PLAIN, 9), m.getLabelFont());
    m.setLabelFont(new Font("SansSerif", Font.BOLD, 10));
    assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelFont(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelPaint() and setLabelPaint() methods.
 */
public void testGetSetLabelPaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.black, m.getLabelPaint());
    m.setLabelPaint(Color.red);
    assertEquals(Color.red, m.getLabelPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelAnchor() and setLabelAnchor() methods.
 */
public void testGetSetLabelAnchor() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    m.setLabelAnchor(RectangleAnchor.TOP);
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelOffsetType() and setLabelOffsetType() 
 * methods.
 */
public void testGetSetLabelOffsetType() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType());
    m.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelOffsetType(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Some checks for the getLabelTextAnchor() and setLabelTextAnchor() 
 * methods.
 */
public void testGetSetLabelTextAnchor() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(TextAnchor.CENTER, m.getLabelTextAnchor());
    m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT);
    assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelTextAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Checks that a CategoryPlot deregisters listeners when clearing markers.
 */
public void testListenersWithCategoryPlot() {
    CategoryPlot plot = new CategoryPlot();
    CategoryMarker marker1 = new CategoryMarker("X");
    ValueMarker marker2 = new ValueMarker(1.0);
    plot.addDomainMarker(marker1);
    plot.addRangeMarker(marker2);
    EventListener[] listeners1 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners1).contains(plot));
    EventListener[] listeners2 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners2).contains(plot));
    plot.clearDomainMarkers();
    plot.clearRangeMarkers();
    listeners1 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners1).contains(plot));
    listeners2 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners2).contains(plot));
}
项目:parabuild-ci    文件:MarkerTests.java   
/**
 * Checks that an XYPlot deregisters listeners when clearing markers.
 */
public void testListenersWithXYPlot() {
    XYPlot plot = new XYPlot();
    ValueMarker marker1 = new ValueMarker(1.0);
    ValueMarker marker2 = new ValueMarker(2.0);
    plot.addDomainMarker(marker1);
    plot.addRangeMarker(marker2);
    EventListener[] listeners1 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners1).contains(plot));
    EventListener[] listeners2 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners2).contains(plot));
    plot.clearDomainMarkers();
    plot.clearRangeMarkers();
    listeners1 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners1).contains(plot));
    listeners2 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners2).contains(plot));
}
项目:jasperreports    文件:AbstractValueMarkerCustomizer.java   
protected ValueMarker createMarker() 
{
    Double value = getDoubleProperty(PROPERTY_VALUE);

    if (value == null)
    {
        return null;
    }

    ValueMarker marker = new ValueMarker(value);

    configureMarker(marker);

    configureStroke(marker);

    return marker;
}
项目:scalalab    文件:jPlot.java   
/**
 * Adds marker line to the chart.
 *
 * @param axis     axis on which to add the marker.
 * @param position marker position
 * @param paint    marker paint, for example <code>Color.yellow</code>
 * @param width    marker width
 * @param style    marker style, for example:
 *                 <cocde>new float[]{2, 5, 8, 5}</code> specifies dot dash line.
 */
public void addMarker(AxisEnum axis, double position, Paint paint, int width, float[] style) {

    float dashPhase = 0;
    Stroke stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2, style, dashPhase);

    ValueMarker marker = new ValueMarker(position, paint, stroke);

    switch (axis) {
        case X:
            m_xMarker = marker;
            if (m_chart != null) {
                m_chart.getXYPlot().addDomainMarker(m_xMarker);
            }
            break;
        case Y:
            m_yMarker = marker;
            if (m_chart != null) {
                m_chart.getXYPlot().addRangeMarker(m_yMarker);
            }
            break;
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getPaint() and setPaint() methods.
 */
public void testGetSetPaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getPaint());
    m.setPaint(Color.blue);
    assertEquals(Color.blue, m.getPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getStroke() and setStroke() methods.
 */
public void testGetSetStroke() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getStroke());
    m.setStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setStroke(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getOutlinePaint() and setOutlinePaint() methods.
 */
public void testGetSetOutlinePaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getOutlinePaint());
    m.setOutlinePaint(Color.yellow);
    assertEquals(Color.yellow, m.getOutlinePaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlinePaint(null);
    assertEquals(null, m.getOutlinePaint());
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getOutlineStroke() and setOutlineStroke() methods.
 */
public void testGetSetOutlineStroke() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getOutlineStroke());
    m.setOutlineStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getOutlineStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlineStroke(null);
    assertEquals(null, m.getOutlineStroke());
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabel() and setLabel() methods.
 */
public void testGetSetLabel() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(null, m.getLabel());
    m.setLabel("XYZ");
    assertEquals("XYZ", m.getLabel());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setLabel(null);
    assertEquals(null, m.getLabel());
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelFont() and setLabelFont() methods.
 */
public void testGetSetLabelFont() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new Font("SansSerif", Font.PLAIN, 9), m.getLabelFont());
    m.setLabelFont(new Font("SansSerif", Font.BOLD, 10));
    assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelFont(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelPaint() and setLabelPaint() methods.
 */
public void testGetSetLabelPaint() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.black, m.getLabelPaint());
    m.setLabelPaint(Color.red);
    assertEquals(Color.red, m.getLabelPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelAnchor() and setLabelAnchor() methods.
 */
public void testGetSetLabelAnchor() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    m.setLabelAnchor(RectangleAnchor.TOP);
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelOffset() and setLabelOffset() methods.
 */
public void testGetSetLabelOffset() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset());
    m.setLabelOffset(new RectangleInsets(1, 2, 3, 4));
    assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelOffset(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelOffsetType() and setLabelOffsetType() 
 * methods.
 */
public void testGetSetLabelOffsetType() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType());
    m.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelOffsetType(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Some checks for the getLabelTextAnchor() and setLabelTextAnchor() 
 * methods.
 */
public void testGetSetLabelTextAnchor() {
    // we use ValueMarker for the tests, because we need a concrete 
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(TextAnchor.CENTER, m.getLabelTextAnchor());
    m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT);
    assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelTextAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:nabs    文件:MarkerTests.java   
/**
 * Checks that a CategoryPlot deregisters listeners when clearing markers.
 */
public void testListenersWithCategoryPlot() {
    CategoryPlot plot = new CategoryPlot();
    CategoryMarker marker1 = new CategoryMarker("X");
    ValueMarker marker2 = new ValueMarker(1.0);
    plot.addDomainMarker(marker1);
    plot.addRangeMarker(marker2);
    EventListener[] listeners1 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners1).contains(plot));
    EventListener[] listeners2 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners2).contains(plot));
    plot.clearDomainMarkers();
    plot.clearRangeMarkers();
    listeners1 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners1).contains(plot));
    listeners2 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners2).contains(plot));
}
项目:nabs    文件:MarkerTests.java   
/**
 * Checks that an XYPlot deregisters listeners when clearing markers.
 */
public void testListenersWithXYPlot() {
    XYPlot plot = new XYPlot();
    ValueMarker marker1 = new ValueMarker(1.0);
    ValueMarker marker2 = new ValueMarker(2.0);
    plot.addDomainMarker(marker1);
    plot.addRangeMarker(marker2);
    EventListener[] listeners1 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners1).contains(plot));
    EventListener[] listeners2 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners2).contains(plot));
    plot.clearDomainMarkers();
    plot.clearRangeMarkers();
    listeners1 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners1).contains(plot));
    listeners2 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners2).contains(plot));
}
项目:grammarviz2_src    文件:GrammarvizChartPanel.java   
/**
 * @param plot plot for the marker
 * @param startVal start postion
 * @param endVal end position
 */
protected void addMarker(XYPlot plot, int startVal, int endVal) {
  IntervalMarker marker = new IntervalMarker(startVal, endVal);
  marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
  marker.setPaint(new Color(134, 254, 225));
  marker.setAlpha((float) 0.60);
  marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
  marker.setLabelPaint(Color.green);
  marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
  marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);

  plot.addDomainMarker(marker, Layer.BACKGROUND);

  ValueMarker markStart = new ValueMarker(startVal, new Color(31, 254, 225),
      new BasicStroke(2.0f));
  ValueMarker markEnd = new ValueMarker(endVal, new Color(31, 254, 225), new BasicStroke(2.0f));
  plot.addDomainMarker(markStart, Layer.BACKGROUND);
  plot.addDomainMarker(markEnd, Layer.BACKGROUND);
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getPaint() and setPaint() methods.
 */
public void testGetSetPaint() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getPaint());
    m.setPaint(Color.blue);
    assertEquals(Color.blue, m.getPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getStroke() and setStroke() methods.
 */
public void testGetSetStroke() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getStroke());
    m.setStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setStroke(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getOutlinePaint() and setOutlinePaint() methods.
 */
public void testGetSetOutlinePaint() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.gray, m.getOutlinePaint());
    m.setOutlinePaint(Color.yellow);
    assertEquals(Color.yellow, m.getOutlinePaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlinePaint(null);
    assertEquals(null, m.getOutlinePaint());
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getOutlineStroke() and setOutlineStroke() methods.
 */
public void testGetSetOutlineStroke() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new BasicStroke(0.5f), m.getOutlineStroke());
    m.setOutlineStroke(new BasicStroke(1.1f));
    assertEquals(new BasicStroke(1.1f), m.getOutlineStroke());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setOutlineStroke(null);
    assertEquals(null, m.getOutlineStroke());
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getLabel() and setLabel() methods.
 */
public void testGetSetLabel() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(null, m.getLabel());
    m.setLabel("XYZ");
    assertEquals("XYZ", m.getLabel());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    m.setLabel(null);
    assertEquals(null, m.getLabel());
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getLabelFont() and setLabelFont() methods.
 */
public void testGetSetLabelFont() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new Font("Tahoma", Font.PLAIN, 9), m.getLabelFont());
    m.setLabelFont(new Font("SansSerif", Font.BOLD, 10));
    assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelFont(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getLabelPaint() and setLabelPaint() methods.
 */
public void testGetSetLabelPaint() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(Color.black, m.getLabelPaint());
    m.setLabelPaint(Color.red);
    assertEquals(Color.red, m.getLabelPaint());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelPaint(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getLabelAnchor() and setLabelAnchor() methods.
 */
public void testGetSetLabelAnchor() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    m.setLabelAnchor(RectangleAnchor.TOP);
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:astor    文件:MarkerTests.java   
/**
 * Some checks for the getLabelOffset() and setLabelOffset() methods.
 */
public void testGetSetLabelOffset() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset());
    m.setLabelOffset(new RectangleInsets(1, 2, 3, 4));
    assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelOffset(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}