| javax.swing.JComponent com.xoetrope.swing.XGraph
All known Subclasses: com.xoetrope.tools.WardGraph,
XGraph | public class XGraph extends JComponent implements ActionListener,XAttributedComponent,XModelHolder(Code) | | An component that displays data as charts/graphs. The display can be Pie,
Scatter, Line, X-Y or Bar charts
Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
the GNU Public License (GPL), please see license.txt for more details. If
you make commercial use of this software you must purchase a commercial
license from Xoetrope.
$Revision: 1.29 $
|
Inner Class :public class SelectableArea | |
Constructor Summary | |
public | XGraph() |
Method Summary | |
public void | actionPerformed(ActionEvent e) | protected Color | darken(Color c, double degrees) | public void | drawBarChart(Graphics2D g2d) | protected void | drawLegend(Graphics2D g2d, double x, double y, double w, double h) | public void | drawLineChart(Graphics2D g2d) | public void | drawPieChart(Graphics2D g2d) | public void | drawScale(Graphics2D g2d, boolean isVertical) | public void | drawSelectedArea(Graphics2D g2d) | public void | drawStackedBarChart(Graphics2D g2d) | public boolean | getDrawBorder() | protected Color | getGeneratedColor(int idx) | protected Color | getGeneratedColor(int i, int opacity) | public boolean | getHighlight() | public boolean | getLabels() | public int | getLegendPos() | protected int | getLegendSpace(boolean verticalSpace) | protected int | getLegendX(double left, double right) | protected int | getLegendY(double top, double bottom) | public boolean | getMarkers() | public double | getMaxY() | public double | getMinY() | public int | getMode() | public SelectableArea | getSelectableArea() | public String | getTitle() | protected double | getXLabelHeight(Graphics g) | protected double | getYLabelWidth(Graphics g) | public void | paintComponent(Graphics g) Renders the chart image. | public void | print(Graphics g) | public int | setAttribute(String attribName, Object attribValue) Set one or more attributes of the component. | public void | setBounds(int x, int y, int w, int h) | public void | setData(double[] pts, int nSeries, String[] names, boolean animate) Set the chart data
Parameters: nSeries - the number of series Parameters: pts - the data points in x, y pairs, a complete series at a time e.g. | public void | setDrawBorder(boolean b) | public void | setHighlight(boolean b) | public void | setLabels(boolean b) | public void | setLegendPos(int y) | public void | setMarkers(boolean b) | public void | setMaxY(double y) | public void | setMinY(double y) | public void | setMode(int newMode) | public void | setModel(XModel xmodel) | public void | setModelStructure(int attribute, int value) | public void | setTitle(String newStr) Set the text of the form to the specified language string,
the setLangString(...) function is the preferred method of setting
the caption. | public void | setXScale(double min, double max, int type, String title, String[] labels) | public void | setYScale(int type, String title) | public void | toggleYAxisAnimation() | public void | update() |
BARCHART | final public static int BARCHART(Code) | | Bar chart - with one bar per value in each series
|
LABELS | final public static int LABELS(Code) | | The labels column/field in the source data table
|
LINEAR | final public static int LINEAR(Code) | | Linear axis
|
LINECHART | final public static int LINECHART(Code) | | A simple line chart with connected points
|
LOGARITHMIC | final public static int LOGARITHMIC(Code) | | A Log10 axis
|
PIECHART | final public static int PIECHART(Code) | | A pie chart showing the first series
|
SCATTERCHART | final public static int SCATTERCHART(Code) | | A plot with points for each x-y value pair
|
SERIES | final public static int SERIES(Code) | | The series column/field in the source data table
|
STACKEDBARCHART | final public static int STACKEDBARCHART(Code) | | Bar chart with the bars for each value in the series stacked upon one another so that there is one bar for each x value
|
VALUES | final public static int VALUES(Code) | | The values column/field in the source data table
|
currentProject | protected XProject currentProject(Code) | | The owner project and the context in which this object operates.
|
XGraph | public XGraph()(Code) | | Construct a new graph/chart
|
actionPerformed | public void actionPerformed(ActionEvent e)(Code) | | An action handler for the animation timer
Parameters: e - the event |
darken | protected Color darken(Color c, double degrees)(Code) | | Darken the selected color for the sides of the pie chart
Parameters: c - the selected color Parameters: degrees - the angle/position at which the color is used the new color |
drawBarChart | public void drawBarChart(Graphics2D g2d)(Code) | | Draw a simple bar chart
Parameters: g2d - the graphics context |
drawLegend | protected void drawLegend(Graphics2D g2d, double x, double y, double w, double h)(Code) | | Draw the chart legend
Parameters: g2d - the graphics context Parameters: x - the x/left position Parameters: y - the y/top position Parameters: w - the width Parameters: h - the height |
drawLineChart | public void drawLineChart(Graphics2D g2d)(Code) | | Draw a line chart
Parameters: g2d - the graphics context |
drawPieChart | public void drawPieChart(Graphics2D g2d)(Code) | | Draw a pie chart with the first data series
Parameters: g2d - the graphics context |
drawScale | public void drawScale(Graphics2D g2d, boolean isVertical)(Code) | | Draw a scale
Parameters: g2d - the graphics context Parameters: isVertical - true to draw a vertical axis, otherwise the horizontal axis is drawn |
drawSelectedArea | public void drawSelectedArea(Graphics2D g2d)(Code) | | Highlight the selected area - if any
Parameters: g2d - the graphics context |
drawStackedBarChart | public void drawStackedBarChart(Graphics2D g2d)(Code) | | Draw a stacked bar chart
Parameters: g2d - the graphics context |
getDrawBorder | public boolean getDrawBorder()(Code) | | Get the drawBorder flag value
true if the border is drawn |
getGeneratedColor | protected Color getGeneratedColor(int idx)(Code) | | Generate an HSB color, using the index as an offset int the H color range
Parameters: idx - the index of the color the new color |
getGeneratedColor | protected Color getGeneratedColor(int i, int opacity)(Code) | | Get a generated color with partial opacity
Parameters: i - the color index Parameters: opacity - the opacity in the range 0-255 the new color |
getHighlight | public boolean getHighlight()(Code) | | Get the highlight flag value
true if the current value is highlighted as the mouse is moved |
getLabels | public boolean getLabels()(Code) | | Get the labels flag value
true if the border is drawn |
getLegendPos | public int getLegendPos()(Code) | | Get the legend position
the position value, 0=top left, 1=top right, 2=bottom left, 3=bottom right, 4=right margin, 5=bottom margin |
getLegendSpace | protected int getLegendSpace(boolean verticalSpace)(Code) | | Get the space consumed by the legend
Parameters: verticalSpace - true if the legend is shown horizontally below the chart the size the legend consumes if it does not overlap the chart area |
getLegendX | protected int getLegendX(double left, double right)(Code) | | Get the legend x coordinate
Parameters: left - the left edge of the chart Parameters: right - the right edge of the chart the starting x coordinate of the legend |
getLegendY | protected int getLegendY(double top, double bottom)(Code) | | Get the legend y coordinate
Parameters: top - the top edge of the chart Parameters: bottom - the bottom edge of the chart the starting y coordinate of the legend |
getMarkers | public boolean getMarkers()(Code) | | Get the markers flag value
true if the markers are drwan for each point |
getMaxY | public double getMaxY()(Code) | | Get the maximum Y value
the maximum value |
getMinY | public double getMinY()(Code) | | Get the minimum Y value
the minimum value |
getMode | public int getMode()(Code) | | Get the current display mode of the chart
the mode: 0=BAR, 1=STACKEDBAR, 2=LINE, 3=PIE, 4=SCATTER |
getSelectableArea | public SelectableArea getSelectableArea()(Code) | | Get the selectable area
the selected area or null if there is no selection |
getTitle | public String getTitle()(Code) | | Get the graph title
the title text |
getXLabelHeight | protected double getXLabelHeight(Graphics g)(Code) | | Get the height of the X axis labels
the label space height Parameters: g - the graphics context |
getYLabelWidth | protected double getYLabelWidth(Graphics g)(Code) | | Get the height of the X axis labels
the label space height Parameters: g - the graphics context |
paintComponent | public void paintComponent(Graphics g)(Code) | | Renders the chart image.
Parameters: g - the graphics context |
print | public void print(Graphics g)(Code) | | Setup the envelope component for printing
Parameters: g - the graphics context |
setAttribute | public int setAttribute(String attribName, Object attribValue)(Code) | | Set one or more attributes of the component. Currently this handles the
attributes
- mode, value=the type of chart i.e. 0=BAR, 1=STACKEDBAR, 2=LINE, 3=PIE, 4=SCATTER
- border, value=1 or true to surround with a border
- labels, value=1 or true to label the data points
- markers, value=1 or true to draw markers for each data point
- minY, value=the minimum allowable y value, any value less than this will not be drawn
- legendPos, value=the legend position, 0=top left, 1=top right, 2=bottom left, 3=bottom right, 4=right margin, 5=bottom margin
- highlight, value=1 or true to highlight the selection under the mouse
Parameters: attribName - the attribute name Parameters: attribValue - the attribute value 0 for success, non zero otherwise |
setBounds | public void setBounds(int x, int y, int w, int h)(Code) | | Set the bounds for this component and layout the children
Parameters: x - the x coordinate Parameters: y - the y coordinate Parameters: w - the width Parameters: h - the height |
setData | public void setData(double[] pts, int nSeries, String[] names, boolean animate)(Code) | | Set the chart data
Parameters: nSeries - the number of series Parameters: pts - the data points in x, y pairs, a complete series at a time e.g. ax1, ay1, ax2, ay2, .... xn, yn, bx1, by1, bx2, by2 Parameters: names - the names of the series Parameters: animate - true to animate new data |
setDrawBorder | public void setDrawBorder(boolean b)(Code) | | Set the drawBorder flag value
Parameters: b - true if the border is drawn |
setHighlight | public void setHighlight(boolean b)(Code) | | Set the highlight flag value
Parameters: b - true if the current value is to be highlighted as the mouse is moved |
setLabels | public void setLabels(boolean b)(Code) | | Set the labels flag value
Parameters: b - true if the lables are drawn on the data points |
setLegendPos | public void setLegendPos(int y)(Code) | | Set the legend position
Parameters: pos - value=the legend position, 0=top left, 1=top right, 2=bottom left, 3=bottom right, 4=right margin, 5=bottom margin |
setMarkers | public void setMarkers(boolean b)(Code) | | Set the markers flag value
Parameters: b - true if the markers are drwan for each point |
setMaxY | public void setMaxY(double y)(Code) | | Set the maximum Y value
Parameters: y - the maximum value |
setMinY | public void setMinY(double y)(Code) | | Set the minimum Y value
Parameters: y - the minimum value |
setMode | public void setMode(int newMode)(Code) | | Set the display mode of the chart
Parameters: newMode - the new mode: 0=BAR, 1=STACKEDBAR, 2=LINE, 3=PIE, 4=SCATTER |
setModel | public void setModel(XModel xmodel)(Code) | | Set the XModel which we will be generating the table from
Parameters: xmodel - The XModel of data |
setModelStructure | public void setModelStructure(int attribute, int value)(Code) | | Define the location of the data in the model
Parameters: attribute - the attribute being defined (LABELS, SERIES, VALUES) Parameters: value - the column of field where that data can be found |
setTitle | public void setTitle(String newStr)(Code) | | Set the text of the form to the specified language string,
the setLangString(...) function is the preferred method of setting
the caption.
Parameters: newStr - the new title |
setXScale | public void setXScale(double min, double max, int type, String title, String[] labels)(Code) | | Set the XScale options
Parameters: min - the min value Parameters: max - the max value Parameters: type - the type of axis Parameters: title - the axis title Parameters: labels - the labels for the markers in the series |
setYScale | public void setYScale(int type, String title)(Code) | | Set the XScale options
Parameters: type - the type of axis Parameters: title - the axis title |
toggleYAxisAnimation | public void toggleYAxisAnimation()(Code) | | Turn on/off the animation of new data
|
update | public void update()(Code) | | Force a repaint
|
Methods inherited from javax.swing.JComponent | public void addAncestorListener(AncestorListener listener)(Code)(Java Doc) public void addNotify()(Code)(Java Doc) public synchronized void addVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) public void computeVisibleRect(Rectangle visibleRect)(Code)(Java Doc) public boolean contains(int x, int y)(Code)(Java Doc) public JToolTip createToolTip()(Code)(Java Doc) public void disable()(Code)(Java Doc) public void enable()(Code)(Java Doc) public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, int oldValue, int newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, char oldValue, char newValue)(Code)(Java Doc) protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws java.beans.PropertyVetoException(Code)(Java Doc) public AccessibleContext getAccessibleContext()(Code)(Java Doc) public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) final public ActionMap getActionMap()(Code)(Java Doc) public float getAlignmentX()(Code)(Java Doc) public float getAlignmentY()(Code)(Java Doc) public AncestorListener[] getAncestorListeners()(Code)(Java Doc) public boolean getAutoscrolls()(Code)(Java Doc) public int getBaseline(int width, int height)(Code)(Java Doc) public BaselineResizeBehavior getBaselineResizeBehavior()(Code)(Java Doc) public Border getBorder()(Code)(Java Doc) public Rectangle getBounds(Rectangle rv)(Code)(Java Doc) final public Object getClientProperty(Object key)(Code)(Java Doc) protected Graphics getComponentGraphics(Graphics g)(Code)(Java Doc) public JPopupMenu getComponentPopupMenu()(Code)(Java Doc) public int getConditionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) public int getDebugGraphicsOptions()(Code)(Java Doc) public static Locale getDefaultLocale()(Code)(Java Doc) public FontMetrics getFontMetrics(Font font)(Code)(Java Doc) public Graphics getGraphics()(Code)(Java Doc) public int getHeight()(Code)(Java Doc) public boolean getInheritsPopupMenu()(Code)(Java Doc) final public InputMap getInputMap(int condition)(Code)(Java Doc) final public InputMap getInputMap()(Code)(Java Doc) public InputVerifier getInputVerifier()(Code)(Java Doc) public Insets getInsets()(Code)(Java Doc) public Insets getInsets(Insets insets)(Code)(Java Doc) public T[] getListeners(Class<T> listenerType)(Code)(Java Doc) public Point getLocation(Point rv)(Code)(Java Doc) public Dimension getMaximumSize()(Code)(Java Doc) public Dimension getMinimumSize()(Code)(Java Doc) public Component getNextFocusableComponent()(Code)(Java Doc) public Point getPopupLocation(MouseEvent event)(Code)(Java Doc) public Dimension getPreferredSize()(Code)(Java Doc) public KeyStroke[] getRegisteredKeyStrokes()(Code)(Java Doc) public JRootPane getRootPane()(Code)(Java Doc) public Dimension getSize(Dimension rv)(Code)(Java Doc) public Point getToolTipLocation(MouseEvent event)(Code)(Java Doc) public String getToolTipText()(Code)(Java Doc) public String getToolTipText(MouseEvent event)(Code)(Java Doc) public Container getTopLevelAncestor()(Code)(Java Doc) public TransferHandler getTransferHandler()(Code)(Java Doc) public String getUIClassID()(Code)(Java Doc) public boolean getVerifyInputWhenFocusTarget()(Code)(Java Doc) public synchronized VetoableChangeListener[] getVetoableChangeListeners()(Code)(Java Doc) public Rectangle getVisibleRect()(Code)(Java Doc) public int getWidth()(Code)(Java Doc) public int getX()(Code)(Java Doc) public int getY()(Code)(Java Doc) public void grabFocus()(Code)(Java Doc) public boolean isDoubleBuffered()(Code)(Java Doc) public static boolean isLightweightComponent(Component c)(Code)(Java Doc) public boolean isManagingFocus()(Code)(Java Doc) public boolean isOpaque()(Code)(Java Doc) public boolean isOptimizedDrawingEnabled()(Code)(Java Doc) final public boolean isPaintingForPrint()(Code)(Java Doc) public boolean isPaintingTile()(Code)(Java Doc) public boolean isRequestFocusEnabled()(Code)(Java Doc) public boolean isValidateRoot()(Code)(Java Doc) public void paint(Graphics g)(Code)(Java Doc) protected void paintBorder(Graphics g)(Code)(Java Doc) protected void paintChildren(Graphics g)(Code)(Java Doc) protected void paintComponent(Graphics g)(Code)(Java Doc) public void paintImmediately(int x, int y, int w, int h)(Code)(Java Doc) public void paintImmediately(Rectangle r)(Code)(Java Doc) protected String paramString()(Code)(Java Doc) public void print(Graphics g)(Code)(Java Doc) public void printAll(Graphics g)(Code)(Java Doc) protected void printBorder(Graphics g)(Code)(Java Doc) protected void printChildren(Graphics g)(Code)(Java Doc) protected void printComponent(Graphics g)(Code)(Java Doc) protected void processComponentKeyEvent(KeyEvent e)(Code)(Java Doc) protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)(Code)(Java Doc) protected void processKeyEvent(KeyEvent e)(Code)(Java Doc) protected void processMouseEvent(MouseEvent e)(Code)(Java Doc) protected void processMouseMotionEvent(MouseEvent e)(Code)(Java Doc) final public void putClientProperty(Object key, Object value)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void removeAncestorListener(AncestorListener listener)(Code)(Java Doc) public void removeNotify()(Code)(Java Doc) public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) public void repaint(long tm, int x, int y, int width, int height)(Code)(Java Doc) public void repaint(Rectangle r)(Code)(Java Doc) public boolean requestDefaultFocus()(Code)(Java Doc) public void requestFocus()(Code)(Java Doc) public boolean requestFocus(boolean temporary)(Code)(Java Doc) public boolean requestFocusInWindow()(Code)(Java Doc) protected boolean requestFocusInWindow(boolean temporary)(Code)(Java Doc) public void resetKeyboardActions()(Code)(Java Doc) public void reshape(int x, int y, int w, int h)(Code)(Java Doc) public void revalidate()(Code)(Java Doc) public void scrollRectToVisible(Rectangle aRect)(Code)(Java Doc) final public void setActionMap(ActionMap am)(Code)(Java Doc) public void setAlignmentX(float alignmentX)(Code)(Java Doc) public void setAlignmentY(float alignmentY)(Code)(Java Doc) public void setAutoscrolls(boolean autoscrolls)(Code)(Java Doc) public void setBackground(Color bg)(Code)(Java Doc) public void setBorder(Border border)(Code)(Java Doc) public void setComponentPopupMenu(JPopupMenu popup)(Code)(Java Doc) public void setDebugGraphicsOptions(int debugOptions)(Code)(Java Doc) public static void setDefaultLocale(Locale l)(Code)(Java Doc) public void setDoubleBuffered(boolean aFlag)(Code)(Java Doc) public void setEnabled(boolean enabled)(Code)(Java Doc) public void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)(Code)(Java Doc) public void setFont(Font font)(Code)(Java Doc) public void setForeground(Color fg)(Code)(Java Doc) public void setInheritsPopupMenu(boolean value)(Code)(Java Doc) final public void setInputMap(int condition, InputMap map)(Code)(Java Doc) public void setInputVerifier(InputVerifier inputVerifier)(Code)(Java Doc) public void setMaximumSize(Dimension maximumSize)(Code)(Java Doc) public void setMinimumSize(Dimension minimumSize)(Code)(Java Doc) public void setNextFocusableComponent(Component aComponent)(Code)(Java Doc) public void setOpaque(boolean isOpaque)(Code)(Java Doc) public void setPreferredSize(Dimension preferredSize)(Code)(Java Doc) public void setRequestFocusEnabled(boolean requestFocusEnabled)(Code)(Java Doc) public void setToolTipText(String text)(Code)(Java Doc) public void setTransferHandler(TransferHandler newHandler)(Code)(Java Doc) protected void setUI(ComponentUI newUI)(Code)(Java Doc) public void setVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget)(Code)(Java Doc) public void setVisible(boolean aFlag)(Code)(Java Doc) public void unregisterKeyboardAction(KeyStroke aKeyStroke)(Code)(Java Doc) public void update(Graphics g)(Code)(Java Doc) public void updateUI()(Code)(Java Doc)
|
|
|