Beispiel #1
0
 /**
  * Draws the axes in a drawing panel.
  *
  * @param panel
  * @param g
  */
 public void draw(DrawingPanel panel, Graphics g) {
   if (!visible) {
     return;
   }
   if (interiorColor != panel.getBackground()) {
     g.setColor(interiorColor);
     int gw = panel.getLeftGutter() + panel.getRightGutter();
     int gh = panel.getTopGutter() + panel.getLeftGutter();
     g.fillRect(
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel.getWidth() - gw,
         panel.getHeight() - gh);
     g.setColor(gridColor);
     g.drawRect(
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel.getWidth() - gw,
         panel.getHeight() - gh);
   }
   Iterator<Drawable> it = drawableList.iterator();
   while (it.hasNext()) {
     Drawable drawable = it.next();
     drawable.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);
 }
Beispiel #2
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);
 }
 /**
  * Paint the contour.
  *
  * @param g
  */
 public synchronized void draw(DrawingPanel panel, Graphics g) {
   if (!visible || (griddata == null)) {
     return;
   }
   if (!autoscaleZ) {
     g.setColor(colorMap.getFloorColor());
     int w = panel.getWidth() - panel.getLeftGutter() - panel.getRightGutter();
     int h = panel.getHeight() - panel.getTopGutter() - panel.getBottomGutter();
     g.fillRect(panel.getLeftGutter(), panel.getTopGutter(), Math.max(w, 0), Math.max(h, 0));
   }
   accumulator.clearAccumulator();
   contour_stepz = (zmax - zmin) / (contour_lines + 1);
   double z = zmin;
   for (int c = 0; c < contourColors.length; c++) {
     if (!autoscaleZ && (c == contourColors.length - 1)) {
       contourColors[c] = colorMap.getCeilColor();
     } else {
       contourColors[c] = colorMap.doubleToColor(z);
     }
     z += contour_stepz;
   }
   // double dx=griddata.getDx();
   // double dy=griddata.getDy();
   // double x = griddata.getLeft();
   double x = griddata.getLeft(), dx = (griddata.getRight() - griddata.getLeft()) / (nx - 1);
   double y = griddata.getTop(), dy = -(griddata.getTop() - griddata.getBottom()) / (ny - 1);
   for (int i = 0, mx = internalData.length - 1; i < mx; i++) {
     y = griddata.getTop();
     for (int j = 0, my = internalData[0].length - 1; j < my; j++) {
       contour_vertex[0][0] = x;
       contour_vertex[0][1] = y;
       contour_vertex[0][2] = internalData[i][j];
       contour_vertex[1][0] = x;
       contour_vertex[1][1] = y + dy;
       contour_vertex[1][2] = internalData[i][j + 1];
       contour_vertex[2][0] = x + dx;
       contour_vertex[2][1] = y + dy;
       contour_vertex[2][2] = internalData[i + 1][j + 1];
       contour_vertex[3][0] = x + dx;
       contour_vertex[3][1] = y;
       contour_vertex[3][2] = internalData[i + 1][j];
       createContour(panel, g);
       y += dy;
     }
     x += dx;
   }
   if (showContourLines) {
     g.setColor(lineColor);
     accumulator.drawAll(g);
     int lpix = panel.xToPix(griddata.getLeft());
     int tpix = panel.yToPix(griddata.getTop());
     int rpix = panel.xToPix(griddata.getRight());
     int bpix = panel.yToPix(griddata.getBottom());
     g.drawRect(
         Math.min(lpix, rpix), Math.min(tpix, bpix), Math.abs(lpix - rpix), Math.abs(tpix - bpix));
   }
 }
Beispiel #4
0
 /**
  * Draws the image and the grid.
  *
  * @param panel
  * @param g
  */
 public void draw(DrawingPanel panel, Graphics g) {
   if (scaleFactor < 1) {
     g.drawImage(
         image.getScaledInstance(
             (int) (scaleFactor * image.getWidth()),
             (int) (scaleFactor * image.getHeight()),
             java.awt.Image.SCALE_REPLICATE),
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel);
   } else {
     // g.drawImage(image, 1+panel.xToPix(xmin), 1+panel.yToPix(ymax), panel);
     g.drawImage(image, panel.getLeftGutter(), panel.getTopGutter(), panel);
   }
 }
Beispiel #5
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));
 }