|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component net.sourceforge.webcompmath.draw.Drawable net.sourceforge.webcompmath.draw.WcmAxes
public class WcmAxes
A set of horizontal and vertical axes that look OK and have reasonable, labeled tick marks. The number and spacing of tick marks changes depending on the scale on the axes in AUTO_TICKS mode. (The heuristics for computing this could use some improvement.)
In ABSOLUTE_TICKS and RATIONAL_TICKS mode, you explicitly specify the major and minor tick mark spacing. RATIONAL_TICKS in addition will try to convert the tick labels to rational numbers and display the labels as fractions (including factoring out multiples of pi or e).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
ABSOLUTE_TICKS
Explicitly specify the tick mark spacing |
static int |
AUTO_TICKS
Use automatic tick mark spacing |
static int |
BOTTOM
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axs. |
static int |
CENTER
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes. |
static int |
LEFT
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. |
static int |
NO_AXIS
Hide the axis |
static int |
NO_TICKS
Show no tick marks or labels |
static int |
RATIONAL_TICKS
Explicitly specify the tick mark spacing, and make the labels rationals (i.e., fractions) if possible |
static int |
RIGHT
A constant that can be used in the setXAxisPosition() method to indicate the placement of the x-axis. |
static int |
SMART
A constant that can be used in the setXAxisPosition() and setYAxisPosition() methods to indicate the placement of the axes. |
static int |
TICKS_AND_LABELS
Show both tick marks and labels (the default) |
static int |
TICKS_NO_LABELS
Show tick marks but not tick labels |
static int |
TOP
A constant that can be used in the setYAxisPosition() method to indicate the placement of the y-axis. |
Fields inherited from class net.sourceforge.webcompmath.draw.Drawable |
---|
canvas, coords |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
WcmAxes()
Creates axes with no names on the axes. |
|
WcmAxes(java.lang.String xLabel,
java.lang.String yLabel)
Construct a WcmAxes with the specified labels |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics g,
boolean coordsChanged)
Axes drawing |
boolean |
getAutoTicks()
Get whether autoticks is in use. |
int |
getAutoXTicks()
Get the style of x axis tick mark spacing. |
int |
getAutoYTicks()
Get the style of y axis tick mark spacing. |
java.awt.Color |
getAxesColor()
Get the color that is used for drawing the axes, when they are drawn in their true position. |
java.awt.Color |
getLabelColor()
Get the color that is used for drawing the labels on the x- and y-axes. |
java.awt.Color |
getLightAxesColor()
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position. |
double |
getMajorXTickSpacing()
Get the major tick spacing for the x axis |
float |
getMajorXTickWidth()
Get the width of major tick marks on the x axis. |
double |
getMajorYTickSpacing()
Get the major tick spacing for the y axis |
float |
getMajorYTickWidth()
Get the width of major tick marks on the y axis. |
double |
getMinorXTickSpacing()
Get the minor tick spacing for the x axis |
double |
getMinorYTickSpacing()
Get the minor tick spacing for the y axis |
boolean |
getPaintTicks()
Get whether ticks and labels are in use. |
int |
getStyleXAxis()
Get the style of the x axis. |
int |
getStyleYAxis()
Get the style of the y axis. |
java.awt.Color |
getTickColor()
Get the color used for ticks and tick labels |
java.awt.Color |
getXAxisColor()
Get the color for the x axis. |
int |
getXAxisPosition()
Get the positioning constant that tells where the x-axis is drawn. |
java.lang.String |
getXLabel()
Get the label that appears on the x-axis. |
java.awt.Color |
getXLabelColor()
Get the color for the x axis label. |
int |
getXLabelFontSize()
Get the x axis font size |
float |
getXLineWidth()
Get the line width for the x axis. |
java.awt.Color |
getXTickColor()
Get the color of tick marks and labels on the x axis. |
int |
getXTickFontSize()
Get the x axis tick label font size |
java.awt.Color |
getYAxisColor()
Get the color for the y axis |
int |
getYAxisPosition()
Get the positioning constant that tells where the y-axis is drawn. |
java.lang.String |
getYLabel()
Get the label that appears on the y-axis. |
java.awt.Color |
getYLabelColor()
Get the color for the y axis label. |
int |
getYLabelFontSize()
Get the y axis label font size |
float |
getYLineWidth()
Get the line width for the y axis. |
java.awt.Color |
getYTickColor()
Get the color of tick marks and labels on the y axis. |
int |
getYTickFontSize()
Get the y axis tick label font size |
boolean |
isRationalXText()
For rational labels, get whether to use text or typeset labels for the x axis. |
boolean |
isRationalYText()
For rational labels, get whether to use text or typeset labels for the y axis |
boolean |
isXAvoidOverlap()
Get whether or not x tick labels are allowed to overlap. |
boolean |
isXLabelsAbove()
Get whether to prefer x labels above the axis |
boolean |
isYAvoidOverlap()
Get whether or not y tick labels are allowed to overlap. |
boolean |
isYLabelsLeft()
Get whether to prefer y labels to the left of the axis |
void |
setAutoTicks(boolean b)
Set both axes to use AUTO_TICKS if true, ABSOLUTE_TICKS if false |
void |
setAutoXTicks(int choice)
Set the style of x axis tick mark spacing. |
void |
setAutoYTicks(int choice)
Set the style of y axis tick mark spacing. |
void |
setAxesColor(java.awt.Color c)
Set the color that is used for drawing the axes, when they are drawn in their true position. |
void |
setLabelColor(java.awt.Color c)
Set the color that is used for drawing the labels (usually the names of the variables) on both the x- and y-axes. |
void |
setLightAxesColor(java.awt.Color c)
Get the color that is used for drawing an axis, when it is drawn along an edge of the CoordinateRect instead of in its proper x- or y-position. |
void |
setLineWidth()
set default line width |
void |
setLineWidth(float thickness)
Set the width of the axes for both axes. |
void |
setMajorTickWidth(float thickness)
Set the major tick mark thickness. |
void |
setMajorXTickSpacing(double spacing)
Set the major tick spacing for the x axis |
void |
setMajorXTickWidth(float thickness)
Set the width of major tick marks on the x axis. |
void |
setMajorYTickSpacing(double spacing)
Set the major tick spacing for the y axis |
void |
setMajorYTickWidth(float thickness)
Set the width of major tick marks on the y axis. |
void |
setMinorXTickSpacing(double spacing)
Set the minor tick spacing for the x axis |
void |
setMinorYTickSpacing(double spacing)
Set the minor tick spacing for the y axis |
void |
setPaintTicks(boolean b)
Set the style for both axes |
void |
setRationalXText(boolean rationalText)
For rational labels, set whether to use text or typeset labels for the x axis. |
void |
setRationalYText(boolean rationalText)
For rational labels, set whether to use text or typeset labels for the y axis. |
void |
setStyleXAxis(int styleXAxis)
Set the style of the x axis. |
void |
setStyleYAxis(int styleYAxis)
Set the style of the y axis. |
void |
setTickColor(java.awt.Color tickColor)
Set the color used for ticks and tick labels on both axes. |
void |
setTickSpacing(double forX,
double forY,
double minorX,
double minorY)
Set all tick spacings at once. |
void |
setXAvoidOverlap(boolean avoidOverlap)
Set whether or not x tick labels are allowed to overlap. |
void |
setXAxisColor(java.awt.Color c)
Set the color for the x axis. |
void |
setXAxisPosition(int pos)
Set the positioning constant that tells where the x-axis is drawn. |
void |
setXLabel(java.lang.String s)
Set the label that appears on the x-axis. |
void |
setXLabelColor(java.awt.Color c)
Set the color for the x axis label. |
void |
setXLabelFontSize(int fs)
Set the font size for the x axis label |
void |
setXLabelsAbove(boolean labelsAbove)
Set whether to prefer x labels above the axis (default is true) |
void |
setXLineWidth(float thickness)
Set the line width for the x axis. |
void |
setXTickColor(java.awt.Color tickColor)
Set the color of tick marks and labels on the x axis. |
void |
setXTickFontSize(int fs)
Set the x axis tick label font size |
void |
setYAvoidOverlap(boolean avoidOverlap)
Set whether or not y tick labels are allowed to overlap. |
void |
setYAxisColor(java.awt.Color c)
Set the color for the y axis. |
void |
setYAxisPosition(int pos)
Set the positioning constant that tells where the y-axis is drawn. |
void |
setYLabel(java.lang.String s)
Set the label that appears on the y-axis. |
void |
setYLabelColor(java.awt.Color c)
Set the color for the y axis label. |
void |
setYLabelFontSize(int fs)
Set the y axis label font size |
void |
setYLabelsLeft(boolean labelsLeft)
Set whether to prefer y labels to the left of the axis (default is true) |
void |
setYLineWidth(float thickness)
Set the line width for the y axis. |
void |
setYTickColor(java.awt.Color tickColor)
Set the color of tick marks and labels on the y axis. |
void |
setYTickFontSize(int fs)
Set the y axis tick label font size |
Methods inherited from class net.sourceforge.webcompmath.draw.Drawable |
---|
getVisible, needsRedraw, setOwnerData, setVisible |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TOP
public static final int BOTTOM
public static final int LEFT
public static final int RIGHT
public static final int CENTER
public static final int SMART
public static final int AUTO_TICKS
public static final int ABSOLUTE_TICKS
public static final int RATIONAL_TICKS
public static final int NO_AXIS
public static final int NO_TICKS
public static final int TICKS_NO_LABELS
public static final int TICKS_AND_LABELS
Constructor Detail |
---|
public WcmAxes()
public WcmAxes(java.lang.String xLabel, java.lang.String yLabel)
xLabel
- the x-axis labelyLabel
- the y-axis labelMethod Detail |
---|
public int getXLabelFontSize()
public void setXLabelFontSize(int fs)
fs
- the new font sizepublic int getXTickFontSize()
public void setXTickFontSize(int fs)
fs
- The font size to set.public int getYLabelFontSize()
public void setYLabelFontSize(int fs)
fs
- The font size to set.public int getYTickFontSize()
public void setYTickFontSize(int fs)
fs
- The font sizze to set.public void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- contextcoordsChanged
- value if coordinates have changedpublic void setMajorXTickSpacing(double spacing)
spacing
- the new spacingpublic double getMajorXTickSpacing()
public void setMinorXTickSpacing(double spacing)
spacing
- the new spacingpublic double getMinorXTickSpacing()
public void setMajorYTickSpacing(double spacing)
spacing
- the new spacingpublic double getMajorYTickSpacing()
public void setMinorYTickSpacing(double spacing)
spacing
- the new spacingpublic double getMinorYTickSpacing()
public boolean isRationalXText()
public void setRationalXText(boolean rationalText)
rationalText
- true for text labels, false for typeset labels (default)public boolean isRationalYText()
public void setRationalYText(boolean rationalText)
rationalText
- true for text labels, false for typeset labels (default)public int getXAxisPosition()
public void setXAxisPosition(int pos)
pos
- TOP, BOTTOM, CENTER, or SMARTpublic int getYAxisPosition()
public void setYAxisPosition(int pos)
pos
- LEFT, RIGHT, CENTER, or SMARTpublic boolean isXLabelsAbove()
public void setXLabelsAbove(boolean labelsAbove)
labelsAbove
- The xLabelsAbove to set.public boolean isYLabelsLeft()
public void setYLabelsLeft(boolean labelsLeft)
labelsLeft
- The yLabelsLeft to set.public void setLineWidth()
public void setMajorTickWidth(float thickness)
thickness
- the new thicknesspublic void setLineWidth(float thickness)
thickness
- the thicknesspublic java.lang.String getXLabel()
public void setXLabel(java.lang.String s)
s
- x axis labelpublic java.lang.String getYLabel()
public void setYLabel(java.lang.String s)
s
- y axis labelpublic void setAutoXTicks(int choice)
choice
- AUTO_TICKS or ABSOLUTE_TICKS or RATIONAL_TICKSpublic int getAutoXTicks()
public void setAutoYTicks(int choice)
choice
- AUTO_TICKS or ABSOLUTE_TICKS or RATIONAL_TICKSpublic int getAutoYTicks()
public java.awt.Color getLightAxesColor()
public void setLightAxesColor(java.awt.Color c)
c
- axes colorpublic java.awt.Color getAxesColor()
public void setAxesColor(java.awt.Color c)
c
- axes colorpublic java.awt.Color getXAxisColor()
public void setXAxisColor(java.awt.Color c)
c
- The color to set.public java.awt.Color getYAxisColor()
public void setYAxisColor(java.awt.Color c)
c
- The yAxisColor to set.public java.awt.Color getLabelColor()
public void setLabelColor(java.awt.Color c)
c
- label colorpublic java.awt.Color getTickColor()
public void setTickColor(java.awt.Color tickColor)
tickColor
- The TickColor to set.public int getStyleXAxis()
public void setStyleXAxis(int styleXAxis)
styleXAxis
- NO_AXIS, NO_TICKS, TICKS_NO_LABELS or TICKS_AND_LABELSpublic int getStyleYAxis()
public void setStyleYAxis(int styleYAxis)
styleYAxis
- NO_AXIS, NO_TICKS, TICKS_NO_LABELS or TICKS_AND_LABELSpublic float getXLineWidth()
public void setXLineWidth(float thickness)
thickness
- The width to set.public float getYLineWidth()
public void setYLineWidth(float thickness)
thickness
- The width to set.public java.awt.Color getXTickColor()
public void setXTickColor(java.awt.Color tickColor)
tickColor
- The color to set.public java.awt.Color getYTickColor()
public void setYTickColor(java.awt.Color tickColor)
tickColor
- The color to set.public float getMajorXTickWidth()
public void setMajorXTickWidth(float thickness)
thickness
- The width to set.public float getMajorYTickWidth()
public void setMajorYTickWidth(float thickness)
thickness
- The width to set.public java.awt.Color getXLabelColor()
public void setXLabelColor(java.awt.Color c)
c
- The color to set.public java.awt.Color getYLabelColor()
public void setYLabelColor(java.awt.Color c)
c
- The color to set.public void setTickSpacing(double forX, double forY, double minorX, double minorY)
forX
- the major tick spacing for the x axisforY
- the major tick spacing for the y axisminorX
- the minor tick spacing for the x axisminorY
- the minor tick spacing for the y axispublic boolean getAutoTicks()
public void setAutoTicks(boolean b)
b
- AUTO_TICKS if true, ABSOLUTE_TICKS if falsepublic boolean getPaintTicks()
public void setPaintTicks(boolean b)
b
- true for TICKS_AND_LABELS, false for NO_TICKSpublic boolean isXAvoidOverlap()
public void setXAvoidOverlap(boolean avoidOverlap)
avoidOverlap
- whether x tick labels can overlappublic boolean isYAvoidOverlap()
public void setYAvoidOverlap(boolean avoidOverlap)
avoidOverlap
- whether y tick labels can overlap
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |