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

The following examples show how to use org.jfree.chart.plot.ValueMarker#setLabel() . 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 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());
}
 
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 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());
}
 
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);
}
 
Example 7
Source File: MouseListenerValue.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected ValueMarker makeMarker( final double value )
{
	final ValueMarker valueMarker = new ValueMarker( value );
	valueMarker.setStroke( new BasicStroke ( 2f ) );
	valueMarker.setPaint( new Color( 0f/255f, 0f/255f, 255f/255f ) );
	valueMarker.setLabel( " Distance=" + value );
	valueMarker.setLabelPaint( Color.BLUE );
	valueMarker.setLabelAnchor( RectangleAnchor.TOP );
	valueMarker.setLabelTextAnchor( TextAnchor.TOP_LEFT );

	return valueMarker;
}
 
Example 8
Source File: MouseListenerTimelapse.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected ValueMarker makeMarker( final int timePoint )
{
	final ValueMarker valueMarker = new ValueMarker( timePoint );
	valueMarker.setStroke( new BasicStroke ( 1.5f ) );
	valueMarker.setPaint( new Color( 0.0f, 93f/255f, 9f/255f ) );
	valueMarker.setLabel( " Reference\n Timepoint " + timePoint );
	valueMarker.setLabelAnchor(RectangleAnchor.BOTTOM );
	valueMarker.setLabelTextAnchor( TextAnchor.BOTTOM_LEFT );
	
	return valueMarker;
}
 
Example 9
Source File: MouseListenerTimelapse.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected ValueMarker makeMarker( final int timePoint )
{
	final ValueMarker valueMarker = new ValueMarker( timePoint );
	valueMarker.setStroke( new BasicStroke ( 1.5f ) );
	valueMarker.setPaint( new Color( 0.0f, 93f/255f, 9f/255f ) );
	valueMarker.setLabel( " Reference\n Timepoint " + timePoint );
	valueMarker.setLabelAnchor(RectangleAnchor.BOTTOM );
	valueMarker.setLabelTextAnchor( TextAnchor.BOTTOM_LEFT );
	
	return valueMarker;
}
 
Example 10
Source File: HouseholdsPanel.java    From computational-economy with GNU General Public License v3.0 5 votes vote down vote up
protected void addValueMarker(final JFreeChart chart, final double position, final String label) {
	final ValueMarker marker = new ValueMarker(position);
	marker.setPaint(Color.black);
	marker.setLabel(label);
	final XYPlot plot = (XYPlot) chart.getPlot();
	plot.addDomainMarker(marker);
}
 
Example 11
Source File: cfCHART.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public void addDomainMarker(XYPlot plot, cfCHARTDOMAINMARKERData dmData) throws cfmRunTimeException {
	double dbl;
	try {
		dbl = Double.parseDouble(dmData.getValue());
	} catch (NumberFormatException nfe) {
		throw newRunTimeException("the CFCHARTDOMAINMARKER value attribute must be numeric for scale charts");
	}
	ValueMarker domainMarker = new ValueMarker(dbl);
	boolean drawAsLine = true; // XY charts currently only support drawing
															// domain markers as lines
	domainMarker.setPaint(convertStringToColor(dmData.getColor()));
	if (dmData.getLabel() != null) {
		domainMarker.setLabel(dmData.getLabel());
		domainMarker.setLabelPaint(convertStringToColor(dmData.getLabelColor()));
		String labelPos = dmData.getLabelPosition();
		if (labelPos.equals("top_left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
		} else if (labelPos.equals("top")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP);
			domainMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
		} else if (labelPos.equals("top_right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
		} else if (labelPos.equals("left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
		} else if (labelPos.equals("center")) {
			domainMarker.setLabelAnchor(RectangleAnchor.CENTER);
			domainMarker.setLabelTextAnchor(TextAnchor.CENTER);
		} else if (labelPos.equals("right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
		} else if (labelPos.equals("bottom_left")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
		} else if (labelPos.equals("bottom")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
			domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
		} else if (labelPos.equals("bottom_right")) {
			domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
			if (drawAsLine)
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
			else
				domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
		}
		domainMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
		domainMarker.setLabelFont(getFont(dmData.getFont(), dmData.getFontBold(), dmData.getFontItalic(), dmData.getFontSize()));
	}
	plot.addDomainMarker(domainMarker, Layer.BACKGROUND);
}