|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.ganttchart.GanttChart
public class GanttChart
The GanttChart is a Swing component that uses a GanttChartDataModel (data properties) and a GanttChartModel (display properties) to create a graphical scheduling tool for planning and managing a project. In its most basic form, a Gantt chart is a bar chart that plots project activities over time.
Graph
,
GraphStyle
,
NoteModel
,
GanttChartModel
,
GanttChartDataModel
,
GanttChartTableDataModel
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
RB_KEY
|
Fields inherited from class com.sas.graphics.components.Graph |
---|
footnoteContainer, titleContainer |
Constructor Summary | |
---|---|
GanttChart()
Construct a GanttChart using the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
GanttChart(GanttChartDataModel newGanttChartDataModel)
Construct a GanttChart, assigning ganttChartDataModel, and using the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
GanttChart(GanttChartDataModel newGanttChartDataModel,
GraphStyle newGraphStyle)
Construct a GanttChart assigning ganttChartDataModel and applying graphStyle. |
Method Summary | |
---|---|
void |
addLinkListener(java.awt.event.ActionListener l)
|
void |
applyColorScheme(ColorScheme scheme)
Apply a color scheme on this Graph. |
protected void |
applyDataModel()
Intended for internalUse only |
protected void |
applyGraphModel()
Intended for internalUse only |
void |
applyGraphStyle(GraphStyle graphStyle)
Apply the GraphStyle display properties onto the GanttChart. |
int |
convertRowIndexToModel(int viewRowIndex)
Maps the index of the row in the view at viewRowIndex to the index of the row in the table model. |
int |
convertRowIndexToView(int modelRowIndex)
Maps the index of the row in the table model at modelRowIndex to the index of the row in the view. |
protected void |
doPropertyChange(java.lang.String propertyName,
java.lang.Object oldProperty,
java.lang.Object newProperty)
Internal use only. |
int |
getDataLevelCount()
Returns the number of parent-child levels that will be displayed in the TableAxis if a hierarchial relationship has been defined in the data model set on the chart and a parent and task variables have been set on the chart. |
GanttChartDataModel |
getDataModel()
Returns the GanttChartDataModel that provides a handle to the data along with any associated mapping properties. |
int |
getDisplayPolicy()
Get how the graph is to utilize the display area when insufficient space is available. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this GanttChart. |
GanttChartModel |
getGraphModel()
Returns the GanttChartModel that encapsulates most of the GanttChart's display properties. |
java.awt.Color[] |
getLegendCategoryColors()
This method is for internal use only. |
java.lang.String[] |
getLegendCategoryValues()
This method is for internal use only. |
java.util.LinkedHashMap |
getLegendValuesHashMap()
The getter method for the HashMap legendValuesIndexMap from the LegendModel class. |
com.sas.graphics.util.PrintSupport |
getPrintSupport()
|
java.awt.Color |
getRowSelectionColor()
This method is for internal use only. |
java.util.Collection |
getTreeExpansionState()
This method is for internal use only. |
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. |
boolean |
isBgAndLogoDropDownOptionToBeDisabled()
This method return true when both the members bgImageBrowseOptionToBeDisabled and logoImageBrowseOptionToBeDisabled are true, which indicates that both options of background image and logo image have to be disabled. |
boolean |
isBgCheckBoxToBeDisabled()
This method checks the boolean value of the member bgImageBrowseOptionToBeDisabled and returns true or false accordingly, which indicates whether or not to disable the option for setting background image in the GanttChart. |
boolean |
isLogoCheckBoxToBeDisabled()
This method checks the boolean value of the member logoImageBrowseOptionToBeDisabled and returns true or false accordingly, which indicates whether or not to disable the option for setting logo image in the GanttChart. |
boolean |
isSortEnabled()
This method is for internal use only. |
void |
paintBackground(java.awt.Graphics g,
java.awt.Rectangle bounds,
java.awt.Insets insets)
Draw the background in a limited area. |
void |
prepareToPaint()
Notify this component that an application is about to call paint directly. |
void |
print()
Print using the current print settings. |
void |
print(com.sas.graphics.util.PrintSupport p)
Print using the given PrintSupport object. |
java.awt.Window |
printPreview()
|
void |
printSetup()
|
void |
removeLinkListener(java.awt.event.ActionListener l)
|
protected void |
selectionChanged()
Internal use only. |
void |
setAutoRepaintEnabled(boolean b)
Sets whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed. |
void |
setBgImageBrowseOptionToBeDisabled(boolean b)
This method is used to set the value of the boolean member bgImageBrowseOptionToBeDisabled. |
void |
setDataModel(GanttChartDataModel newDataModel)
Sets the GanttChartDataModel which provides a handle to the data along with any associated mapping properties to define the number and arrangement of data elements (i.e. gantt activity bars), legend and axes. |
void |
setDisplayPolicy(int newDisplayPolicy)
Set how the graph is to utilize the display area. |
void |
setFontForegroundColor(java.awt.Color newFontColor)
This method is for internal use only. |
protected void |
setGraph(javax.swing.JComponent newGraph)
For Internal use only! |
void |
setGraphModel(GanttChartModel newGanttChartModel)
Sets a GanttChartModel to define most of the GanttChart's display properties. |
void |
setHandCursorEnabled(boolean hand)
Change the cursor to a hand when over a bar. |
void |
setLogoImageBrowseOptionToBeDisabled(boolean b)
This method is used to set the value of the boolean member logoImageBrowseOptionToBeDisabled. |
void |
setPrintSupport(com.sas.graphics.util.PrintSupport ps)
|
void |
setRowSelectionColor(java.awt.Color newColor)
This method is for internal use only. |
void |
setRowSelectionFont(java.awt.Font newFont)
This method is for internal use only. |
void |
setSortEnabled(boolean sortEnable)
This method is for internal use only. |
void |
setTreeExpansionState(java.util.Collection expansionState)
This method is for internal use only. |
protected void |
updateDataModelListeners()
Internal use only. |
Field Detail |
---|
public static final java.lang.String RB_KEY
Constructor Detail |
---|
public GanttChart()
GraphStyle
public GanttChart(GanttChartDataModel newGanttChartDataModel)
A null GanttChartDataModel parameter is equivalent to using the default constructor.
newGanttChartDataModel
- the data to be used by this graphGraphStyle
,
GanttChartTableDataModel
public GanttChart(GanttChartDataModel newGanttChartDataModel, GraphStyle newGraphStyle)
newGanttChartDataModel
- provides a data handle with associated mapping propertiesnewGraphStyle
- the set of graph display propertiesNoteModel
,
GanttChartModel
,
GanttChartTableDataModel
Method Detail |
---|
public java.util.Collection getTreeExpansionState()
setTreeExpansionState(java.util.Collection)
public void setTreeExpansionState(java.util.Collection expansionState)
getTreeExpansionState()
public void setSortEnabled(boolean sortEnable)
isSortEnabled()
public boolean isSortEnabled()
setSortEnabled(boolean)
public java.lang.String[] getLegendCategoryValues()
public java.awt.Color[] getLegendCategoryColors()
public void setRowSelectionColor(java.awt.Color newColor)
public java.awt.Color getRowSelectionColor()
public void setRowSelectionFont(java.awt.Font newFont)
public void setFontForegroundColor(java.awt.Color newFontColor)
public void setGraphModel(GanttChartModel newGanttChartModel) throws java.lang.IllegalArgumentException
Typically applyGraphStyle is used to modify the graphs display properties.
newGanttChartModel
- the GanttChartModel that encapsulates the GanttChart's display properties
java.lang.IllegalArgumentException
- if newGanttChartModel is null.getGraphModel()
,
GanttChartModel.apply(com.sas.graphics.components.ganttchart.GanttChartModel)
,
GraphStyle
public GanttChartModel getGraphModel()
setGraphModel(com.sas.graphics.components.ganttchart.GanttChartModel)
,
GanttChartModel.apply(com.sas.graphics.components.ganttchart.GanttChartModel)
public void setDataModel(GanttChartDataModel newDataModel)
Any change in the GanttChartDataModel properties will cause the GanttChart to update. The update is asynchronous and delayed so modifying multiple properties in quick succession will result in only a single update. The FullPaintInterface can be used if greater control over the GanttChart's paint behavior is needed.
Note: Data value changes will also trigger GanttChart to update.
A valid GanttChartDataModel is required to draw a graph.
newDataModel
- provides a handle to the data
along with any associated mapping propertiesgetDataModel()
,
GanttChartTableDataModel
public GanttChartDataModel getDataModel()
setDataModel(com.sas.graphics.components.ganttchart.GanttChartDataModel)
,
GanttChartTableDataModel
public void setDisplayPolicy(int newDisplayPolicy) throws java.lang.IllegalArgumentException
When insufficient display area is available, the gantt chart uses scroll bars and only displays a portion of the graph and table.
GraphConstants.DISPLAY_SCROLL_AS_NEEDED is the default behavior and GraphConstants.DISPLAY_AUTOMATIC will behave behave the same way as scroll as needed. Specifing GraphConstants.DISPLAY_SCROLL_ENABLED and GraphConstants.FIT_TO_SCREEN have no meaning to the GanttChart.
The default value is GraphConstants.DISPLAY_SCROLL_AS_NEEDED.
Valid values are:
GraphConstants.DISPLAY_SCROLL_AS_NEEDED
GraphConstants.DISPLAY_SCROLL_ENABLED:
GraphConstants.DISPLAY_AUTOMATIC:
setDisplayPolicy
in class Graph
newDisplayPolicy
- how the Graph should utilize the dislay area
java.lang.IllegalArgumentException
- if newDisplayPolicy is invalid.getDisplayPolicy()
public int getDisplayPolicy()
getDisplayPolicy
in class Graph
setDisplayPolicy(int)
protected void applyGraphModel()
Graph
applyGraphModel
in class Graph
protected void applyDataModel()
Graph
applyDataModel
in class Graph
public int convertRowIndexToModel(int viewRowIndex)
viewRowIndex
- - the index of the row in the view
public int convertRowIndexToView(int modelRowIndex)
modelRowIndex
- - the index of the row in the table model
public void setHandCursorEnabled(boolean hand)
public int getDataLevelCount()
TableAxisModel
,
GanttChartTableDataModel
public 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 GanttChart graph = new GanttChart(); // 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."); } }
prepareToPaint
in class Graph
public void setAutoRepaintEnabled(boolean b)
The setting of this property to false implies that the application will be responsible for synchronizing the graph with its models using the prepareToPaint method.
Note: This method should NOT be used when also allowing interactive table editing. Unreliable results are sure to occur. This method was added to suport rendering into an off screen graphics context such as an image.
setAutoRepaintEnabled
in class Graph
b
- true means to automatically updateisAutoRepaintEnabled()
public boolean isAutoRepaintEnabled()
isAutoRepaintEnabled
in class Graph
setAutoRepaintEnabled(boolean)
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this GanttChart.
public void applyGraphStyle(GraphStyle graphStyle)
The GraphStyle enforces certain constraints that are not enforced on the Graph's display models (GanttChartModel and NoteModels). For example only one value text color may be specified on the GraphStyle, whereas the GanttChartModel supports setting different value text colors between axes, legends and data element text. Most presentations only require a single color for all types of value text, which is easily achieved by applying a GraphStyle.
Applying a GraphStyle will modify the display properties of the GanttChartModel and the title and footnote NoteModels. The GanttChart does not retain a link to the GraphStyle after this method has been called. Modifying any of the GraphStyle properties after this method has been called will have no affect on the GanttChart. Similarly modifying any of GanttChart's display properties after this method has been called will have no affect on the GraphStyle properties. To affect any change in the GanttChart display appearance the modified GraphStyle or a different GraphStyle would need to be applied again.
A blind PropertyChangeEvent is fired by the GanttChart after the apply is made.
No action is taken if a null GraphStyle is passed in.
applyGraphStyle
in class Graph
graphStyle
- the GraphStyle whose properties are conveyed to the GanttChartNoteModel
,
GanttChartModel
public void applyColorScheme(ColorScheme scheme)
Note: ColorScheme is currently geared towards solid fill colors only. Changing gradient and image fills will have to be handled by directly on the GanttChartModel.
applyColorScheme
in class Graph
scheme
- ColorScheme object containing a set of colors for the charts.protected void selectionChanged()
Graph
selectionChanged
in class Graph
protected void updateDataModelListeners()
updateDataModelListeners
in class Graph
Graph.updateDataModelListeners(Object model, Object selectionModel)
protected void doPropertyChange(java.lang.String propertyName, java.lang.Object oldProperty, java.lang.Object newProperty)
doPropertyChange
in class Graph
public void addLinkListener(java.awt.event.ActionListener l)
public void removeLinkListener(java.awt.event.ActionListener l)
protected void setGraph(javax.swing.JComponent newGraph)
Graph
setGraph
in class Graph
newGraph
- the graph value along with any assigned styles.
Note: a null graph value will cause the graph (if any) that is located at the specified position to be removed.
Note: if the message styles have not been assigned then the graph will determine the default styles by the position.
Graph.getGraph()
public void print(com.sas.graphics.util.PrintSupport p)
To customize your print settings, make a PrintSupport object, customize that, and then call this method.
The passed-in PrintSupport object is remembered and
used by subsequent calls to print()
,
which may allow the user to make interactive changes
to it through the print setup dialog.
p
- print(com.sas.graphics.util.PrintSupport)
public void print()
Print settings could be assigned by calling
print(PrintSupport)
, or by interactive
changes made in the print setup dialog.
print(PrintSupport)
public void setPrintSupport(com.sas.graphics.util.PrintSupport ps)
public com.sas.graphics.util.PrintSupport getPrintSupport()
public void printSetup()
public java.awt.Window printPreview()
public void paintBackground(java.awt.Graphics g, java.awt.Rectangle bounds, java.awt.Insets insets)
paintBackground
in class Graph
g
- - the graphics context with which to draw.bounds
- - size of area to paint. (x and y are unused?)insets
- - margin (?)public void setBgImageBrowseOptionToBeDisabled(boolean b)
b
- is the boolean variable whose value would be assigned to the member
bgImageBrowseOptionToBeDisabled.public void setLogoImageBrowseOptionToBeDisabled(boolean b)
b
- is the boolean variable whose value would be assigned to the member
logoImageBrowseOptionToBeDisabled.public boolean isBgCheckBoxToBeDisabled()
public boolean isLogoCheckBoxToBeDisabled()
public boolean isBgAndLogoDropDownOptionToBeDisabled()
public java.util.LinkedHashMap getLegendValuesHashMap()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |