Ejemplo n.º 1
0
 /**
  * Sets the x axis to linear or logarithmic.
  *
  * @param isLog true for log scale; false otherwise
  */
 public void setXLog(boolean isLog) {
   xlog = isLog; // Added by Paco
   if (isLog) {
     xaxis.setAxisType(XYAxis.LOG10);
   } else {
     xaxis.setAxisType(XYAxis.LINEAR);
   }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix) {
   if (!visible) {
     return null;
   }
   if (xaxis.findInteractive(panel, xpix, ypix) != null) {
     return xaxis;
   } else if (yaxis.findInteractive(panel, xpix, ypix) != null) {
     return yaxis;
   } else {
     return null;
   }
 }
Ejemplo n.º 4
0
 /**
  * Constructs the XYAxes inside the drawing panel.
  *
  * <p>Drawing panel gutters are set to 30, 30, 30, 30.
  *
  * @param panel the drawing panel that will use the axes
  */
 public CartesianType3(PlottingPanel panel) {
   super(panel);
   defaultLeftGutter = 30;
   defaultTopGutter = 30;
   defaultRightGutter = 30;
   defaultBottomGutter = 30;
   titleLine.setJustification(TextLine.CENTER);
   titleLine.setFont(titleFont);
   xaxis = new XAxis();
   yaxis = new YAxis();
   xaxis.setEnabled(true); // enable dragging
   xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
   yaxis.setEnabled(true);
   yaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
   if (panel == null) {
     return;
   }
   panel.setCoordinateStringBuilder(CoordinateStringBuilder.createCartesian());
   panel.setPreferredGutters(
       defaultLeftGutter, defaultTopGutter, defaultRightGutter, defaultBottomGutter);
   panel.setAxes(this);
 }
Ejemplo n.º 5
0
 /**
  * Sets the x label of the axes. The font names understood are those understood by
  * java.awt.Font.decode(). If the font name is null, the font remains unchanged.
  *
  * @param s the title
  * @param font_name an optional font name
  */
 public void setXLabel(String s, String font_name) {
   xaxis.setTitle(s, font_name);
 }
Ejemplo n.º 6
0
 public void setY(double y) {
   xaxis.setLocation(y); // Added by Paco
 }
Ejemplo n.º 7
0
 public void setXY(double x, double y) {
   xaxis.setLocation(y); // Added by Paco
   yaxis.setLocation(x); // Added by Paco
 }
Ejemplo n.º 8
0
 public void centerAxes(DrawingPanel panel) {
   xaxis.setLocation((panel.getYMax() + panel.getYMin()) / 2);
   yaxis.setLocation((panel.getXMax() + panel.getXMin()) / 2);
 }
Ejemplo n.º 9
0
 /** Shows a grid line for every x axis major tickmark. */
 public void setShowMajorXGrid(boolean showGrid) {
   xaxis.setShowMajorGrid(showGrid);
   if (!showGrid) {
     setShowMinorXGrid(showGrid);
   }
 }