Java Code Examples for org.jfree.chart.plot.ValueMarker#setLabelOffset()

The following examples show how to use org.jfree.chart.plot.ValueMarker#setLabelOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarkerTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: MarkerTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: KovatsIndexExtractionDialog.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * replace markers
 */
private void kovatsValuesChanged() {
  // parse values
  if (parseValues() && chart != null) {
    //
    chart.getChart().getXYPlot().clearDomainMarkers();
    if (markers == null)
      markers = new ArrayList<>();
    else
      markers.clear();

    for (Entry<KovatsIndex, Double> e : parsedValues.entrySet()) {
      ValueMarker marker = new ValueMarker(e.getValue(),
          MZmineCore.getConfiguration().getDefaultColorPalette()
              .getPositiveColorAWT(), markerStroke);

      marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
      marker.setLabelFont(new Font("Arial", Font.PLAIN, 12));
      marker.setLabelBackgroundColor(Color.WHITE);
      marker.setLabel(e.getKey().getShortName());
      chart.getChart().getXYPlot().addDomainMarker(marker);
      markers.add(marker);
    }

    // revalidate();
    // repaint();
  }
}
 
Example 4
Source File: KovatsIndexExtractionDialog.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * replace markers
 */
private void kovatsValuesChanged() {
  // parse values
  if (parseValues() && chart != null) {
    //
    chart.getChart().getXYPlot().clearDomainMarkers();
    if (markers == null)
      markers = new ArrayList<>();
    else
      markers.clear();

    for (Entry<KovatsIndex, Double> e : parsedValues.entrySet()) {
      ValueMarker marker = new ValueMarker(e.getValue(),
          ColorPalettes.getPositiveColor(MZmineCore.getConfiguration().getColorVision()),
          markerStroke);
      marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
      marker.setLabelFont(new Font("Arial", Font.PLAIN, 12));
      marker.setLabelBackgroundColor(Color.WHITE);
      marker.setLabel(e.getKey().getShortName());
      chart.getChart().getXYPlot().addDomainMarker(marker);
      markers.add(marker);
    }

    revalidate();
    repaint();
  }
}
 
Example 5
Source File: KafkaFT.java    From flink-perf with Apache License 2.0 5 votes vote down vote up
private static void addKillEvent(XYPlot xyplot, long pos) {
	ValueMarker vm = new ValueMarker(pos);
	vm.setPaint(ChartColor.VERY_DARK_GREEN);
	vm.setLabelOffset(new RectangleInsets(10.0D, 1.0D, 1.0D, 1.0D));
	vm.setLabel("Container Kill Event");
	vm.setStroke(new BasicStroke(2));
	xyplot.addDomainMarker(vm);
}
 
Example 6
Source File: KafkaFT.java    From flink-perf with Apache License 2.0 5 votes vote down vote up
private static void addIllegalEvent(XYPlot xyplot, long pos) {
	ValueMarker vm = new ValueMarker(pos);
	vm.setPaint(ChartColor.LIGHT_YELLOW);
	vm.setLabelOffset(new RectangleInsets(10.0D, 1.0D, 1.0D, 1.0D));
	vm.setLabel("Illegal State");
	vm.setStroke(new BasicStroke(2));
	xyplot.addDomainMarker(vm);
}