本文整理汇总了Java中org.jgraph.graph.DefaultGraphCell类的典型用法代码示例。如果您正苦于以下问题:Java DefaultGraphCell类的具体用法?Java DefaultGraphCell怎么用?Java DefaultGraphCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultGraphCell类属于org.jgraph.graph包,在下文中一共展示了DefaultGraphCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: positionVertexAt
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void positionVertexAt (Object vertex,
int x,
int y)
{
DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
AttributeMap attr = cell.getAttributes();
Rectangle2D bounds = GraphConstants.getBounds(attr);
Rectangle2D newBounds = new Rectangle2D.Double(
x,
y,
bounds.getWidth(),
bounds.getHeight());
GraphConstants.setBounds(attr, newBounds);
// TODO: Clean up generics once JGraph goes generic
AttributeMap cellAttr = new AttributeMap();
cellAttr.put(cell, attr);
jgAdapter.edit(cellAttr, null, null, null);
}
示例2: commandAddToNewSubjectArea
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
/**
* Create a new subject area for a set of cells.
*
* @param aCells the cells to add to the subject area
*/
public void commandAddToNewSubjectArea(List<DefaultGraphCell> aCells) {
SubjectArea theArea = new SubjectArea();
theArea.setExpanded(true);
SubjectAreaCell theSubjectAreaCell = new SubjectAreaCell(theArea);
for (DefaultGraphCell theCell : aCells) {
Object theUserObject = theCell.getUserObject();
if (theUserObject instanceof Table) {
theArea.getTables().add((Table) theUserObject);
}
if (theUserObject instanceof View) {
theArea.getViews().add((View) theUserObject);
}
}
getGraphLayoutCache().insertGroup(theSubjectAreaCell, aCells.toArray());
model.addSubjectArea(theArea);
getGraphLayoutCache().toBack(new Object[]{theSubjectAreaCell});
}
示例3: removeFromGraph
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
public void removeFromGraph(Object[] cells) {
for (Object cell : cells) {
DefaultGraphCell graphCell = CustomCellViewFactory.tryCastToCell(cell);
if (graphCell != null) {
for (Object child : graphCell.getChildren()) {
Port port = CustomCellViewFactory.tryCastToPort(child);
if (port != null) {
ArrayList edges = Lists.newArrayList(port.edges());
edges.forEach(this::removeFromGraph);
}
}
}
model.getPetriNetGraph().getGraphLayoutCache().remove(new Object[]{cell});
synhronizeRemoveFromGraph(cell);
}
refreshMatrix();
invalidateReachabilityGraph();
}
示例4: testJGraph
import org.jgraph.graph.DefaultGraphCell; //导入依赖的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));
}
示例5: positionVertexAt
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
@SuppressWarnings("unchecked") // FIXME hb 28-nov-05: See FIXME below
private void positionVertexAt(Object vertex, int x, int y)
{
DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
AttributeMap attr = cell.getAttributes();
Rectangle2D bounds = GraphConstants.getBounds(attr);
Rectangle2D newBounds =
new Rectangle2D.Double(
x,
y,
bounds.getWidth(),
bounds.getHeight());
GraphConstants.setBounds(attr, newBounds);
// TODO: Clean up generics once JGraph goes generic
AttributeMap cellAttr = new AttributeMap();
cellAttr.put(cell, attr);
jgAdapter.edit(cellAttr, null, null, null);
}
示例6: createCell
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
/**
* Creates a new JGraph cell with the specified rendering information.
*
* @param name String that is the cell name.
* @param x Double that is the X coordinate.
* @param y Double that is the Y coordinate.
* @param scale Double that is the scale information.
* @param color Color of the future graph cell.
* @return DMGraph cell generated with the specified rendering information.
* @throws Exception
*/
public static DefaultGraphCell createCell(String name, double x, double y,
double scale, Color color) throws Exception {
DefaultGraphCell cell = new DefaultGraphCell(name);
GraphConstants.setBounds(cell.getAttributes(),
new Rectangle2D.Double(x, y, scale, scale));
GraphConstants.setBorder(cell.getAttributes(),
BorderFactory.createRaisedBevelBorder());
GraphConstants.setOpaque(cell.getAttributes(), true);
cell.addPort(new Point2D.Double(0, 0));
if (color != null) {
GraphConstants.setGradientColor(cell.getAttributes(), color);
} else {
GraphConstants.setGradientColor(cell.getAttributes(), Color.BLUE);
}
return cell;
}
示例7: createVertex
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
private void createVertex(DefaultGraphCell cell, double x, double y, double w, double h)
{
// Set bounds
GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(x, y, w, h));
GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createRaisedBevelBorder());
GraphConstants.setEditable(cell.getAttributes(), false);
GraphConstants.setSizeable(cell.getAttributes(), true);
GraphConstants.setAutoSize(cell.getAttributes(), false);
GraphConstants.setRouting(cell.getAttributes(), GraphConstants.ROUTING_SIMPLE);
GraphConstants.setBendable(cell.getAttributes(), true);
// Add a Floating Port
hmPorts.put(cell.getUserObject(), cell.addPort());
}
示例8: getSelectedObjectType
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
/**
* returns the type of the selected object in the graph
* 1: Selected object is of type DBTableGenerator
* 2: DBCardinalityGenerator
* 0: Something else!
*/
private int getSelectedObjectType()
{
Object oSelectedObject;
if (!graph.isSelectionEmpty())
{
oSelectedObject = ((DefaultGraphCell) graph.getSelectionCell()).getUserObject();
if (oSelectedObject != null)
{
if (oSelectedObject instanceof DBTableGenerator)
{
return 1;
}
if (oSelectedObject instanceof DBCardinalityGenerator)
{
return 2;
}
}
}
return 0;
}
示例9: createVertex
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
public DefaultGraphCell createVertex(String name, double x, double y, Color bg, boolean raised) {
// Create vertex with the given name
DefaultGraphCell cell = new DefaultGraphCell(name);
GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createEtchedBorder());
GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(x, y, 10, 10));
GraphConstants.setResize(cell.getAttributes(), true);
GraphConstants.setAutoSize(cell.getAttributes(), true);
// Set fill color
if (bg != null) {
GraphConstants.setOpaque(cell.getAttributes(), true);
GraphConstants.setGradientColor(cell.getAttributes(), bg);
}
// Set raised border
if (raised)
GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createRaisedBevelBorder());
else
// Set black border
GraphConstants.setBorderColor(cell.getAttributes(), Color.black);
return cell;
}
示例10: unhandled_node
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
@Override
protected Object unhandled_node(SimpleNode node) throws Exception {
DefaultGraphCell cell = null;
String caption = node.toString();
parentAddPort();
cell = createVertex(caption, indent, depth, nodeColor, false);
DefaultEdge edge = createConnection(cell);
cells.add(cell);
cells.add(edge);
incrementPosition(cell);
return null;
}
示例11: MappingViewCommonComponent
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
public MappingViewCommonComponent(MappableNode sourceNode, MappableNode targetNode,
DefaultGraphCell sourceCell, DefaultGraphCell targetCell, DefaultEdge linkEdge)
{
if(sourceNode==null)
{
throw new IllegalArgumentException("Source Node cannot be null!");
}
if(targetNode==null)
{
throw new IllegalArgumentException("Target Node cannot be null!");
}
// MappableNode localSourceNode = null;
// MappableNode localTargetNode = null;
determineSourceAndTargetNode(sourceNode, sourceCell);
determineSourceAndTargetNode(targetNode, targetCell);
this.linkEdge = linkEdge;
// this.sourceNode = sourceNode;
// this.targetNode = targetNode;
// this.sourceCell = sourceCell;
// this.targetCell = targetCell;
}
示例12: isCellRemovable
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
/**
* test if the given cell may cause sourceCell or targetCell removable
* @param cell
* @return if the given cell may cause sourceCell or targetCell removable
*/
private boolean isCellRemovable(DefaultGraphCell cell)
{
boolean result = sourceCell.equals(cell) || targetCell.equals(cell);
// if(result)
// {
if(!(cell instanceof DefaultPort))
{
Set edgeSet = ((DefaultPort) cell.getChildAt(0)).getEdges();
result = result && !(cell instanceof FunctionBoxDefaultPort) && (edgeSet.isEmpty() || edgeSet.size()==1);
}
else
{//if cell is an instance of DefaultPort, port is not removable.
result = false;
}
// }
return result;
}
示例13: highlightTreeNodeInTree
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
private void highlightTreeNodeInTree(Object object)
{
if (object instanceof DefaultGraphCell |!(object instanceof DefaultMutableTreeNode))
return;
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) object;
JTree tree=null;
MappingMainPanel mappingPanel= graphController.getMappingPanel();
if (treeNode instanceof DefaultSourceTreeNode)
tree=mappingPanel.getSourceTree();
else if (treeNode instanceof DefaultTargetTreeNode)
tree=mappingPanel.getTargetTree();
if (tree==null)
return;
TreePath treePath = new TreePath(treeNode.getPath());
tree.setSelectionPath(treePath);
}
示例14: MappingViewCommonComponent
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
public MappingViewCommonComponent(MappableNode sourceNode, MappableNode targetNode,
DefaultGraphCell sourceCell, DefaultGraphCell targetCell, DefaultEdge linkEdge)
{
if(sourceNode==null)
{
throw new IllegalArgumentException("Source Node cannot be null!");
}
if(targetNode==null)
{
throw new IllegalArgumentException("Target Node cannot be null!");
}
// determineSourceAndTargetNode(sourceNode, sourceCell);
// determineSourceAndTargetNode(targetNode, targetCell);
this.linkEdge = linkEdge;
this.sourceNode = sourceNode;
this.targetNode = targetNode;
this.sourceCell = sourceCell;
this.targetCell = targetCell;
}
示例15: isCellRemovable
import org.jgraph.graph.DefaultGraphCell; //导入依赖的package包/类
/**
* test if the given cell may cause sourceCell or targetCell removable
* @param cell
* @return if the given cell may cause sourceCell or targetCell removable
*/
private boolean isCellRemovable(DefaultGraphCell cell)
{
boolean result = sourceCell.equals(cell) || targetCell.equals(cell);
// if(result)
// {
if(!(cell instanceof DefaultPort))
{
Set edgeSet = ((DefaultPort) cell.getChildAt(0)).getEdges();
// result = result && !(cell instanceof FunctionBoxDefaultPort) && (edgeSet.isEmpty() || edgeSet.size()==1);
}
else
{//if cell is an instance of DefaultPort, port is not removable.
result = false;
}
// }
return result;
}