|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.Graph
public abstract class Graph
The Graph class is an abstract class that serves as a general base class for all specific chart and plot classes (such as BarChart and PieChart) to extend.
Simple text based information would be better set as titles and footnotes, which is extended by the specific models.
In addition, Graph is where data tips can be set up.
Most specific, visual, user set-able properties are consolidated in the GraphModel, accessible from the Graph.
GraphModel
,
Serialized FormField Summary | |
---|---|
protected javax.swing.JComponent |
footnoteContainer
|
static java.lang.String |
RB_KEY
|
protected javax.swing.JComponent |
titleContainer
|
Constructor Summary | |
---|---|
Graph()
Construct a Graph. |
Method Summary | |
---|---|
void |
addActionListener(GraphActionListener l)
|
void |
addMouseListener(java.awt.event.MouseListener l)
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener l)
|
void |
addMouseMotionListener(java.awt.event.MouseWheelListener l)
|
void |
applyColorScheme(ColorScheme scheme)
Apply a color scheme on this Graph. |
protected abstract void |
applyDataModel()
Intended for internalUse only |
protected void |
applyGraphModel()
Intended for internalUse only |
void |
applyGraphStyle(GraphStyle graphStyle)
applyGraphStyle must be called in order for any visual attributes set within the graph's GraphStyle to show up in the graph. |
void |
clearSelection()
|
protected void |
firePropertyChange(java.lang.String propertyName,
ModelBase oldValue,
ModelBase newValue)
Support for reporting bound contained-Model property changes. |
SwingActionProvider |
getActionProvider()
Returns the ActionProvider object used to return actions for the Graph. |
int |
getAppliedColorSchemeName()
The name of the last ColorScheme applied to this graph. |
int |
getAppliedGraphStyleName()
The name of the last graphStyle applied to this graph. |
java.awt.Color |
getBackground()
|
java.awt.Rectangle |
getBrushBounds()
|
protected com.sas.graphics.util.gl.Channel |
getChannel()
|
protected com.sas.collection.ContentsChangedListener |
getContentsChangedListener()
Internal use only |
protected GraphStyle |
getDefaultGraphStyle()
For internal use only. |
static int |
getDefaultHeight()
|
static int |
getDefaultWidth()
|
int |
getDisplayPolicy()
Get how the graph is to utilize the display area when insufficient space is available. |
javax.swing.JComponent |
getFooter()
Return the user-set footer component, or null if none has been specified. |
NoteModel |
getFootnote(int position)
Return the model for the footnote at the specified position. |
NoteModel |
getFootnote1()
Return the model for the graph's 1st (upper most) footnote. |
NoteModel |
getFootnote2()
Return the model for the graph's 2nd footnote. |
javax.swing.JComponent |
getHeader()
Return the user-set header component, or null if none has been specified. |
protected javax.swing.event.ListSelectionListener |
getListSelectionListener()
Internal use only |
java.util.Locale |
getLocale()
|
com.sas.graphics.components.MessageModel |
getMessageModel()
Sets the model that can be used to specify a message that will be displayed in a panel in the graph area appearing on top of the graph display. |
java.awt.Dimension |
getMinimumSize()
|
java.awt.Dimension |
getPreferredSize()
|
protected javax.swing.event.TableModelListener |
getTableModelListener()
Internal use only |
NoteModel |
getTitle(int position)
Return the model for the title at the specified position. |
NoteModel |
getTitle1()
Return the model for the graph's 1st (upper most) title. |
NoteModel |
getTitle2()
Return the model for the graph's 2nd title. |
NoteModel |
getTitle3()
Return the model for the graph's 3rd title. |
NoteModel |
getTitle4()
Return the model for the graph's 4th title. |
boolean |
isAppliedGraphStyleModified()
Indicates whether or not any display properties have changes since the last graphstyle was applied. |
abstract boolean |
isAutoRepaintEnabled()
Returns whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed. |
void |
paint(java.awt.Graphics g)
|
void |
paintAll(java.awt.Graphics g)
|
protected void |
paintBackground(java.awt.Graphics g,
java.awt.Rectangle bounds,
java.awt.Insets insets)
|
PickInfo |
pick(int x,
int y)
|
PickInfo[] |
pick(int x,
int y,
int w,
int h)
|
PickInfo[] |
pickSelected()
|
abstract void |
prepareToPaint()
Notify this component that an application is about to call paint directly. |
void |
removeActionListener(GraphActionListener l)
|
PickInfo |
select(int x,
int y)
|
PickInfo |
select(int x,
int y,
boolean isControlDown)
|
PickInfo[] |
select(int x,
int y,
int w,
int h)
|
PickInfo[] |
select(int x,
int y,
int w,
int h,
boolean isControlDown)
|
protected abstract void |
selectionChanged()
Internal use only. |
void |
setActionProvider(SwingActionProvider actionProvider)
Set an action provider on this Graph. |
abstract void |
setAutoRepaintEnabled(boolean enabled)
Sets whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed. |
void |
setBackground(java.awt.Color c)
|
void |
setBounds(int x,
int y,
int w,
int h)
|
void |
setDisplayPolicy(int newDisplayPolicy)
Set how the graph is to utilize the display area. |
void |
setFooter(javax.swing.JComponent newFooter)
Assigns a component that gets placed at the bottom of the Graph display area. |
void |
setFootnote(NoteModel newNoteModel,
int position)
Set the model for the footnote at the specified position. |
void |
setFootnote1(NoteModel newNoteModel)
Set the model for the graph's 1st (upper most) footnote. |
void |
setFootnote2(NoteModel newNoteModel)
Set the model for the graph's 2nd footnote. |
void |
setHeader(javax.swing.JComponent newHeader)
Assigns a component that gets placed at the top of the Graph component's display area. |
void |
setMessageModel(com.sas.graphics.components.MessageModel newMessageModel)
Sets the model that can be used to specify a message that will be displayed in a panel in the graph area appearing on top of the graph display. |
protected void |
setPaintContext(boolean redoSelectionOnPaintEnabled,
com.sas.graphics.components.animation.AnimationPosition animationPosition)
|
void |
setTitle(NoteModel newNoteModel,
int position)
Set the model for the title at the specified position. |
void |
setTitle1(NoteModel newNoteModel)
Set the model for the graph's 1st title. |
void |
setTitle2(NoteModel newNoteModel)
Set the model for the graph's 2nd title. |
void |
setTitle3(NoteModel newNoteModel)
Set the model for the graph's 3rd title. |
void |
setTitle4(NoteModel newNoteModel)
Set the model for the graph's 4th title. |
void |
update(java.awt.Graphics g)
|
protected abstract void |
updateDataModelListeners()
Invoked when the data model has changed. |
protected void |
updateDataModelListeners(java.lang.Object newModel,
java.lang.Object newSelectionModel)
Perform listener list maintenance on a data and selection model. |
protected void |
validateTree()
|
Field Detail |
---|
public static final java.lang.String RB_KEY
protected transient javax.swing.JComponent titleContainer
protected transient javax.swing.JComponent footnoteContainer
Constructor Detail |
---|
public Graph()
Method Detail |
---|
protected javax.swing.event.ListSelectionListener getListSelectionListener()
protected javax.swing.event.TableModelListener getTableModelListener()
protected com.sas.collection.ContentsChangedListener getContentsChangedListener()
public void setActionProvider(SwingActionProvider actionProvider)
actionProvider
- public SwingActionProvider getActionProvider()
protected final GraphStyle getDefaultGraphStyle()
protected void firePropertyChange(java.lang.String propertyName, ModelBase oldValue, ModelBase newValue)
propertyName
- the property being changedoldValue
- the value being changed fromnewValue
- the value being changed topublic static int getDefaultWidth()
public static int getDefaultHeight()
protected void setPaintContext(boolean redoSelectionOnPaintEnabled, com.sas.graphics.components.animation.AnimationPosition animationPosition)
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void update(java.awt.Graphics g)
update
in class javax.swing.JComponent
protected void validateTree()
validateTree
in class java.awt.Container
public void paintAll(java.awt.Graphics g)
paintAll
in class java.awt.Component
public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
public abstract void prepareToPaint()
As per java standard practices; "paint" should never be called directly by an application. However if it is necessary to render the Graph directly then the use of paintAll(Graphics) or printAll(Graphics) is acceptable.
Graphs asynchronously update to keep their view in sync with their model properties (Graphmodel, DataModel, NoteModel etc.). A direct call to paintAll or printAll does not allow for the graph to asynchronously sync up with their model proeprties. prepareToPaint provides this synchronization point necessary for the Graphs to update their component structure as needed.
Note: Used in a headless environment, Graphs will never asynchronously update and therefore require a call to prepareToPaint to render into a GraphicsContext.
The headless and non-headless cases can be handled slightly differently. In the non-headless case the asynchronous updating needs to be halted. This is done by setting the "autoRepaintEnabled" property to false. The default for autoRepaintEnabled is true, allowing the graph to automatically resync and repaint as model properties are modified.
Example writing to an image. Note for readability exception handling has been ignored.
static public void main(String args[]) { BufferedImage bi = new BufferedImage(640,480,BufferedImage.TYPE_INT_RGB); Graphics ig = bi.createGraphics(); // Create Graph BarChart graph = new BarChart(); // This call is not necessary if you are running in a headless environment. graph.setAutoRepaintEnabled(false); // ... assign data and model properties here ... graph.setDataModel(newGraphData()); {// Render sequence graph.setBounds(0,0,bi.getWidth(null),bi.getHeight(null)); // Define the size of the Graph graph.addNotify(); // Makes the component displayable. graph.prepareToPaint(); // do property synchronization graph.paintAll(ig); // render into some graphics context } // Dispose of image graphics context ig.dispose(); // Save immage to disk File file = new File("graph.jpg"); try { ImageIO.write(bi, "jpg", file); } catch (IOException e) { System.out.println("ImageIO.write failed."); } }
public abstract void setAutoRepaintEnabled(boolean enabled)
The setting of this property to false implies that the application will be responsible for synchronising the graph with its models using the prepareToPaint() method. Also see isAutoRepaintEnabled() on the graph's model.
This method was added to support rendering into an off screen graphics context such as an image.
enabled
- true means to automatically updatepublic abstract boolean isAutoRepaintEnabled()
public void setBounds(int x, int y, int w, int h)
setBounds
in class java.awt.Component
public void setBackground(java.awt.Color c)
setBackground
in class javax.swing.JComponent
public java.awt.Color getBackground()
getBackground
in class java.awt.Component
public void setMessageModel(com.sas.graphics.components.MessageModel newMessageModel) throws java.lang.IllegalArgumentException
And though this model may not be set to null, no message is displayed so long as the message title property is null and the message strings are not defined or all null.
Note: no other behaviour or visual differences are modified by the graph when a message is displayed. The application is responsible for specifying any special display properties on the graph required to produce the desired appearance since it is probable that different applications may wish to present different looks based upon their usage.
java.lang.IllegalArgumentException
getMessageModel()
public com.sas.graphics.components.MessageModel getMessageModel()
setMessageModel(com.sas.graphics.components.MessageModel)
protected void applyGraphModel()
protected abstract void applyDataModel()
public java.util.Locale getLocale()
getLocale
in class java.awt.Component
protected abstract void selectionChanged()
protected abstract void updateDataModelListeners()
updateDataModelListeners(Object model, Object selectionModel)
protected void updateDataModelListeners(java.lang.Object newModel, java.lang.Object newSelectionModel)
newModel
- - One of TableModel, ContentsChangedSource, nullnewSelectionModel
- - ListSelectionModel, or nullprotected void paintBackground(java.awt.Graphics g, java.awt.Rectangle bounds, java.awt.Insets insets)
public void setDisplayPolicy(int newDisplayPolicy) throws java.lang.IllegalArgumentException
On the occasion when insufficient display area is available, the graph has to decide whether to use scroll bars and only display a portion of the graph or to draw the entire graph into the available space (shrinking and adjusting portions of the graph as best it can).
To allow scroll bars use the GraphConstants.DISPLAY_SCROLL_AS_NEEDED or specify GraphConstants.DISPLAY_FIT_TO_SCREEN to force the entire graph into the available display area. Specify GraphConstants.DISPLAY_SCROLL_ENABLED shows zoom scrollbars which appear when the display area is moused over and the chart is forced to show the entire graph in the available display area, however the use can then zoom and scroll to investigate the data further.
The default value is GraphConstants.DISPLAY_AUTOMATIC.
Valid values are:
GraphConstants.DISPLAY_FIT_TO_SCREEN
GraphConstants.DISPLAY_SCROLL_AS_NEEDED
GraphConstants.DISPLAY_SCROLL_ENABLED:
GraphConstants.DISPLAY_AUTOMATIC:
newDisplayPolicy
- how the Graph should utilize the dislay area
java.lang.IllegalArgumentException
- if newDisplayPolicy is invalid.getDisplayPolicy()
public int getDisplayPolicy()
Valid values are:
GraphConstants.DISPLAY_SCROLL_ENABLED
GraphConstants.DISPLAY_FIT_TO_SCREEN
GraphConstants.DISPLAY_SCROLL_AS_NEEDED
setDisplayPolicy(int)
public void setHeader(javax.swing.JComponent newHeader)
newHeader
- the component to be placed at the top of the graph
Note: a null value will cause the component (if any) to be removed.
getHeader()
public javax.swing.JComponent getHeader()
setHeader(javax.swing.JComponent)
public void setFooter(javax.swing.JComponent newFooter)
newFooter
- the component to be placed at the bottom of the graph
Note: a null value will cause the component (if any) to be removed.
getFooter()
public javax.swing.JComponent getFooter()
setFooter(javax.swing.JComponent)
public PickInfo pick(int x, int y)
public PickInfo[] pick(int x, int y, int w, int h)
public PickInfo select(int x, int y)
public PickInfo[] select(int x, int y, int w, int h)
public PickInfo select(int x, int y, boolean isControlDown)
public PickInfo[] select(int x, int y, int w, int h, boolean isControlDown)
public void clearSelection()
public PickInfo[] pickSelected()
public java.awt.Rectangle getBrushBounds()
public void addMouseListener(java.awt.event.MouseListener l)
addMouseListener
in class java.awt.Component
public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
addMouseMotionListener
in class java.awt.Component
public void addMouseMotionListener(java.awt.event.MouseWheelListener l)
public void addActionListener(GraphActionListener l)
public void removeActionListener(GraphActionListener l)
public void setTitle(NoteModel newNoteModel, int position) throws java.lang.IllegalArgumentException
newNoteModel
- - title attributesposition
- identifies the desired title by its order position.
java.lang.IllegalArgumentException
- if newNoteModel is null.
java.lang.IllegalArgumentException
- if the
value of position is less than 1 or greater than 4.getTitle(int)
,
setTitle1(com.sas.graphics.components.NoteModel)
,
setTitle2(com.sas.graphics.components.NoteModel)
,
setTitle3(com.sas.graphics.components.NoteModel)
,
setTitle4(com.sas.graphics.components.NoteModel)
,
NoteModel
,
NoteModel.apply(com.sas.graphics.components.NoteModel)
public NoteModel getTitle(int position) throws java.lang.IllegalArgumentException
position
- identifies the desired title by its order position.
java.lang.IllegalArgumentException
- if the value of position is less than 1 or greater than 4.setTitle(com.sas.graphics.components.NoteModel, int)
,
getTitle1()
,
getTitle2()
,
getTitle3()
,
getTitle4()
,
NoteModel
public void setTitle1(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 1st title's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getTitle1()
,
setTitle(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getTitle1()
setTitle1(com.sas.graphics.components.NoteModel)
,
getTitle(int)
,
JComponent
public void setTitle2(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 2nd title's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getTitle2()
,
setTitle(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getTitle2()
setTitle2(com.sas.graphics.components.NoteModel)
,
getTitle(int)
,
JComponent
public void setTitle3(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 3rd title's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getTitle3()
,
setTitle(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getTitle3()
setTitle3(com.sas.graphics.components.NoteModel)
,
getTitle(int)
,
JComponent
public void setTitle4(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 4th title's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getTitle4()
,
setTitle(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getTitle4()
setTitle4(com.sas.graphics.components.NoteModel)
,
getTitle(int)
,
JComponent
public void setFootnote(NoteModel newNoteModel, int position) throws java.lang.IllegalArgumentException
newNoteModel
- footnote attributesposition
- identifies the desired footnote by its order position.
java.lang.IllegalArgumentException
- if newNoteModel is null.
java.lang.IllegalArgumentException
- if the
value of position is less than 1 or greater than 2.getFootnote(int)
,
setFootnote1(com.sas.graphics.components.NoteModel)
,
setFootnote2(com.sas.graphics.components.NoteModel)
,
NoteModel
,
NoteModel.apply(com.sas.graphics.components.NoteModel)
public NoteModel getFootnote(int position) throws java.lang.IllegalArgumentException
position
- identifies the desired footnote by its order position.
java.lang.IllegalArgumentException
- if the value of position is less than 1 or greater than 2.setFootnote(com.sas.graphics.components.NoteModel, int)
,
getFootnote1()
,
getFootnote2()
,
NoteModel
public void setFootnote1(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 1st footnote's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getFootnote1()
,
setFootnote(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getFootnote1()
setFootnote1(com.sas.graphics.components.NoteModel)
,
getFootnote(int)
,
NoteModel
public void setFootnote2(NoteModel newNoteModel) throws java.lang.IllegalArgumentException
newNoteModel
- the 2nd footnote's attributes
java.lang.IllegalArgumentException
- if newNoteModel is null.getFootnote2()
,
setFootnote(com.sas.graphics.components.NoteModel, int)
,
NoteModel
public NoteModel getFootnote2()
setFootnote2(com.sas.graphics.components.NoteModel)
,
getFootnote(int)
,
NoteModel
public int getAppliedGraphStyleName()
applyGraphStyle(com.sas.graphics.components.GraphStyle)
,
isAppliedGraphStyleModified()
public boolean isAppliedGraphStyleModified()
appliedGraphStyleName
property is only modified when a graph style is applied.
The appliedGraphStyleModified
property is set to false when a
graph style is applied and set to true when display property
changes are detected.
Intended for internal use.
applyGraphStyle(com.sas.graphics.components.GraphStyle)
,
getAppliedGraphStyleName()
public int getAppliedColorSchemeName()
applyColorScheme(com.sas.graphics.components.ColorScheme)
public void applyGraphStyle(GraphStyle graphStyle)
Note: calling this method, wipes out any previously defined same visual attributes set on an individual graph. Any further customisation of the graph needs to happen after the applyGraphStyle method call.
graphStyle
- containing a set of visual attributes for the charts.public void applyColorScheme(ColorScheme scheme)
scheme
- a ColorScheme
containing a set of colors for the charts.protected com.sas.graphics.util.gl.Channel getChannel()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |