本文整理汇总了Java中org.jgraph.JGraph类的典型用法代码示例。如果您正苦于以下问题:Java JGraph类的具体用法?Java JGraph怎么用?Java JGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JGraph类属于org.jgraph包,在下文中一共展示了JGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustDisplaySettings
import org.jgraph.JGraph; //导入依赖的package包/类
private void adjustDisplaySettings( JGraph jg ) {
jg.setPreferredSize( DEFAULT_SIZE );
Color c = DEFAULT_BG_COLOR;
String colorStr = null;
try {
colorStr = getParameter( "bgcolor" );
}
catch( Exception e ) {}
if( colorStr != null ) {
c = Color.decode( colorStr );
}
jg.setBackground( c );
}
示例2: paintSelectionBorder
import org.jgraph.JGraph; //导入依赖的package包/类
/**
* Provided for subclassers to paint a selection border.
*/
protected void paintSelectionBorder(Graphics g)
{
((Graphics2D) g).setStroke(GraphConstants.SELECTION_STROKE);
if (childrenSelected)
{
if(graph.get()!=null)
g.setColor(((JGraph)graph.get()).getGridColor());
}
else if (focus && selected)
{
if(graph.get()!=null)
g.setColor(((JGraph)graph.get()).getLockedHandleColor());
}
else if (selected)
{
g.setColor(getDecidedHighlightColor());
}
if (childrenSelected || selected)
{
Dimension d = getSize();
g.drawRect(0, 0, d.width-1, d.height-1);
}
}
示例3: setAttributes
import org.jgraph.JGraph; //导入依赖的package包/类
/**
* Sets all the attributes like background colour, dimensions, port number
* & position
*
* @param pt
* @return created map
*/
public Hashtable<Object, Map> setAttributes(Point2D pt, JGraph graph) {
//contains attributes of the cell & ports
Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
Dimension cellDimension = getSize(graph);
//contains attributes of the cell
Map attr = getAttributes();
GraphConstants.setBounds(attr, new Rectangle2D.Double(pt.getX(), pt.getY(), cellDimension.getWidth(), cellDimension.getHeight()));
GraphConstants.setEditable(attr, false);
GraphConstants.setBackground(attr, graph.getBackground());
nest.put(this, attr);
//create ports
ports = createPorts();
Icon icon = GraphConstants.getIcon(attr);
updatePortPositions(nest, icon, cellDimension);
for (Port port : ports) {
add((DefaultPort) port);
}
return nest;
}
示例4: setAttributes
import org.jgraph.JGraph; //导入依赖的package包/类
/**
* Sets all the attribults like background colour, dimensions, port number
* & position
* @param pt
* @return created map
*/
public Hashtable<Object, Map> setAttributes(Point2D pt, JGraph graph) {
//contains attribute of the cell & ports
Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
Dimension cellDimension = getSize(graph);
//contains attrib of cell
Map attr = getAttributes();
GraphConstants.setBounds(attr, new Rectangle2D.Double(pt.getX(), pt.getY(), cellDimension.getWidth(), cellDimension.getHeight()));
GraphConstants.setEditable(attr, false);
GraphConstants.setBackground(attr, graph.getBackground());
nest.put(this, attr);
//create ports
ports = createPorts();
Icon icon = GraphConstants.getIcon(attr);
updatePortPositions(nest, icon, cellDimension);
for (Port port : ports) {
add((DefaultPort) port);
}
return nest;
}
示例5: main
import org.jgraph.JGraph; //导入依赖的package包/类
public static void main(String[] args) {
setLookAndFeel();
DomainModel domainModel = new DomainModel();
domainModel.setPetriNet(new ListPetriNet());
JGraph graph = JGraphFactory.createGraph();
domainModel.setPetriNetGraph(graph);
GraphService graphService = new GraphServiceImpl(domainModel);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MainFrame mainFrame = new MainFrame(graphService);
mainFrame.setVisible(true);
}
});
}
示例6: testJGraph
import org.jgraph.JGraph; //导入依赖的package包/类
@Test
public void testJGraph() throws Exception {
GraphModel model = new DefaultGraphModel();
GraphLayoutCache view = new GraphLayoutCache(model, new DefaultCellViewFactory());
JGraph graph = new JGraph(model, view);
DefaultGraphCell[] cells = new DefaultGraphCell[3];
cells[0] = createCell("hello", true);
cells[1] = createCell("world", false);
DefaultEdge edge = new DefaultEdge();
GraphConstants.setLineStyle(edge.getAttributes(), GraphConstants.ARROW_LINE);
edge.setSource(cells[0].getChildAt(0));
edge.setTarget(cells[1].getChildAt(0));
cells[2] = edge;
graph.getGraphLayoutCache().insert(cells);
JOptionPane.showMessageDialog(null, new JScrollPane(graph));
}
示例7: getRendererComponent
import org.jgraph.JGraph; //导入依赖的package包/类
public Component getRendererComponent(JGraph graph, CellView view,
boolean sel, boolean focus, boolean preview) {
gridColor = graph.getGridColor();
highlightColor = graph.getHighlightColor();
lockedHandleColor = graph.getLockedHandleColor();
isDoubleBuffered = graph.isDoubleBuffered();
if (view instanceof VertexView) {
this.view = (VertexView)view;
this.hasFocus = focus;
this.childrenSelected = graph.getSelectionModel()
.isChildrenSelected(view.getCell());
this.selected = sel;
this.preview = preview;
if (this.view.isLeaf()
|| GraphConstants.isGroupOpaque(view.getAllAttributes()))
installAttributes(view);
else
resetAttributes();
return this;
}
return null;
}
示例8: handleMarqueeEvent
import org.jgraph.JGraph; //导入依赖的package包/类
public void handleMarqueeEvent(MouseEvent e, JGraph graph,
Rectangle2D bounds) {
// Snap the Point to the Grid
Rectangle2D snapBounds = graph.snap(bounds);
if ((bounds.getHeight() >= MIN_HEIGHT)
|| (bounds.getWidth() >= MIN_WIDTH)) {
// Create default TComponent vector
TComponent component = createDefaultComponent(snapBounds);
getBoard().getGraphLayoutCache().insert(component);
e.consume();
// Restore the marquee handler
getBoard().setMarqueeHandler(
new TBasicMarqueeHandler(getBoardContainer()));
}
}
示例9: CircleLaneView
import org.jgraph.JGraph; //导入依赖的package包/类
public CircleLaneView( FrontEndModel frontEndModel ) throws GUIException
{
super( new BorderLayout() );
setName( "CircleLane " + VERSION );
GraphApparence apparenceMgr = new CircleLaneApparence();
model = frontEndModel.getCircleLaneModel();
model.attach( apparenceMgr );
graph = new JGraph( model );
layoutMgr = new CircleLaneLayout( graph );
graph.setModel( model );
graph.setSelectNewCells(false);
graph.setEditable(false);
graph.setCloneable( false );
graph.setDropEnabled( false );
graph.setConnectable( false );
graph.setDisconnectable( false );
graph.addGraphSelectionListener( graphSelectionListener );
add( new JScrollPane( graph ) );
}
示例10: layout
import org.jgraph.JGraph; //导入依赖的package包/类
protected void layout( JGraph graph )
{
Set views = new TreeSet( comparator );
fillVertex( views );
int n = views.size();
int radius_x = (int) (Math.min( n*(max_w) , 1200 )/Math.PI);
int radius_y = (int) (Math.min( n*(max_h), 700 )/Math.PI);
double phi = 2*Math.PI / n;
int i=0;
for ( Iterator j=views.iterator(); j.hasNext(); ++i )
{
CellView view = (CellView) j.next();
double angle = phi*i;
int x = radius_x + (int)(Math.cos(angle) * radius_x);
int y = radius_y + (int)(Math.sin(angle) * radius_y);
setLocation( view, x, y );
}
}
示例11: adjustDisplaySettings
import org.jgraph.JGraph; //导入依赖的package包/类
private void adjustDisplaySettings(JGraph jg)
{
jg.setPreferredSize(DEFAULT_SIZE);
Color c = DEFAULT_BG_COLOR;
String colorStr = null;
try {
colorStr = getParameter("bgcolor");
} catch (Exception e) {
}
if (colorStr != null) {
c = Color.decode(colorStr);
}
jg.setBackground(c);
}
示例12: getRendererComponent
import org.jgraph.JGraph; //导入依赖的package包/类
public Component getRendererComponent(JGraph graph, CellView cellview, boolean sel, boolean focus, boolean preview)
{
if (cellview instanceof TableVertexView)
{
TableVertexView view = (TableVertexView) cellview;
DBGraphCell myCell = (DBGraphCell) view.getCell();
table = (DBTable) myCell.obj;
this.graph = graph;
this.hasFocus = focus;
this.selected = sel;
this.preview = preview;
setForeground(DEFAULT_FOREGROUND);
setBackground(DEFAULT_BACKGROUND);
setComponentOrientation(graph.getComponentOrientation());
return this;
}
return null;
}
示例13: setupGraph
import org.jgraph.JGraph; //导入依赖的package包/类
private JGraph setupGraph() {
// Construct Model and Graph
GraphModel model = new DefaultGraphModel();
JGraph graph = new JGraph(model);
// Control-drag should clone selection
graph.setCloneable(true);
// Enable edit without final RETURN keystroke
graph.setInvokesStopCellEditing(true);
// When over a cell, jump to its default port (we only have one, anyway)
graph.setJumpToDefaultPort(true);
return graph;
}
示例14: getRendererComponent
import org.jgraph.JGraph; //导入依赖的package包/类
/**
* Overrides the parent implementation to return the value component stored
* in the user object instead of this renderer if a value component exists.
* This applies some of the values installed to this renderer to the value
* component (border, opaque) if the latter is a JComponent.
*
* @return Returns a configured renderer for the specified view.
*/
@Override
public Component getRendererComponent(JGraph graph, CellView view,
boolean sel, boolean focus, boolean preview) {
isSelected = sel;
graphForeground = graph.getForeground();
isGroup = view.getCell() instanceof GroupVertex;
isPhenodata = view.getCell() instanceof PhenodataVertex;
if(view.getCell() instanceof AbstractGraphVertex){
if(isGroup){
vertex = (GroupVertex)view.getCell();
} else if(isPhenodata){
vertex = (PhenodataVertex)view.getCell();
} else {
vertex = (GraphVertex)view.getCell();
}
}
this.graph = graph;
return super.getRendererComponent(graph, view, sel, focus, preview);
}
示例15: doAction
import org.jgraph.JGraph; //导入依赖的package包/类
/**
* The abstract function that descendant classes must be overridden to provide customsized handling.
*
* @param e
* @return true if the action is finished successfully; otherwise, return false.
*/
protected boolean doAction(ActionEvent e)
{
// Log.logInfo(this, "GraphDeleteAction's actionPerformed() is called.");
JGraph graph = getController().getGraph();
// if (!graph.isSelectionEmpty())
// {
int userChoice = JOptionPane.showConfirmDialog(getMiddlePanel(),
"ALL mappings will be deleted, are you sure?", "Question",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (userChoice == JOptionPane.YES_OPTION)
{
getController().handleDeleteAll();
}
// }
// else
// {
// JOptionPane.showMessageDialog(getMiddlePanel(), "No graph is currently selected.", "No selection", JOptionPane.WARNING_MESSAGE);
// }
setSuccessfullyPerformed(true);
return isSuccessfullyPerformed();
}