예제 #1
0
 /**
  * Draws the axes in the drawing panel.
  *
  * @param panel
  * @param g
  */
 public void draw(DrawingPanel panel, Graphics g) {
   if (!visible) {
     return;
   }
   if (interiorColor != null) {
     g.setColor(interiorColor);
     int gw = panel.getLeftGutter() + panel.getRightGutter();
     int gh = panel.getTopGutter() + panel.getBottomGutter();
     g.fillRect(
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel.getWidth() - gw,
         panel.getHeight() - gh);
     g.setColor(Color.lightGray);
     g.drawRect(
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel.getWidth() - gw,
         panel.getHeight() - gh);
   }
   xaxis.draw(panel, g);
   yaxis.draw(panel, g);
   titleLine.setX((panel.getXMax() + panel.getXMin()) / 2);
   if (panel.getTopGutter() > 20) {
     titleLine.setY(panel.getYMax() + 5 / panel.getYPixPerUnit());
   } else {
     titleLine.setY(panel.getYMax() - 25 / panel.getYPixPerUnit());
   }
   titleLine.draw(panel, g);
 }
예제 #2
0
 /**
  * Gets the dimension of the lattice in pixel units.
  *
  * @param panel
  * @return the dimension
  */
 public Dimension getInterior(DrawingPanel panel) {
   float availableWidth = panel.getWidth() - panel.getLeftGutter() - panel.getRightGutter() - 1;
   float availableHeight = panel.getHeight() - panel.getTopGutter() - panel.getBottomGutter() - 1;
   scaleFactor = Math.min(availableWidth / dimension.width, availableHeight / dimension.height);
   if (scaleFactor > 1) {
     scaleFactor = 1;
     return dimension;
   }
   return new Dimension((int) (scaleFactor * ncol), (int) (scaleFactor * nrow));
 }