org.jfree.chart.entity.AxisEntity Java Examples

The following examples show how to use org.jfree.chart.entity.AxisEntity. 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: ChartGestureDragDiffHandler.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * use default orientation or orientation of axis
 * 
 * @param event
 * @return
 */
public Orientation getOrientation(ChartGestureEvent event) {
  ChartEntity ce = event.getEntity();
  if (ce instanceof AxisEntity) {
    JFreeChart chart = event.getChart();
    PlotOrientation plotorient = PlotOrientation.HORIZONTAL;
    if (chart.getXYPlot() != null)
      plotorient = chart.getXYPlot().getOrientation();
    else if (chart.getCategoryPlot() != null)
      plotorient = chart.getCategoryPlot().getOrientation();

    Entity entity = event.getGesture().getEntity();
    if ((entity.equals(Entity.DOMAIN_AXIS) && plotorient.equals(PlotOrientation.VERTICAL))
        || (entity.equals(Entity.RANGE_AXIS) && plotorient.equals(PlotOrientation.HORIZONTAL)))
      orient = Orientation.HORIZONTAL;
    else
      orient = Orientation.VERTICAL;
  }
  return orient;
}
 
Example #2
Source File: ChartGestureDragDiffHandler.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * use default orientation or orientation of axis
 * 
 * @param event
 * @return
 */
public Orientation getOrientation(ChartGestureEvent event) {
  ChartEntity ce = event.getEntity();
  if (ce instanceof AxisEntity) {
    JFreeChart chart = event.getChart();
    PlotOrientation plotorient = PlotOrientation.HORIZONTAL;
    if (chart.getXYPlot() != null)
      plotorient = chart.getXYPlot().getOrientation();
    else if (chart.getCategoryPlot() != null)
      plotorient = chart.getCategoryPlot().getOrientation();

    Entity entity = event.getGesture().getEntity();
    if ((entity.equals(Entity.DOMAIN_AXIS) && plotorient.equals(PlotOrientation.VERTICAL))
        || (entity.equals(Entity.RANGE_AXIS) && plotorient.equals(PlotOrientation.HORIZONTAL)))
      orient = Orientation.HORIZONTAL;
    else
      orient = Orientation.VERTICAL;
  }
  return orient;
}
 
Example #3
Source File: ChartGestureDragDiffHandler.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * use default orientation or orientation of axis
 * 
 * @param event
 * @return
 */
public Orientation getOrientation(ChartGestureEvent event) {
  ChartEntity ce = event.getEntity();
  if (ce instanceof AxisEntity) {
    JFreeChart chart = event.getChart();
    PlotOrientation plotorient = PlotOrientation.HORIZONTAL;
    if (chart.getXYPlot() != null)
      plotorient = chart.getXYPlot().getOrientation();
    else if (chart.getCategoryPlot() != null)
      plotorient = chart.getCategoryPlot().getOrientation();

    Entity entity = event.getGesture().getEntity();
    if ((entity.equals(Entity.DOMAIN_AXIS) && plotorient.equals(PlotOrientation.VERTICAL))
        || (entity.equals(Entity.RANGE_AXIS) && plotorient.equals(PlotOrientation.HORIZONTAL)))
      orient = Orientation.HORIZONTAL;
    else
      orient = Orientation.VERTICAL;
  }
  return orient;
}
 
Example #4
Source File: Axis.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #5
Source File: ChartGestureEvent.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The ValueAxis of this event's entity or null if the entity is different to an AxisEntity or if
 * the axis is not a ValueAxis
 * 
 * @return
 */
public ValueAxis getAxis() {
  if (entity != null && entity instanceof AxisEntity
      && ((AxisEntity) entity).getAxis() instanceof ValueAxis)
    return (ValueAxis) ((AxisEntity) entity).getAxis();
  else
    return null;
}
 
Example #6
Source File: ChartGesture.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The gesture entity type
 * 
 * @param entity
 * @return
 */
public static Entity getGestureEntity(ChartEntity entity) {
  if (entity == null)
    return NONE;
  if (entity instanceof PlotEntity)
    return PLOT;
  if (entity instanceof AxisEntity) {
    AxisEntity e = (AxisEntity) entity;
    if (e.getAxis().getPlot() instanceof XYPlot) {
      XYPlot plot = ((XYPlot) e.getAxis().getPlot());
      for (int i = 0; i < plot.getDomainAxisCount(); i++)
        if (plot.getDomainAxis(i).equals(e.getAxis()))
          return DOMAIN_AXIS;
      for (int i = 0; i < plot.getRangeAxisCount(); i++)
        if (plot.getRangeAxis(i).equals(e.getAxis()))
          return RANGE_AXIS;
    }
    // else return basic axis
    return AXIS;
  }
  if (entity instanceof LegendItemEntity)
    return LEGEND_ITEM;
  if (entity instanceof XYItemEntity)
    return XY_ITEM;
  if (entity instanceof XYAnnotationEntity)
    return XY_ANNOTATION;
  if (entity instanceof TitleEntity) {
    if (((TitleEntity) entity).getTitle() instanceof TextTitle)
      return TEXT_TITLE;
    else
      return NON_TEXT_TITLE;
  }
  if (entity instanceof JFreeChartEntity)
    return JFREECHART;
  if (entity instanceof CategoryItemEntity)
    return CATEGORY_ITEM;
  return GENERAL;
}
 
Example #7
Source File: Axis.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #8
Source File: Axis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #9
Source File: ChartGestureEvent.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The ValueAxis of this event's entity or null if the entity is different to an AxisEntity or if
 * the axis is not a ValueAxis
 * 
 * @return
 */
public ValueAxis getAxis() {
  if (entity != null && entity instanceof AxisEntity
      && ((AxisEntity) entity).getAxis() instanceof ValueAxis)
    return (ValueAxis) ((AxisEntity) entity).getAxis();
  else
    return null;
}
 
Example #10
Source File: ChartGesture.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The gesture entity type
 * 
 * @param entity
 * @return
 */
public static Entity getGestureEntity(ChartEntity entity) {
  if (entity == null)
    return NONE;
  if (entity instanceof PlotEntity)
    return PLOT;
  if (entity instanceof AxisEntity) {
    AxisEntity e = (AxisEntity) entity;
    if (e.getAxis().getPlot() instanceof XYPlot) {
      XYPlot plot = ((XYPlot) e.getAxis().getPlot());
      for (int i = 0; i < plot.getDomainAxisCount(); i++)
        if (plot.getDomainAxis(i).equals(e.getAxis()))
          return DOMAIN_AXIS;
      for (int i = 0; i < plot.getRangeAxisCount(); i++)
        if (plot.getRangeAxis(i).equals(e.getAxis()))
          return RANGE_AXIS;
    }
    // else return basic axis
    return AXIS;
  }
  if (entity instanceof LegendItemEntity)
    return LEGEND_ITEM;
  if (entity instanceof XYItemEntity)
    return XY_ITEM;
  if (entity instanceof XYAnnotationEntity)
    return XY_ANNOTATION;
  if (entity instanceof TitleEntity) {
    if (((TitleEntity) entity).getTitle() instanceof TextTitle)
      return TEXT_TITLE;
    else
      return NON_TEXT_TITLE;
  }
  if (entity instanceof JFreeChartEntity)
    return JFREECHART;
  if (entity instanceof CategoryItemEntity)
    return CATEGORY_ITEM;
  return GENERAL;
}
 
Example #11
Source File: ChartGestureEvent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The ValueAxis of this event's entity or null if the entity is different to an AxisEntity or if
 * the axis is not a ValueAxis
 * 
 * @return
 */
public ValueAxis getAxis() {
  if (entity != null && entity instanceof AxisEntity
      && ((AxisEntity) entity).getAxis() instanceof ValueAxis)
    return (ValueAxis) ((AxisEntity) entity).getAxis();
  else
    return null;
}
 
Example #12
Source File: ChartGesture.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The gesture entity type
 * 
 * @param entity
 * @return
 */
public static Entity getGestureEntity(ChartEntity entity) {
  if (entity == null)
    return NONE;
  if (entity instanceof PlotEntity)
    return PLOT;
  if (entity instanceof AxisEntity) {
    AxisEntity e = (AxisEntity) entity;
    if (e.getAxis().getPlot() instanceof XYPlot) {
      XYPlot plot = ((XYPlot) e.getAxis().getPlot());
      for (int i = 0; i < plot.getDomainAxisCount(); i++)
        if (plot.getDomainAxis(i).equals(e.getAxis()))
          return DOMAIN_AXIS;
      for (int i = 0; i < plot.getRangeAxisCount(); i++)
        if (plot.getRangeAxis(i).equals(e.getAxis()))
          return RANGE_AXIS;
    }
    // else return basic axis
    return AXIS;
  }
  if (entity instanceof LegendItemEntity)
    return LEGEND_ITEM;
  if (entity instanceof XYItemEntity)
    return XY_ITEM;
  if (entity instanceof XYAnnotationEntity)
    return XY_ANNOTATION;
  if (entity instanceof TitleEntity) {
    if (((TitleEntity) entity).getTitle() instanceof TextTitle)
      return TEXT_TITLE;
    else
      return NON_TEXT_TITLE;
  }
  if (entity instanceof JFreeChartEntity)
    return JFREECHART;
  if (entity instanceof CategoryItemEntity)
    return CATEGORY_ITEM;
  return GENERAL;
}
 
Example #13
Source File: Axis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #14
Source File: Axis.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we canĀ“t save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #15
Source File: Axis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}
 
Example #16
Source File: Axis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Created an entity for the axis.
 *
 * @param cursor  the initial cursor value.
 * @param state  the axis state after completion of the drawing with a
 *     possibly updated cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * @param plotState  the PlotRenderingInfo from which a reference to the
 *     entity collection can be obtained.
 *
 * @since 1.0.13
 */
protected void createAndAddEntity(double cursor, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    if (plotState == null || plotState.getOwner() == null) {
        return;  // no need to create entity if we can't save it anyways...
    }
    Rectangle2D hotspot = null;
    if (edge.equals(RectangleEdge.TOP)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(),
                state.getCursor(), dataArea.getWidth(),
                cursor - state.getCursor());
    }
    else if (edge.equals(RectangleEdge.BOTTOM)) {
        hotspot = new Rectangle2D.Double(dataArea.getX(), cursor,
                dataArea.getWidth(), state.getCursor() - cursor);
    }
    else if (edge.equals(RectangleEdge.LEFT)) {
        hotspot = new Rectangle2D.Double(state.getCursor(),
                dataArea.getY(), cursor - state.getCursor(),
                dataArea.getHeight());
    }
    else if (edge.equals(RectangleEdge.RIGHT)) {
        hotspot = new Rectangle2D.Double(cursor, dataArea.getY(),
                state.getCursor() - cursor, dataArea.getHeight());
    }
    EntityCollection e = plotState.getOwner().getEntityCollection();
    if (e != null) {
        e.add(new AxisEntity(hotspot, this));
    }
}