Beispiel #1
0
 @Override
 public void defineTitle(Canvas canvas, String title) {
   canvas.setTitle(title);
   if (canvas.getFrame().getFrame() != null) {
     canvas.getFrame().getFrame().setTitle(title);
   }
 }
Beispiel #2
0
 @Override
 public void modSize(Canvas canvas, List<Double> size) {
   canvas.getFrame().setWidth(size.get(0));
   canvas.getFrame().setHeight(size.get(1));
   if (!(canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME)) {
     canvas.getFrame().getFrame().modSize(size.get(0), size.get(1));
   }
 }
Beispiel #3
0
 @Override
 public Value addLabel(Canvas canvas, List<Double> coordinates, String text)
     throws UndefinedOperationException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     throw new UndefinedOperationException(
         "label cannot be added, if no Graph or Chart is defined. Please add a Graph or Chart first");
   }
   return canvas.getFrame().getFrame().addTextLabel(coordinates, text);
 }
Beispiel #4
0
 @Override
 public void modScale(Canvas canvas, double xMin, double xMax, double yMin, double yMax)
     throws SetlException {
   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");
   }
   ((DrawFrame) canvas.getFrame().getFrame()).modyScale(yMin, yMax);
   ((DrawFrame) canvas.getFrame().getFrame()).modxScale(xMin, xMax);
 }
Beispiel #5
0
 @Override
 public void legendVisible(Canvas canvas, Boolean visible) {
   ChartPanel chartPanel = canvas.getFrame().getFrame().chartPanel;
   canvas.getFrame().getFrame().setLegendVisible(visible);
   if (visible) {
     if (chartPanel.getChart().getLegend() == null) {
       chartPanel.getChart().addLegend(canvas.getFrame().getFrame().legend);
     }
   } else {
     canvas.getFrame().getFrame().legend = chartPanel.getChart().getLegend();
     chartPanel.getChart().removeLegend();
   }
 }
Beispiel #6
0
 @Override
 public Graph addGraph(
     Canvas canvas,
     String function,
     String name,
     State interpreterState,
     List<Integer> color,
     boolean plotArea)
     throws SetlException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     canvas.getFrame().setFrameType(canvas.getFrame().DRAW_FRAME);
     canvas
         .getFrame()
         .setFrame(
             new DrawFrame(
                 canvas.getTitle(), canvas.getFrame().getWidth(), canvas.getFrame().getHeight()));
   } else 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");
   }
   return ((DrawFrame) canvas.getFrame().getFrame())
       .addDataset(
           name,
           function,
           interpreterState,
           plotArea,
           new ChartColor(color.get(0), color.get(1), color.get(2)));
 }
Beispiel #7
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");
    }
  }
Beispiel #8
0
 @Override
 public void exportCanvas(Canvas canvas, String path) throws FileNotWritableException {
   BufferedImage image =
       new BufferedImage(
           canvas.getFrame().getFrame().getWidth(),
           canvas.getFrame().getFrame().getHeight(),
           BufferedImage.TYPE_INT_RGB);
   Graphics2D graphics2D = image.createGraphics();
   canvas.getFrame().getFrame().paint(graphics2D);
   try {
     ImageIO.write(image, "png", new File(path + ".png"));
   } catch (IOException except) {
     throw new FileNotWritableException("write couldnt be completed", except);
   }
 }
Beispiel #9
0
 @Override
 public Chart addBoxChart(Canvas canvas, List<List<Double>> values, List<String> categories)
     throws IllegalRedefinitionException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.DRAW_FRAME) {
     throw new IllegalRedefinitionException(
         "This canvas is defined for graphs. Create a new canvas to draw charts");
   }
   if (canvas.getFrame().getFrameType() == FrameWrapper.BAR_FRAME
       || canvas.getFrame().getFrameType() == FrameWrapper.PIE_FRAME) {
     throw new IllegalRedefinitionException(
         "This canvas is defined for BoxCharts. Create a new canvas to draw another type of charts");
   }
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     canvas
         .getFrame()
         .setFrame(
             new BoxFrame(
                 canvas.getTitle(), canvas.getFrame().getWidth(), canvas.getFrame().getHeight()));
     canvas.getFrame().setFrameType(FrameWrapper.BOX_FRAME);
   }
   return ((BoxFrame) canvas.getFrame().getFrame())
       .addBoxChart(values, categories, "series" + canvas.getFrame().getFrame().getChartCount());
 }
Beispiel #10
0
 @Override
 public Graph addBullets(Canvas canvas, List<List<Double>> bullets, Double bulletSize)
     throws IllegalRedefinitionException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     canvas.getFrame().setFrameType(FrameWrapper.DRAW_FRAME);
     canvas
         .getFrame()
         .setFrame(
             new DrawFrame(
                 canvas.getTitle(), canvas.getFrame().getWidth(), canvas.getFrame().getHeight()));
   } else 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");
   }
   return ((DrawFrame) canvas.getFrame().getFrame())
       .addBulletDataset("Bullets", bullets, new ChartColor(0, 0, 0), bulletSize);
 }
Beispiel #11
0
 @Override
 public Graph addListGraph(
     Canvas canvas, List<List<Double>> function, String name, List<Integer> color)
     throws IllegalRedefinitionException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     canvas.getFrame().setFrameType(FrameWrapper.DRAW_FRAME);
     canvas
         .getFrame()
         .setFrame(
             new DrawFrame(
                 canvas.getTitle(), canvas.getFrame().getWidth(), canvas.getFrame().getHeight()));
   } else 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");
   }
   return ((DrawFrame) canvas.getFrame().getFrame())
       .addListDataset(
           name, function, false, new ChartColor(color.get(0), color.get(1), color.get(2)));
 }
Beispiel #12
0
 @Override
 public Graph addParamGraph(
     Canvas canvas,
     String xfunction,
     String yfunction,
     String name,
     State interpreterState,
     List<Double> limits)
     throws SetlException {
   if (canvas.getFrame().getFrameType() == FrameWrapper.VIRGIN_FRAME) {
     canvas.getFrame().setFrameType(FrameWrapper.DRAW_FRAME);
     canvas
         .getFrame()
         .setFrame(
             new DrawFrame(
                 canvas.getTitle(), canvas.getFrame().getWidth(), canvas.getFrame().getHeight()));
   } else 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");
   }
   return ((DrawFrame) canvas.getFrame().getFrame())
       .addParamDataset(
           name, xfunction, yfunction, interpreterState, false, new ChartColor(0, 0, 0), limits);
 }
Beispiel #13
0
 @Override
 public void labelAxis(Canvas canvas, String xLabel, String yLabel)
     throws IllegalRedefinitionException {
   canvas.getFrame().getFrame().setLabel(xLabel, yLabel);
 }
Beispiel #14
0
  @Override
  public void removeGraph(Canvas canvas, Value value) throws SetlException {

    canvas.getFrame().getFrame().removeGraph(value);
  }