DelegatingGraphicContext.java

  1. package de.slothsoft.charts.internal;

  2. import java.util.Objects;

  3. import de.slothsoft.charts.Area;
  4. import de.slothsoft.charts.Font;
  5. import de.slothsoft.charts.GraphicContext;

  6. /**
  7.  * This is a {@link GraphicContext} that only delegates to another one. Used to override
  8.  * only one method.
  9.  *
  10.  * @author Stef Schulz
  11.  * @since 0.1.0
  12.  */

  13. public class DelegatingGraphicContext implements GraphicContext {

  14.     private final GraphicContext delegate;

  15.     public DelegatingGraphicContext(GraphicContext delegate) {
  16.         this.delegate = Objects.requireNonNull(delegate);
  17.     }

  18.     @Override
  19.     public void setColor(int backgroundColor) {
  20.         this.delegate.setColor(backgroundColor);
  21.     }

  22.     @Override
  23.     public int getColor() {
  24.         return this.delegate.getColor();
  25.     }

  26.     @Override
  27.     public void setFont(Font font) {
  28.         this.delegate.setFont(font);
  29.     }

  30.     @Override
  31.     public Font getFont() {
  32.         return this.delegate.getFont();
  33.     }

  34.     @Override
  35.     public void translate(double x, double y) {
  36.         this.delegate.translate(x, y);
  37.     }

  38.     @Override
  39.     public void scale(double factor) {
  40.         this.delegate.scale(factor);
  41.     }

  42.     @Override
  43.     public void scale(double x, double y) {
  44.         this.delegate.scale(x, y);
  45.     }

  46.     @Override
  47.     public void clip(Area rect) {
  48.         this.delegate.clip(rect);
  49.     }

  50.     @Override
  51.     public void drawLine(double x1, double y1, double x2, double y2) {
  52.         this.delegate.drawLine(x1, y1, x2, y2);
  53.     }

  54.     @Override
  55.     public void fillRectangle(double x, double y, double width, double height) {
  56.         this.delegate.fillRectangle(x, y, width, height);
  57.     }

  58.     @Override
  59.     public void drawPolyline(double[] x, double[] y) {
  60.         this.delegate.drawPolyline(x, y);
  61.     }

  62.     @Override
  63.     public void fillPolygon(double[] x, double[] y) {
  64.         this.delegate.fillPolygon(x, y);
  65.     }

  66.     @Override
  67.     public void drawText(double x, double y, String text) {
  68.         this.delegate.drawText(x, y, text);
  69.     }

  70.     @Override
  71.     public void fillOval(double x, double y, double width, double height) {
  72.         this.delegate.fillOval(x, y, width, height);
  73.     }

  74.     @Override
  75.     public void fillArc(double x, double y, double width, double height, double startAngle, double arcAngle) {
  76.         this.delegate.fillArc(x, y, width, height, startAngle, arcAngle);
  77.     }

  78.     @Override
  79.     public Area calculateTextSize(String text) {
  80.         return this.delegate.calculateTextSize(text);
  81.     }
  82. }