/**
  * Draws the spokes for the polar plot.
  *
  * @param panel
  * @param g
  */
 protected void drawRAxis(double dr, double rmax, DrawingPanel panel, Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g.setColor(gridcolor.darker());
   int x1 = panel.xToPix(0);
   int y1 = panel.yToPix(0);
   int x2 = panel.xToPix(rmax);
   g.drawLine(x1, y1, Math.min(x2, panel.getWidth() - panel.getRightGutter()), y1);
   FontMetrics fm = g2.getFontMetrics();
   int nLabels = (int) (panel.getXMax() / dr / MAJOR_TIC);
   int stride = (nLabels > 3) ? 2 : 1;
   double rm = Math.min(rmax, panel.getXMax());
   for (double r = (nLabels > 3) ? stride * MAJOR_TIC * dr : MAJOR_TIC * dr;
       r <= rm;
       r += (stride * MAJOR_TIC * dr)) {
     String label = getLabel(r);
     int sW = fm.stringWidth(label) + 4;
     int sH = fm.getHeight();
     g2.setColor(new Color(247, 247, 247));
     int x0 = panel.xToPix(r), y0 = panel.yToPix(0);
     g2.fill(new Rectangle2D.Double(x0 - sW / 2, y0 + 3, sW, sH));
     g2.setColor(Color.black);
     g2.draw(new Rectangle2D.Double(x0 - sW / 2, y0 + 3, sW, sH));
     g2.setColor(Color.BLACK);
     g2.drawString(label, x0 - sW / 2 + 2, y0 + 1 + sH);
   }
 }
Esempio n. 2
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);
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
 public void centerAxes(DrawingPanel panel) {
   xaxis.setLocation((panel.getYMax() + panel.getYMin()) / 2);
   yaxis.setLocation((panel.getXMax() + panel.getXMin()) / 2);
 }