1 19 package jcckit.plot; 20 21 import jcckit.data.DataPlot; 22 import jcckit.graphic.Anchor; 23 import jcckit.graphic.ClippingRectangle; 24 import jcckit.util.ConfigParameters; 25 26 34 public class PlotCanvas implements PlotListener { 35 36 public static final String PAPER_KEY = "paper", 37 HORIZONTAL_ANCHOR_KEY = "horizontalAnchor", 38 VERTICAL_ANCHOR_KEY = "verticalAnchor", 39 PLOT_KEY = "plot"; 40 private final ClippingRectangle _paper; 41 private final Anchor _horizontalAnchor; 42 private final Anchor _verticalAnchor; 43 private final Plot _plot; 44 45 74 public PlotCanvas(ConfigParameters config) { 75 double[] paper = config.getDoubleArray(PAPER_KEY, 76 new double[] {0, 0, 1, 0.6}); 77 _paper = new ClippingRectangle(paper[0], paper[1], paper[2], paper[3]); 78 _horizontalAnchor = Anchor.getHorizontalAnchor(config, 79 HORIZONTAL_ANCHOR_KEY, Anchor.CENTER); 80 _verticalAnchor = Anchor.getVerticalAnchor(config, 81 VERTICAL_ANCHOR_KEY, Anchor.CENTER); 82 _plot = new Plot(config.getNode(PLOT_KEY)); 83 _plot.addPlotListener(this); 84 } 85 86 87 public ClippingRectangle getPaper() { 88 return _paper; 89 } 90 91 92 public Anchor getHorizontalAnchor() { 93 return _horizontalAnchor; 94 } 95 96 97 public Anchor getVerticalAnchor() { 98 return _verticalAnchor; 99 } 100 101 102 public Plot getPlot() { 103 return _plot; 104 } 105 106 113 public void connect(DataPlot dataPlot) { 114 _plot.connect(dataPlot); 115 } 116 117 121 public void plotChanged(PlotEvent event) {} 122 } 123 | Popular Tags |