org.math.plot.plotObjects.Axis Class Reference

Inheritance diagram for org.math.plot.plotObjects.Axis:

org.math.plot.plotObjects.Plotable org.math.plot.plotObjects.BaseDependant org.math.plot.plotObjects.Editable List of all members.

Detailed Description

Class use to describe one of the axis of a plot object.

BSD License

Author:
Yann RICHET

Definition at line 25 of file Axis.java.

Public Member Functions

 Axis (Base b, String aS, Color c, int i)
void setVisible (boolean v)
boolean getVisible ()
HashMap< String, Double > getStringMap ()
void setStringMap (HashMap< String, Double > stringMap)
void setGridVisible (boolean v)
void setColor (Color c)
Color getColor ()
void setLegend (String _label)
String getLegend ()
double[] getLegendCoord ()
void plot (AbstractDrawer draw)
void init ()
void resetBase ()
void setEnd (double[] _end)
void setOrigin (double[] _origin)
void setLightLabels ()
void setLightLabelText (String[] _lightLabelnames)
void setLightLabelFont (Font f)
void setLightLabelAngle (double angle)
void setLabelText (String _t)
void setLabelFont (Font f)
void setLabelAngle (double angle)
void setLabelPosition (double..._p)
void edit (Object plotCanvas)
double[] isSelected (int[] screenCoordTest, AbstractDrawer draw)
void editnote (AbstractDrawer draw)

Static Public Member Functions

static void main (String[] args)

Protected Attributes

HashMap< String, Double > stringMap
int linear_slicing = 10
int note_precision = 5
int index
Base base
Color color
String label
double[] linesSlicing
double[] labelsSlicing
double[] origin
double[] end
BaseLine darkLine
Line[][] lightLines
BaseLabel darkLabel
Label[] lightLabels
Font lightLabelFont = AbstractDrawer.DEFAULT_FONT
Font darkLabelFont = AbstractDrawer.DEFAULT_FONT
double lightLabelAngle = 0
double darkLabelAngle = 0
String[] lightLabelNames
double lightLabels_base_offset = 0.05
double[] darkLabel_base_position

Package Attributes

boolean visible = true
boolean gridVisible = true


Member Function Documentation

void org.math.plot.plotObjects.Axis.setVisible ( boolean  v  ) 

Sets the visibility of the whole axis object.

Parameters:
v Visible if true.

Implements org.math.plot.plotObjects.Plotable.

Definition at line 115 of file Axis.java.

References org.math.plot.plotObjects.Axis.visible.

Referenced by org.math.plot.plotObjects.BasePlot.setVisible().

00115                                           {
00116                 visible = v;
00117         }

boolean org.math.plot.plotObjects.Axis.getVisible (  ) 

Returns the visibility of the whole axis object.

Returns:
Visible if true.

Implements org.math.plot.plotObjects.Plotable.

Definition at line 124 of file Axis.java.

References org.math.plot.plotObjects.Axis.visible.

00124                                     {
00125                 return visible;
00126         }

HashMap<String, Double> org.math.plot.plotObjects.Axis.getStringMap (  ) 

Returns the mapping of the data on this axis, which is the association between values along this axis as String and double numbers.

Returns:
Mapping of the data on this axis.

Definition at line 134 of file Axis.java.

References org.math.plot.plotObjects.Axis.stringMap.

Referenced by org.math.plot.plotObjects.Axis.main(), and org.math.plot.canvas.PlotCanvas.mapData().

00134                                                       {
00135                 return stringMap;
00136         }

void org.math.plot.plotObjects.Axis.setStringMap ( HashMap< String, Double >  stringMap  ) 

Returns the mapping of the data on this axis, which is the association between values along this axis as String and double numbers.

Parameters:
stringMap Mapping of the data on this axis.

Definition at line 145 of file Axis.java.

Referenced by org.math.plot.canvas.PlotCanvas.mapData(), and org.math.plot.canvas.PlotCanvas.resetMapData().

00145                                                                     {
00146                 // System.out.println(Array.toString(this.stringMap)+"
00147                 // >>\n"+Array.toString(stringMap));
00148                 this.stringMap = stringMap;
00149         }

void org.math.plot.plotObjects.Axis.setGridVisible ( boolean  v  ) 

Sets the visibility of the light lines and their labels.

Parameters:
v Visible if true.

Definition at line 157 of file Axis.java.

References org.math.plot.plotObjects.Axis.gridVisible.

Referenced by org.math.plot.plotObjects.BasePlot.setGridVisible().

00157                                               {
00158                 gridVisible = v;
00159         }

void org.math.plot.plotObjects.Axis.setColor ( Color  c  ) 

Sets the color used to display the axis' label.

Parameters:
c The color of the axis' label.

Implements org.math.plot.plotObjects.Plotable.

Definition at line 167 of file Axis.java.

References org.math.plot.plotObjects.Axis.color, org.math.plot.plotObjects.Axis.darkLabel, and org.math.plot.plotObjects.Label.setColor().

00167                                       {
00168                 color = c;
00169                 darkLabel.setColor(color);
00170         }

Color org.math.plot.plotObjects.Axis.getColor (  ) 

Returns the color of the axis' label.

Returns:
The color of the axis' label.

Implements org.math.plot.plotObjects.Plotable.

Definition at line 177 of file Axis.java.

References org.math.plot.plotObjects.Axis.color.

00177                                 {
00178                 return color;
00179         }

void org.math.plot.plotObjects.Axis.setLegend ( String  _label  ) 

Sets the label of this axis.

Parameters:
_label The label to be given to the axis.

Definition at line 187 of file Axis.java.

References org.math.plot.plotObjects.Axis.darkLabel, org.math.plot.plotObjects.Axis.label, and org.math.plot.plotObjects.Label.setText().

Referenced by org.math.plot.plotObjects.Axis.edit(), and org.math.plot.plotObjects.BasePlot.setLegend().

00187                                              {
00188                 label = _label;
00189                 darkLabel.setText(label);
00190         }

String org.math.plot.plotObjects.Axis.getLegend (  ) 

Returns the label of the axis.

Returns:
The label of the axis.

Definition at line 197 of file Axis.java.

References org.math.plot.plotObjects.Axis.label.

Referenced by org.math.plot.plotObjects.BasePlot.getLegend().

00197                                   {
00198                 return label;
00199         }

double [] org.math.plot.plotObjects.Axis.getLegendCoord (  ) 

Returns the coordinates of the axis label, in the referential of the canvas it is drawn in.

Returns:
An array of double (of length 2 or 3 if the dimension of the canvas is 2D or 3D) containing the coordinates.

Definition at line 208 of file Axis.java.

References org.math.plot.plotObjects.Label.coord, and org.math.plot.plotObjects.Axis.darkLabel.

00208                                          {
00209                 return darkLabel.coord;
00210         }

void org.math.plot.plotObjects.Axis.init (  ) 

Sets the axis to its default initial value.

Definition at line 240 of file Axis.java.

References org.math.plot.plotObjects.Axis.gridVisible, and org.math.plot.plotObjects.Axis.setLightLabels().

Referenced by org.math.plot.plotObjects.Axis.Axis(), org.math.plot.canvas.PlotCanvas.mapData(), and org.math.plot.plotObjects.Axis.resetBase().

00240                            {
00241                 // System.out.println("Axe.init");
00242                 initOriginEnd();
00243                 setSlicing();
00244 
00245                 // initDarkLines();
00246                 // initDarkLabels();
00247                 if (gridVisible) {
00248                         setLightLines();
00249                         setLightLabels();
00250                 }
00251         }

void org.math.plot.plotObjects.Axis.resetBase (  ) 

Resets the axis to its default value. Same as init().

Implements org.math.plot.plotObjects.BaseDependant.

Definition at line 256 of file Axis.java.

References org.math.plot.plotObjects.Axis.init().

Referenced by org.math.plot.plotObjects.Axis.setEnd(), and org.math.plot.plotObjects.Axis.setOrigin().

00256                                 {
00257                 // System.out.println("Axe.resetBase");
00258                 init();
00259         }

void org.math.plot.plotObjects.Axis.setEnd ( double[]  _end  ) 

Problem here?

Parameters:
_end 

Definition at line 266 of file Axis.java.

References org.math.plot.plotObjects.Axis.end, and org.math.plot.plotObjects.Axis.resetBase().

00266                                           {
00267                 end = _end;
00268                 resetBase();
00269         }

void org.math.plot.plotObjects.Axis.setLightLabels (  ) 

When called out of the axis class, resets the light labels to their default value.

Definition at line 280 of file Axis.java.

References org.math.plot.plotObjects.Axis.base, org.math.plot.plotObjects.Base.dimension, org.math.plot.plotObjects.Base.getAxeScale(), org.math.plot.plotObjects.Base.getCoords(), org.math.plot.plotObjects.Base.getPrecisionUnit(), org.math.plot.plotObjects.Axis.index, org.math.plot.plotObjects.Axis.labelsSlicing, org.math.plot.plotObjects.Axis.lightLabelAngle, org.math.plot.plotObjects.Axis.lightLabelFont, org.math.plot.plotObjects.Axis.lightLabelNames, org.math.plot.plotObjects.Axis.lightLabels, and org.math.plot.plotObjects.Axis.lightLabels_base_offset.

Referenced by org.math.plot.plotObjects.Axis.init(), org.math.plot.plotObjects.Axis.setLightLabelAngle(), org.math.plot.plotObjects.Axis.setLightLabelFont(), and org.math.plot.plotObjects.Axis.setLightLabelText().

00280                                      {
00281                 // System.out.println(" s setLightLabels");
00282                 // offset of lightLabels
00283                 double[] labelOffset = new double[base.dimension];
00284                 for (int j = 0; j < base.dimension; j++) {
00285                         if (j != index) {
00286                                 labelOffset[j] = -lightLabels_base_offset;
00287                         }
00288                 }
00289                 // local variables initialisation
00290                 int decimal = 0;
00291                 String lab;
00292 
00293                 lightLabels = new Label[labelsSlicing.length];
00294 
00295                 for (int i = 0; i < lightLabels.length; i++) {
00296 
00297                         double[] labelCoord = new double[base.dimension];
00298                         System.arraycopy(base.getCoords()[index + 1], 0, labelCoord, 0,
00299                                         base.dimension);
00300                         labelCoord[index] = labelsSlicing[i];
00301 
00302                         if (base.getAxeScale(index).startsWith(Base.LINEAR)
00303                                         || base.getAxeScale(index).startsWith(Base.STRINGS)) {
00304                                 decimal = -(int) (log(base.getPrecisionUnit()[index] / 100) / log(10));
00305                         } else if (base.getAxeScale(index).startsWith(Base.LOGARITHM)) {
00306                                 decimal = -(int) (floor(log(labelsSlicing[i]) / log(10)));
00307                         }
00308                         if (lightLabelNames != null) {
00309                                 lab = lightLabelNames[i % lightLabelNames.length];
00310                         } else {
00311                                 lab = new String(Label.approx(labelsSlicing[i], decimal) + "");
00312                         }
00313                         // System.out.println(Array.toString(labelCoord) + " -> " + lab);
00314                         lightLabels[i] = new Label(lab, Color.lightGray, labelCoord);
00315                         lightLabels[i].base_offset = labelOffset;
00316 
00317                         if (lightLabelAngle != 0) {
00318                                 lightLabels[i].rotate(lightLabelAngle);
00319                         }
00320                         if (lightLabelFont != null) {
00321                                 lightLabels[i].setFont(lightLabelFont);
00322                         }
00323                 } // end for
00324                 lightLabelNames = null;
00325         }

void org.math.plot.plotObjects.Axis.setLightLabelText ( String[]  _lightLabelnames  ) 

Sets the labels of the light lines. Is the numerical graduation by default.

Parameters:
_lightLabelnames Array of string containing the labels. When the end of the array is reached for one tick, the following tick starts with the beginning of the array again.

Definition at line 336 of file Axis.java.

References org.math.plot.plotObjects.Axis.lightLabelNames, and org.math.plot.plotObjects.Axis.setLightLabels().

00336                                                                  {
00337                 lightLabelNames = _lightLabelnames;
00338                 setLightLabels(); // resetBase();
00339         }

void org.math.plot.plotObjects.Axis.setLightLabelFont ( Font  f  ) 

Sets the font used for the light labels.

Parameters:
f Font to use.

Definition at line 347 of file Axis.java.

References org.math.plot.plotObjects.Axis.lightLabelFont, and org.math.plot.plotObjects.Axis.setLightLabels().

00347                                               {
00348                 lightLabelFont = f;
00349                 setLightLabels(); // resetBase();
00350         }

void org.math.plot.plotObjects.Axis.setLightLabelAngle ( double  angle  ) 

Sets the angle with which the light labels will be displayed.

Parameters:
angle Angle in degrees, measured clockwise.

Definition at line 358 of file Axis.java.

References org.math.plot.plotObjects.Axis.lightLabelAngle, and org.math.plot.plotObjects.Axis.setLightLabels().

00358                                                      {
00359                 lightLabelAngle = angle;
00360                 setLightLabels(); // resetBase();
00361         }

void org.math.plot.plotObjects.Axis.setLabelText ( String  _t  ) 

Specifies the label of the axis.

Parameters:
_t Label to add to the axis.

Definition at line 369 of file Axis.java.

References org.math.plot.plotObjects.Axis.darkLabel, and org.math.plot.plotObjects.Label.label.

00369                                             {
00370                 darkLabel.label = _t;
00371         }

void org.math.plot.plotObjects.Axis.setLabelFont ( Font  f  ) 

Sets the font used to display the label.

Parameters:
f Font to use.

Definition at line 379 of file Axis.java.

References org.math.plot.plotObjects.Axis.darkLabel, org.math.plot.plotObjects.Axis.darkLabelFont, and org.math.plot.plotObjects.Label.setFont().

00379                                          {
00380                 darkLabelFont = f;
00381                 darkLabel.setFont(darkLabelFont);
00382         }

void org.math.plot.plotObjects.Axis.setLabelAngle ( double  angle  ) 

Sets the angle with which the label will be displayed.

Parameters:
angle Angle in degrees, measured clockwise.

Definition at line 390 of file Axis.java.

References org.math.plot.plotObjects.Label.angle, org.math.plot.plotObjects.Axis.darkLabel, and org.math.plot.plotObjects.Axis.darkLabelAngle.

00390                                                 {
00391                 darkLabelAngle = angle;
00392                 darkLabel.angle = darkLabelAngle;
00393         }

void org.math.plot.plotObjects.Axis.setLabelPosition ( double...  _p  ) 

Sets the position of the axis label on the panel.

Parameters:
_p Position of the label.

Definition at line 401 of file Axis.java.

References org.math.plot.plotObjects.Label.coord, org.math.plot.plotObjects.Axis.darkLabel, and org.math.plot.plotObjects.Axis.darkLabel_base_position.

00401                                                    {
00402                 darkLabel_base_position = _p;
00403                 darkLabel.coord = darkLabel_base_position;
00404         }

void org.math.plot.plotObjects.Axis.edit ( Object  plotCanvas  ) 

Opens a dialog window and asks the user for the name of this axis.

Parameters:
plotCanvas The parent window on which the dialog should be displayed.

Implements org.math.plot.plotObjects.Editable.

Definition at line 412 of file Axis.java.

References org.math.plot.plotObjects.Axis.label, and org.math.plot.plotObjects.Axis.setLegend().

Referenced by org.math.plot.canvas.PlotCanvas.mouseClicked().

00412                                             {
00413                 // TODO add other changes possible
00414                 String _label = JOptionPane.showInputDialog((PlotCanvas) plotCanvas,
00415                                 "Choose axis label", label);
00416                 if (_label != null) {
00417                         setLegend(_label);
00418                 }
00419         }

double [] org.math.plot.plotObjects.Axis.isSelected ( int[]  screenCoordTest,
AbstractDrawer  draw 
)

Parameters:
screenCoordTest 
draw 
Returns:

Implements org.math.plot.plotObjects.Editable.

Definition at line 427 of file Axis.java.

References org.math.plot.plotObjects.Label.coord, org.math.plot.plotObjects.Axis.darkLabel, org.math.plot.plotObjects.Axis.note_precision, and org.math.plot.render.AbstractDrawer.project().

Referenced by org.math.plot.canvas.PlotCanvas.mouseClicked().

00427                                                                                {
00428 
00429                 int[] screenCoord = draw.project(darkLabel.coord);
00430 
00431                 if ((screenCoord[0] + note_precision > screenCoordTest[0])
00432                                 && (screenCoord[0] - note_precision < screenCoordTest[0])
00433                                 && (screenCoord[1] + note_precision > screenCoordTest[1])
00434                                 && (screenCoord[1] - note_precision < screenCoordTest[1])) {
00435                         return darkLabel.coord;
00436                 }
00437                 return null;
00438         }

void org.math.plot.plotObjects.Axis.editnote ( AbstractDrawer  draw  ) 

Parameters:
draw 

Implements org.math.plot.plotObjects.Editable.

Definition at line 444 of file Axis.java.

References org.math.plot.plotObjects.Axis.darkLabel, org.math.plot.plotObjects.Axis.darkLabelFont, org.math.plot.plotObjects.BaseLabel.plot(), and org.math.plot.plotObjects.Label.setFont().

00444                                                   {
00445                 darkLabel.setFont(darkLabelFont.deriveFont(Font.BOLD));
00446                 darkLabel.plot(draw);
00447                 darkLabel.setFont(darkLabelFont.deriveFont(Font.PLAIN));
00448         }


Member Data Documentation

HashMap<String, Double> org.math.plot.plotObjects.Axis.stringMap [protected]

Mapping of the data on this axis, which is the association between values along this axis as String and double numbers.

Definition at line 31 of file Axis.java.

Referenced by org.math.plot.plotObjects.Axis.getStringMap().

boolean org.math.plot.plotObjects.Axis.visible = true [package]

Visibility of the whole axis

Definition at line 44 of file Axis.java.

Referenced by org.math.plot.plotObjects.Axis.getVisible(), org.math.plot.plotObjects.Axis.plot(), and org.math.plot.plotObjects.Axis.setVisible().

Color org.math.plot.plotObjects.Axis.color [protected]

Color in which the name of the axis is displayed.

Definition at line 49 of file Axis.java.

Referenced by org.math.plot.plotObjects.Axis.Axis(), org.math.plot.plotObjects.Axis.getColor(), and org.math.plot.plotObjects.Axis.setColor().

String org.math.plot.plotObjects.Axis.label [protected]

Axis label

Definition at line 54 of file Axis.java.

Referenced by org.math.plot.plotObjects.Axis.Axis(), org.math.plot.plotObjects.Axis.edit(), org.math.plot.plotObjects.Axis.getLegend(), and org.math.plot.plotObjects.Axis.setLegend().

boolean org.math.plot.plotObjects.Axis.gridVisible = true [package]

Visibility of the grid.

Definition at line 59 of file Axis.java.

Referenced by org.math.plot.plotObjects.Axis.init(), org.math.plot.plotObjects.Axis.plot(), and org.math.plot.plotObjects.Axis.setGridVisible().


The documentation for this class was generated from the following file:
Generated on Wed Sep 5 21:44:02 2007 for jmathplot by  doxygen 1.5.1