org.jfree.chart.ui.RectangleAnchor Java Examples

The following examples show how to use org.jfree.chart.ui.RectangleAnchor. 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: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the anchor point used to align a block at its (x, y) location and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param anchor the anchor.
 *
 * @see #getBlockAnchor()
 */
public void setBlockAnchor(RectangleAnchor anchor) {
  Args.nullNotPermitted(anchor, "anchor");
  if (this.blockAnchor.equals(anchor)) {
    return; // no change
  }
  this.blockAnchor = anchor;
  updateOffsets();
  fireChangeEvent();
}
 
Example #2
Source File: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Updates the offsets to take into account the block width, height and anchor.
 */
private void updateOffsets() {
  if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = -this.blockHeight;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = -this.blockHeight;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = -this.blockHeight;
  }
}
 
Example #3
Source File: TaChart.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Adds entry and exits signals to the cahrt.
 * @param record the trading record
 * */
private void addEntryExitSignals(TradingRecord record){
    List<Trade> trades = record.getTrades();
    Order.OrderType orderType = record.getLastExit().getType().complementType();
    List<Marker> markers = new ArrayList<>();
    RectangleAnchor entryAnchor = RectangleAnchor.TOP_LEFT;
    RectangleAnchor exitAnchor = RectangleAnchor.BOTTOM_RIGHT;

    Color entryColor = orderType==Order.OrderType.SELL ? Color.RED : Color.GREEN;
    Color exitColor = orderType==Order.OrderType.SELL ? Color.GREEN: Color.RED;
    BarSeries series = chartIndicatorBox.getBarSeries();
    for(Trade trade: trades){
        double entry = new Minute(Date.from(
                series.getBar(trade.getEntry().getIndex()).getEndTime().toInstant())).getFirstMillisecond();
        double exit = new Minute(Date.from(
                series.getBar(trade.getExit().getIndex()).getEndTime().toInstant())).getFirstMillisecond();

        ValueMarker in = new ValueMarker(entry);
        in.setLabel(orderType.toString());
        in.setLabelPaint(Color.WHITE);
        in.setLabelAnchor(entryAnchor);
        in.setPaint(entryColor);
        this.mainPlot.addDomainMarker(in);

        ValueMarker out = new ValueMarker(exit);
        out.setLabel(orderType.complementType().toString());
        out.setLabelPaint(Color.WHITE);
        out.setLabelAnchor(exitAnchor);
        out.setPaint(exitColor);
        this.mainPlot.addDomainMarker(out);

        IntervalMarker imarker = new IntervalMarker(entry, exit, entryColor);
        imarker.setAlpha(0.1f);
        this.mainPlot.addDomainMarker(imarker);
        markers.add(imarker);
        markers.add(in);
        markers.add(out);
    }
    this.mapTradingRecordMarker.put(record, markers);
}
 
Example #4
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the anchor point used to align a block at its (x, y) location and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param anchor the anchor.
 *
 * @see #getBlockAnchor()
 */
public void setBlockAnchor(RectangleAnchor anchor) {
  Args.nullNotPermitted(anchor, "anchor");
  if (this.blockAnchor.equals(anchor)) {
    return; // no change
  }
  this.blockAnchor = anchor;
  updateOffsets();
  fireChangeEvent();
}
 
Example #5
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Updates the offsets to take into account the block width, height and anchor.
 */
private void updateOffsets() {
  if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = 0.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = -this.blockHeight / 2.0;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) {
    this.xOffset = 0.0;
    this.yOffset = -this.blockHeight;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) {
    this.xOffset = -this.blockWidth / 2.0;
    this.yOffset = -this.blockHeight;
  } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) {
    this.xOffset = -this.blockWidth;
    this.yOffset = -this.blockHeight;
  }
}
 
Example #6
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 #7
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 #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: JPanelProfil.java    From Course_Generator with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Update the profil chart
 */
public void RefreshProfilChart() {
	if (track == null)
		return;
	if (track.data.isEmpty())
		return;

	// -- Clear all series
	if (datasetProfil.getSeriesCount() > 0)
		datasetProfil.removeAllSeries();

	XYPlot plot = chartProfil.getXYPlot();
	plot.clearDomainMarkers();

	// -- Populate the serie
	XYSeries serie1 = new XYSeries("Elevation/Distance");
	int cmpt = 1;
	for (CgData r : track.data) {
		double x = r.getTotal(settings.Unit) / 1000;
		double y = r.getElevation(settings.Unit);
		serie1.add(x, y);

		if (((r.getTag() & CgConst.TAG_MARK) != 0) & showProfilMarker) {
			Marker m = new ValueMarker(x);
			m.setPaint(Color.GRAY);
			m.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
			m.setLabel(String.valueOf(cmpt));
			m.setLabelOffset(new RectangleInsets(5, 0, 0, 2));
			m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
			m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
			plot.addDomainMarker(m);
			cmpt++;
		}
	}
	datasetProfil.addSeries(serie1);

	if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) {
		// XYPlot plot = chart.getXYPlot();
		ValueAxis axisY = plot.getRangeAxis();
		axisY.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0,
				Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0);
	}
}
 
Example #10
Source File: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the anchor point used to align a block at its (x, y) location. The default values is
 * {@link RectangleAnchor#CENTER}.
 *
 * @return The anchor point (never {@code null}).
 *
 * @see #setBlockAnchor(RectangleAnchor)
 */
public RectangleAnchor getBlockAnchor() {
  return this.blockAnchor;
}
 
Example #11
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the anchor point used to align a block at its (x, y) location. The default values is
 * {@link RectangleAnchor#CENTER}.
 *
 * @return The anchor point (never {@code null}).
 *
 * @see #setBlockAnchor(RectangleAnchor)
 */
public RectangleAnchor getBlockAnchor() {
  return this.blockAnchor;
}