1 package org.catacomb.dataview.gui; 2 3 import org.catacomb.dataview.display.ViewConfig; 4 import org.catacomb.dataview.formats.DataHandler; 5 import org.catacomb.druid.gui.base.DruDataDisplay; 6 import org.catacomb.druid.gui.edit.DruListPanel; 7 import org.catacomb.interlish.annotation.IOPoint; 8 import org.catacomb.interlish.structure.Controller; 9 import org.catacomb.report.E; 10 11 import java.awt.image.BufferedImage; 12 13 public class DViewPlotController implements Controller { 14 15 @IOPoint(xid="dataDisplay") 16 public DruDataDisplay dataDisplay; 17 18 @IOPoint(xid="plots") 19 public DruListPanel plotsList; 20 21 private DataHandler dataHandler; 22 23 24 25 public DViewPlotController() { 26 27 } 28 29 30 31 public void setDataHandler(DataHandler dh) { 32 dataHandler = dh; 33 dataDisplay.attachGraphicsController(dh); 34 35 dataDisplay.setXAxisLabel(dh.getXAxisLabel()); 36 dataDisplay.setYAxisLabel(dh.getYAxisLabel()); 37 38 39 plotsList.setItems(dh.getPlotNames()); 40 repaint(); 41 } 42 43 44 public void showPlot(String s) { 45 dataHandler.setPlot(s); 46 ViewConfig vc = dataHandler.getViewConfig(s); 47 if (vc == null) { 48 E.warning("no such view " + vc); 49 } else { 50 dataDisplay.setLimits(vc.getLimits()); 51 } 52 } 53 54 55 public void attached() { 56 repaint(); 57 58 } 59 60 61 62 public void repaint() { 63 dataDisplay.repaint(); 64 65 } 66 67 68 69 public void setViewSize(int w, int h) { 70 dataDisplay.setSize(w, h); 71 72 } 73 74 75 76 public BufferedImage getSnapshot() { 77 return dataDisplay.getSnapshot(); 78 } 79 80 }