コード例 #1
0
 /**
  * Sets the y axis to linear or logarithmic.
  *
  * @param isLog true for log scale; false otherwise
  */
 public void setYLog(boolean isLog) {
   ylog = isLog; // Added by Paco
   if (isLog) {
     yaxis.setAxisType(XYAxis.LOG10);
   } else {
     yaxis.setAxisType(XYAxis.LINEAR);
   }
 }
コード例 #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);
 }
コード例 #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;
   }
 }
コード例 #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);
 }
コード例 #5
0
 /**
  * Sets the y 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 setYLabel(String s, String font_name) {
   yaxis.setTitle(s, font_name);
 }
コード例 #6
0
 public void setX(double x) {
   yaxis.setLocation(x); // Added by Paco
 }
コード例 #7
0
 public void setXY(double x, double y) {
   xaxis.setLocation(y); // Added by Paco
   yaxis.setLocation(x); // Added by Paco
 }
コード例 #8
0
 public void centerAxes(DrawingPanel panel) {
   xaxis.setLocation((panel.getYMax() + panel.getYMin()) / 2);
   yaxis.setLocation((panel.getXMax() + panel.getXMin()) / 2);
 }
コード例 #9
0
 /** Shows a grid line for every y axis major tickmark. */
 public void setShowMajorYGrid(boolean showGrid) {
   yaxis.setShowMajorGrid(showGrid);
   if (!showGrid) {
     setShowMinorYGrid(showGrid);
   }
 }