Esempio n. 1
0
 private XYPlot createScalabilityPlot(
     List<XYSeries> seriesList,
     String xAxisLabel,
     NumberFormat xAxisNumberFormat,
     String yAxisLabel,
     NumberFormat yAxisNumberFormat) {
   NumberAxis xAxis;
   if (useLogarithmicProblemScale(seriesList)) {
     LogarithmicAxis logarithmicAxis = new LogarithmicAxis(xAxisLabel + " (logarithmic)");
     logarithmicAxis.setAllowNegativesFlag(true);
     xAxis = logarithmicAxis;
   } else {
     xAxis = new NumberAxis(xAxisLabel);
   }
   xAxis.setNumberFormatOverride(xAxisNumberFormat);
   NumberAxis yAxis = new NumberAxis(yAxisLabel);
   yAxis.setNumberFormatOverride(yAxisNumberFormat);
   XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
   int seriesIndex = 0;
   for (XYSeries series : seriesList) {
     XYSeriesCollection seriesCollection = new XYSeriesCollection();
     seriesCollection.addSeries(series);
     plot.setDataset(seriesIndex, seriesCollection);
     XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat);
     plot.setRenderer(seriesIndex, renderer);
     seriesIndex++;
   }
   plot.setOrientation(PlotOrientation.VERTICAL);
   return plot;
 }
Esempio n. 2
0
  @Override
  public void modScaleType(Canvas canvas, String xType, String yType)
      throws UndefinedOperationException, IllegalRedefinitionException {

    if (canvas.getFrame().getFrameType() >= FrameWrapper.BAR_FRAME) {
      throw new IllegalRedefinitionException(
          "This Canvas can only be used for Graphs, not for Charts. Create a new Canvas, to draw Graphs");
    }
    LogarithmicAxis log = new LogarithmicAxis(canvas.getFrame().getFrame().getyAxis().getLabel());
    log.setAllowNegativesFlag(true);
    if (xType.equalsIgnoreCase("log")) {
      ((DrawFrame) canvas.getFrame().getFrame()).setxAxis(log);
    } else if (xType.equalsIgnoreCase("num")) {
      ((DrawFrame) canvas.getFrame().getFrame())
          .setxAxis(new NumberAxis(canvas.getFrame().getFrame().getxAxis().getLabel()));
    } else {
      throw new UndefinedOperationException("Axis type for x-Axis can either be log or num");
    }
    if (yType.equalsIgnoreCase("log")) {
      ((DrawFrame) canvas.getFrame().getFrame()).setyAxis(log);
    } else if (yType.equalsIgnoreCase("num")) {
      ((DrawFrame) canvas.getFrame().getFrame())
          .setyAxis(new NumberAxis(canvas.getFrame().getFrame().getyAxis().getLabel()));
    } else {
      throw new UndefinedOperationException("Axis type for y-Axis can either be log or num");
    }
  }