org.jfree.chart.util.Args Java Examples

The following examples show how to use org.jfree.chart.util.Args. 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: ChartExportUtil.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints a chart with scaling options
 *
 * @param chart
 * @param info
 * @param out
 * @param width
 * @param height
 * @param resolution
 * @return BufferedImage of a given chart with scaling to resolution
 * @throws IOException
 */
private static BufferedImage paintScaledChartToBufferedImage(JFreeChart chart,
    ChartRenderingInfo info, OutputStream out, int width, int height, int resolution,
    int bufferedIType) throws IOException {
  Args.nullNotPermitted(out, "out");
  Args.nullNotPermitted(chart, "chart");

  double scaleX = resolution / 72.0;
  double scaleY = resolution / 72.0;

  double desiredWidth = width * scaleX;
  double desiredHeight = height * scaleY;
  double defaultWidth = width;
  double defaultHeight = height;
  boolean scale = false;

  // get desired width and height from somewhere then...
  if ((scaleX != 1) || (scaleY != 1)) {
    scale = true;
  }

  BufferedImage image = new BufferedImage((int) desiredWidth, (int) desiredHeight, bufferedIType);
  Graphics2D g2 = image.createGraphics();

  if (scale) {
    AffineTransform saved = g2.getTransform();
    g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY));
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
    g2.setTransform(saved);
    g2.dispose();
  } else {
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
  }
  return image;
}
 
Example #3
Source File: ChartCanvas.java    From jfreechart-fx with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add an overlay to the canvas.
 *
 * @param overlay  the overlay ({@code null} not permitted).
 */
public void addOverlay(OverlayFX overlay) {
    Args.nullNotPermitted(overlay, "overlay");
    this.overlays.add(overlay);
    overlay.addChangeListener(this);
    draw();
}
 
Example #4
Source File: ChartCanvas.java    From jfreechart-fx with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Removes an overlay from the canvas.
 *
 * @param overlay  the overlay to remove ({@code null} not permitted).
 */
public void removeOverlay(OverlayFX overlay) {
    Args.nullNotPermitted(overlay, "overlay");
    boolean removed = this.overlays.remove(overlay);
    if (removed) {
        overlay.removeChangeListener(this);
        draw();
    }
}
 
Example #5
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 #6
Source File: ChartExportUtil.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints a chart with scaling options
 * 
 * @param chart
 * @param info
 * @param out
 * @param width
 * @param height
 * @param resolution
 * @return BufferedImage of a given chart with scaling to resolution
 * @throws IOException
 */
private static BufferedImage paintScaledChartToBufferedImage(JFreeChart chart,
    ChartRenderingInfo info, OutputStream out, int width, int height, int resolution,
    int bufferedIType) throws IOException {
  Args.nullNotPermitted(out, "out");
  Args.nullNotPermitted(chart, "chart");

  double scaleX = resolution / 72.0;
  double scaleY = resolution / 72.0;

  double desiredWidth = width * scaleX;
  double desiredHeight = height * scaleY;
  double defaultWidth = width;
  double defaultHeight = height;
  boolean scale = false;

  // get desired width and height from somewhere then...
  if ((scaleX != 1) || (scaleY != 1)) {
    scale = true;
  }

  BufferedImage image = new BufferedImage((int) desiredWidth, (int) desiredHeight, bufferedIType);
  Graphics2D g2 = image.createGraphics();

  if (scale) {
    AffineTransform saved = g2.getTransform();
    g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY));
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
    g2.setTransform(saved);
    g2.dispose();
  } else {
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
  }
  return image;
}
 
Example #7
Source File: ChartExportUtil.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints a chart with scaling options
 * 
 * @param chart
 * @param info
 * @param out
 * @param width
 * @param height
 * @param resolution
 * @return BufferedImage of a given chart with scaling to resolution
 * @throws IOException
 */
private static BufferedImage paintScaledChartToBufferedImage(JFreeChart chart,
    ChartRenderingInfo info, OutputStream out, int width, int height, int resolution,
    int bufferedIType) throws IOException {
  Args.nullNotPermitted(out, "out");
  Args.nullNotPermitted(chart, "chart");

  double scaleX = resolution / 72.0;
  double scaleY = resolution / 72.0;

  double desiredWidth = width * scaleX;
  double desiredHeight = height * scaleY;
  double defaultWidth = width;
  double defaultHeight = height;
  boolean scale = false;

  // get desired width and height from somewhere then...
  if ((scaleX != 1) || (scaleY != 1)) {
    scale = true;
  }

  BufferedImage image = new BufferedImage((int) desiredWidth, (int) desiredHeight, bufferedIType);
  Graphics2D g2 = image.createGraphics();

  if (scale) {
    AffineTransform saved = g2.getTransform();
    g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY));
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
    g2.setTransform(saved);
    g2.dispose();
  } else {
    chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), info);
  }
  return image;
}
 
Example #8
Source File: TaChartCanvas.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Removes an overlay from the canvas.
 *
 * @param overlay  the overlay to remove ({@code null} not permitted).
 *
 * @since 1.0.20
 */
public void removeOverlay(TaOverlayFX overlay) {
    Args.nullNotPermitted(overlay, "overlay");
    boolean removed = this.overlays.remove(overlay);
    if (removed) {
        overlay.removeChangeListener(this);
        draw();
    }
}
 
Example #9
Source File: AbstractMouseHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Creates a new instance.  The modifier keys are used to select a 
 * mouse handler to be the current "live" handler (when a handler is
 * used as an auxiliary handler, the modifier keys are not relevant).
 * 
 * @param id  the handler id ({@code null} not permitted).
 * @param altKey  require ALT key modifier?
 * @param ctrlKey  require ALT key modifier?
 * @param metaKey  require ALT key modifier?
 * @param shiftKey   require ALT key modifier?
 */
public AbstractMouseHandlerFX(String id, boolean altKey, boolean ctrlKey, 
        boolean metaKey, boolean shiftKey) {
    Args.nullNotPermitted(id, "id");
    this.id = id;
    this.enabled = true;
    this.altKey = altKey;
    this.ctrlKey = ctrlKey;
    this.metaKey = metaKey;
    this.shiftKey = shiftKey;
}
 
Example #10
Source File: TaAbstractMouseHandlerFX.java    From TAcharting with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
     * Creates a new instance.  The modifier keys are used to select a
     * mouse handler to be the current "live" handler (when a handler is
     * used as an auxiliary handler, the modifier keys are not relevant).
     *
     * @param id  the handler id ({@code null} not permitted).
     * @param altKey  require ALT key modifier?
     * @param ctrlKey  require ALT key modifier?
     * @param metaKey  require ALT key modifier?
     * @param shiftKey   require ALT key modifier?
     */
public TaAbstractMouseHandlerFX(String id, boolean altKey, boolean ctrlKey,
    boolean metaKey, boolean shiftKey) {
    Args.nullNotPermitted(id, "id");
    this.id = id;
    this.enabled = true;
    this.altKey = altKey;
    this.ctrlKey = ctrlKey;
    this.metaKey = metaKey;
    this.shiftKey = shiftKey;
}
 
Example #11
Source File: TaChartCanvas.java    From TAcharting with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Add an overlay to the canvas.
 *
 * @param overlay  the overlay ({@code null} not permitted).
 *
 * @since 1.0.20
 */
public void addOverlay(TaOverlayFX overlay) {
    Args.nullNotPermitted(overlay, "overlay");
    this.overlays.add(overlay);
    overlay.addChangeListener(this);
    draw();
}
 
Example #12
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the paint scale used by the renderer and sends a {@link RendererChangeEvent} to all
 * registered listeners.
 *
 * @param scale the scale ({@code null} not permitted).
 *
 * @see #getPaintScale()
 * @since 1.0.4
 */
public void setPaintScale(PaintScale scale) {
  Args.nullNotPermitted(scale, "scale");
  this.paintScale = scale;
  fireChangeEvent();
}
 
Example #13
Source File: TaChartViewer.java    From TAcharting with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Sets the org.sjwimmer.tacharting.chart to be displayed by this viewer.
 *
 * @param chart  the org.sjwimmer.tacharting.chart ({@code null} not permitted).
 */
public void setChart(JFreeChart chart) {
    Args.nullNotPermitted(chart, "org/sjwimmer/tacharting/chart");
    this.canvas.setChart(chart);
}
 
Example #14
Source File: TaChartCanvas.java    From TAcharting with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Registers a listener to receive {@link ChartMouseEvent} notifications.
 *
 * @param listener  the listener ({@code null} not permitted).
 */
public void addChartMouseListener(ChartMouseListenerFX listener) {
    Args.nullNotPermitted(listener, "listener");
    this.chartMouseListeners.add(listener);
}
 
Example #15
Source File: ChartViewer.java    From jfreechart-fx with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListenerFX listener) {
    Args.nullNotPermitted(listener, "listener");
    this.canvas.removeChartMouseListener(listener);
}
 
Example #16
Source File: ChartViewer.java    From jfreechart-fx with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Registers a listener to receive {@link ChartMouseEvent} notifications
 * from the canvas embedded in this viewer.
 *
 * @param listener  the listener ({@code null} not permitted).
 */
public void addChartMouseListener(ChartMouseListenerFX listener) {
    Args.nullNotPermitted(listener, "listener");
    this.canvas.addChartMouseListener(listener);
}
 
Example #17
Source File: ChartViewer.java    From jfreechart-fx with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Sets the chart to be displayed by this viewer.
 * 
 * @param chart  the chart ({@code null} not permitted). 
 */
public void setChart(JFreeChart chart) {
    Args.nullNotPermitted(chart, "chart");
    this.canvas.setChart(chart);
}
 
Example #18
Source File: ChartCanvas.java    From jfreechart-fx with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Registers a listener to receive {@link ChartMouseEvent} notifications.
 *
 * @param listener  the listener ({@code null} not permitted).
 */
public void addChartMouseListener(ChartMouseListenerFX listener) {
    Args.nullNotPermitted(listener, "listener");
    this.chartMouseListeners.add(listener);
}
 
Example #19
Source File: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the paint scale used by the renderer and sends a {@link RendererChangeEvent} to all
 * registered listeners.
 *
 * @param scale the scale ({@code null} not permitted).
 *
 * @see #getPaintScale()
 * @since 1.0.4
 */
public void setPaintScale(PaintScale scale) {
  Args.nullNotPermitted(scale, "scale");
  this.paintScale = scale;
  fireChangeEvent();
}