工具类
JGraphpadFileFilte
rJGraphpadFocusManager
JGraphpadMorphingManager
JGraphpadImageEncoder
JGraphpadImageIcon
JGraphpadShadowBorder
JGraphpadMouseAdapter
定制JGraph
JGraphpad
基于
JGraph
做了如下的定制:
• User objects and graph model to implement properties
• Cell view renderer for rich text, heavweights and shapes
• In-place editing of rich text and heavyweights
• Edge views to support moveable ports
• Transfer handler to implement drag and drop
• Marquee handler for event intercepting
User Object
用
com.jgraph.pad.graph.JGraphpadBusinessObject
实现
user object
用一个Map类型的
properties保存用户数据,
用String类型的
value属性供render使用。
根据
getTooltip
方法在
graph
中创建
tips
为了显示tip,提供一个特殊的JGraph类,该类唯一的功能是基于上面的getTooltip方法创建tips。
该类重写
getToolTipText
,
该方法找到鼠标所指的
cell
,然后调用
getToolTipForCell
(Object)
创建
tips
,创建
tips
的时候会用
user object
的
getTooltip
做参数。
在JGraphpad类的
configureGraph
方法中注册
tooltip manager
ToolTipManager.sharedInstance().registerComponent(graph);
Cloning
Editing
valueForCellChanged
getValue
Transactions:
JGraphpadGraphModel
为了支持
com.jgraph.pad.graph.JGraphpadBusinessObject
扩展了
handleAttributes
方法
Rendering
JGraphpadVertexRenderer
提供了一个通用
render
,它可以
render
JGraphpadVertexView
所有可能的配置(
rendering various shapes, gradient background, image scaling, rich text and redirecting to heavyweight value
)。
JGraphpadVertexRenderer
继承
VertexRenderer, VertexRenderer
继承
JLable
通用render
优点:
the reduced redundancy and complexity of the required cell type hierarchy and factory implementation
缺点
it requires special handling of fixed ports
when the shape is changed and makes the default renderer code considerably more complex
shape:
如果shape是rectangle,那么JLable可以负责绘制,
当shape不是retangle的时候,需要代码负责绘制(
背景和
border)
heavyweight:
heavyweight本身是一个component,因此重写
getRendererComponent
return new JComponent() {
public void paint(Graphics g) {
valueComponent.setSize(getSize());
if (graph.getEditingCell() != view.getCell())
valueComponent.paint(g);
}
};
The valueComponent is the actual heavyweight. The code is only invoked if the valueComponent is not null and creates a wrapper component around the heavyweight to avoid changes of its properties. The valueComponent variable is set in the installAttributes method or cleared in the resetAttributes method if installAttributes is not called, as controlled by the groupOpaque attribute defined by the core library
Rich text
render rich text
的方法:
混合使用
text component
和通用
render
的方式。
In-place editing
in-place editing
跟
render
一样,按
string
,
rich text
,
heavyweight
分类。
String
:默认
editor
,
其他:
if (obj.isRichText())
return editor;
else if (obj.isComponent())
return redirector;
鉴于
heavyweight
是一个
component
,因此用一个
component
为
editor
,由下面的方法完成:
getCellEditorComponent
method of the JGraphpadVertexView.RedirectorEditor class
,最后由
getCellEditorValue
返回
edit
结果。
对
rich text
使用
text pane
来
edit
,该
text pane
在
getCellEditorComponent
中配置。
Edit
结果由
getCellEditorValue
返回
moveable port
drag and drop
鼠标事件
JGraph的
控制流由
basic marquee handler.
中的鼠标
handler
定义。
Swing中的action listener chaining有些问题:
对已经注册的listener,不能通过注册新的listener而block对事件的处理。
因此,JGraph使用
marquee handler
来控制事件处理。
Popup menu
弹出菜单是鼠标右键事件的第一个处理,然后marquee handler接管控制,处理之后的其他响应。
Folding
the process of expanding and collapsing group cells, ie. showing or hiding
their children.
其他特性
edge groups
connecting edges
Edge promoting:
the process of painting edges along the parent group boundaries when
children are hidden
grouping by mouse
plugins
Internationalization
Browser Integration
Bean Shell
Codecs
EPS (Postscript)
JGX (JGraphpad 5.x)
L2FProd (UI Components)
Automatic Layout
PDF Export
SVG Export
Embedded Webserver