工具类
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