org.jfree.chart.plot.IntervalMarker Java Examples

The following examples show how to use org.jfree.chart.plot.IntervalMarker. 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: ChartUtil.java    From ezScrum with GNU General Public License v2.0 6 votes vote down vote up
@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++;
	}
}
 
Example #2
Source File: GrammarvizChartPanel.java    From grammarviz2_src with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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);
}
 
Example #3
Source File: GrammarvizChartPanel.java    From grammarviz2_src with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a periodicity marker.
 * 
 * @param plot plot for the marker
 * @param startVal start postion
 * @param endVal end position
 */
protected void addPeriodMarker(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.blue);
  marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
  marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);

  marker.setPaint(Color.blue);

  plot.addDomainMarker(marker, Layer.BACKGROUND);
}
 
Example #4
Source File: GrammarvizChartPanel.java    From grammarviz2_src with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an anomaly marker.
 * 
 * @param plot plot for the marker
 * @param startVal start postion
 * @param endVal end position
 */
protected void addAnomalyMarker(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.pink);
  marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
  marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);

  marker.setPaint(Color.pink);

  plot.addDomainMarker(marker, Layer.BACKGROUND);
}
 
Example #5
Source File: IntervalMarkerTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEndValue() and setEndValue() methods.
 */
public void testGetSetEndValue() {
    IntervalMarker m = new IntervalMarker(1.0, 2.0);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(2.0, m.getEndValue(), EPSILON);
    m.setEndValue(0.5);
    assertEquals(0.5, m.getEndValue(), EPSILON);
    assertEquals(m, this.lastEvent.getMarker());
}
 
Example #6
Source File: MarkerAxisBand.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #7
Source File: MarkerAxisBand.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #8
Source File: MarkerAxisBand.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s, 
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #9
Source File: MarkerAxisBand.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s, 
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #10
Source File: IntervalMarkerTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEndValue() and setEndValue() methods.
 */
public void testGetSetEndValue() {
    IntervalMarker m = new IntervalMarker(1.0, 2.0);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(2.0, m.getEndValue(), EPSILON);
    m.setEndValue(0.5);
    assertEquals(0.5, m.getEndValue(), EPSILON);
    assertEquals(m, this.lastEvent.getMarker());
}
 
Example #11
Source File: IntervalMarkerTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStartValue() and setStartValue() methods.
 */
public void testGetSetStartValue() {
    IntervalMarker m = new IntervalMarker(1.0, 2.0);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(1.0, m.getStartValue(), EPSILON);
    m.setStartValue(0.5);
    assertEquals(0.5, m.getStartValue(), EPSILON);
    assertEquals(m, this.lastEvent.getMarker());
}
 
Example #12
Source File: MarkerAxisBand.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #13
Source File: IntervalMarkerTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStartValue() and setStartValue() methods.
 */
public void testGetSetStartValue() {
    IntervalMarker m = new IntervalMarker(1.0, 2.0);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(1.0, m.getStartValue(), EPSILON);
    m.setStartValue(0.5);
    assertEquals(0.5, m.getStartValue(), EPSILON);
    assertEquals(m, this.lastEvent.getMarker());
}
 
Example #14
Source File: MarkerAxisBand.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #15
Source File: MarkerAxisBand.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #16
Source File: MarkerAxisBand.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #17
Source File: cfCHART.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public void addRangeMarker(XYPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException {
	IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd());
	rangeMarker.setPaint(convertStringToColor(rmData.getColor()));
	if (rmData.getLabel() != null) {
		rangeMarker.setLabel(rmData.getLabel());
		rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor()));
		String labelPos = rmData.getLabelPosition();
		if (labelPos.equals("top_left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
		} else if (labelPos.equals("top")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
		} else if (labelPos.equals("top_right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
		} else if (labelPos.equals("left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
		} else if (labelPos.equals("center")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.CENTER);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER);
		} else if (labelPos.equals("right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
		} else if (labelPos.equals("bottom_left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
		} else if (labelPos.equals("bottom")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
		} else if (labelPos.equals("bottom_right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
		}
		rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
		rangeMarker.setLabelFont(getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize()));
	}
	plot.addRangeMarker(rangeMarker, org.jfree.ui.Layer.BACKGROUND);
}
 
Example #18
Source File: cfCHART.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public void addRangeMarker(CategoryPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException {
	IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd());
	rangeMarker.setPaint(convertStringToColor(rmData.getColor()));
	if (rmData.getLabel() != null) {
		rangeMarker.setLabel(rmData.getLabel());
		rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor()));
		String labelPos = rmData.getLabelPosition();
		if (labelPos.equals("top_left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
		} else if (labelPos.equals("top")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
		} else if (labelPos.equals("top_right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
		} else if (labelPos.equals("left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
		} else if (labelPos.equals("center")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.CENTER);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER);
		} else if (labelPos.equals("right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
		} else if (labelPos.equals("bottom_left")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
		} else if (labelPos.equals("bottom")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
		} else if (labelPos.equals("bottom_right")) {
			rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
			rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
		}
		rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
		rangeMarker.setLabelFont(getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize()));
	}
	plot.addRangeMarker(rangeMarker, Layer.BACKGROUND);
}
 
Example #19
Source File: MarkerAxisBand.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the band.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
                 double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
        IntervalMarker marker = (IntervalMarker) iterator.next();
        double start =  Math.max(
            marker.getStartValue(), this.axis.getRange().getLowerBound()
        );
        double end = Math.min(
            marker.getEndValue(), this.axis.getRange().getUpperBound()
        );
        double s = this.axis.valueToJava2D(
            start, dataArea, RectangleEdge.BOTTOM
        );
        double e = this.axis.valueToJava2D(
            end, dataArea, RectangleEdge.BOTTOM
        );
        Rectangle2D r = new Rectangle2D.Double(
            s, y + this.topOuterGap, e - s,
            h - this.topOuterGap - this.bottomOuterGap
        );

        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
            AlphaComposite.SRC_OVER, marker.getAlpha())
        );
        g2.setPaint(marker.getPaint());
        g2.fill(r);
        g2.setPaint(marker.getOutlinePaint());
        g2.draw(r);
        g2.setComposite(originalComposite);

        g2.setPaint(Color.black);
        drawStringInRect(g2, r, this.font, marker.getLabel());
    }

}
 
Example #20
Source File: AbstractIntervalMarkerCustomizer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected IntervalMarker createMarker()
{
	Double startValue = getDoubleProperty(PROPERTY_START_VALUE);
	Double endValue = getDoubleProperty(PROPERTY_END_VALUE);

	if (
		startValue == null 
		|| endValue == null
		)
	{
		return null;
	}

	IntervalMarker marker = new IntervalMarker(startValue, endValue);

	configureMarker(marker);
	
	Float strokeWidth = getFloatProperty(PROPERTY_STROKE_WIDTH);
	if (
		strokeWidth != null
		&& strokeWidth > 0
		) 
	{
		BasicStroke basicStroke = getStroke(strokeWidth);

		marker.setOutlineStroke(basicStroke);

		Color outlineColor = JRColorUtil.getColor(getProperty(PROPERTY_OUTLINE_COLOR), null);
		if (outlineColor != null)
		{
			marker.setOutlinePaint(outlineColor);
		}
	}

	return marker;
}
 
Example #21
Source File: SWTTimeSeriesDemo.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a chart.
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
        "Legal & General Unit Trust Prices",  // title
        "Date",             // x-axis label
        "Price Per Unit",   // y-axis label
        dataset,            // data
        true,               // create legend?
        true,               // generate tooltips?
        false               // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    //plot.setForegroundAlpha(0.5f);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }

    // code to test the alpha channel
    IntervalMarker interv = new IntervalMarker(120, 150,
            Color.blue, new BasicStroke(5.0f),null,null,0.2f);
    plot.addRangeMarker(interv);

    // code to test the alpha channel within awt colors
    XYDifferenceRenderer differenceRenderer= new XYDifferenceRenderer(
            new Color(255, 0, 0, 128),new Color(0, 255, 0, 128), false);
    plot.setRenderer(differenceRenderer);

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}
 
Example #22
Source File: ProfilePlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void removeIntervalMarkers() {
    for (IntervalMarker intervalMarker : intervalMarkers) {
        chart.getXYPlot().removeDomainMarker(intervalMarker, Layer.BACKGROUND);
    }
    intervalMarkers.clear();
}
 
Example #23
Source File: ProfilePlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void updateUIState() {
    if (!isInitialized) {
        return;
    }

    xAxisRangeControl.getBindingContext().setComponentsEnabled(PROPERTY_NAME_MARK_SEGMENTS,
                                                               profileData != null &&
                                                                       profileData.getShapeVertices().length > 2);
    xAxisRangeControl.setComponentsEnabled(profileData != null);
    yAxisRangeControl.setComponentsEnabled(profileData != null);
    adjustPlotAxes();

    if (dataSourceConfig.computeInBetweenPoints) {
        chart.getXYPlot().setRenderer(deviationRenderer);
    } else {
        chart.getXYPlot().setRenderer(pointRenderer);
    }

    chart.getXYPlot().getRangeAxis().setLabel(StatisticChartStyling.getAxisLabel(getRaster(), DEFAULT_SAMPLE_DATASET_NAME, false));

    boolean markSegments = xAxisRangeControl.getBindingContext().getPropertySet().getValue(PROPERTY_NAME_MARK_SEGMENTS);
    if (markSegments && profileData != null && profileData.getNumShapeVertices() > 1) {
        final int[] shapeVertexIndexes = profileData.getShapeVertexIndexes();
        removeIntervalMarkers();
        for (int i = 0; i < shapeVertexIndexes.length - 1; i++) {
            if (i % 2 != 0) {
                final IntervalMarker marker = new IntervalMarker(shapeVertexIndexes[i], shapeVertexIndexes[i + 1]);
                marker.setPaint(new Color(120, 122, 125));
                marker.setAlpha(0.3F);
                chart.getXYPlot().addDomainMarker(marker, Layer.BACKGROUND);
                intervalMarkers.add(marker);
            }
        }
    } else {
        removeIntervalMarkers();
    }

    pointDataSourceEnablement.apply();
    dataFieldEnablement.apply();

}
 
Example #24
Source File: SWTTimeSeriesDemo.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
        "Legal & General Unit Trust Prices",  // title
        "Date",             // x-axis label
        "Price Per Unit",   // y-axis label
        dataset,            // data
        true,               // create legend?
        true,               // generate tooltips?
        false               // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    //plot.setForegroundAlpha(0.5f);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    
    // code to test the alpha channel
    IntervalMarker interv = new IntervalMarker(120, 150,
    		Color.blue, new BasicStroke(5.0f),null,null,0.2f);
    plot.addRangeMarker(interv);
    
    // code to test the alpha channel within awt colors
    XYDifferenceRenderer differenceRenderer= new XYDifferenceRenderer(new Color(255,0,0,128),new Color(0,255,0,128),false);
    plot.setRenderer(differenceRenderer);
    
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    
    return chart;

}
 
Example #25
Source File: MarkerAxisBand.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}
 
Example #26
Source File: MarkerAxisBand.java    From opensim-gui with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}
 
Example #27
Source File: MarkerAxisBand.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}
 
Example #28
Source File: MarkerAxisBand.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}
 
Example #29
Source File: MarkerAxisBand.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}
 
Example #30
Source File: MarkerAxisBand.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a marker to the band.
 *
 * @param marker  the marker.
 */
public void addMarker(IntervalMarker marker) {
    this.markers.add(marker);
}