本文整理汇总了Java中org.jgraph.graph.GraphConstants.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java GraphConstants.setBounds方法的具体用法?Java GraphConstants.setBounds怎么用?Java GraphConstants.setBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgraph.graph.GraphConstants
的用法示例。
在下文中一共展示了GraphConstants.setBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startEditingAtCell
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
/**
* Selects the specified cell and initiates editing.
* The edit-attempt fails if the <code>CellEditor</code>
* does not allow
* editing for the specified item.
*/
public void startEditingAtCell(Object cell) {
graph.startEditingAtCell(cell);
if ((cell != null) && (cell instanceof JmtCell)) {
JmtCell jcell = (JmtCell) cell;
showStationParameterPanel(((CellComponent) jcell.getUserObject()).getKey(),
StationParameterPanel.INPUT_SECTION, null);
// Updates cell dimensions if name was changed too much...
Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
Dimension cellDimension = jcell.getSize(graph);
Map attr = jcell.getAttributes();
Rectangle2D oldBounds = GraphConstants.getBounds(attr);
if (oldBounds.getWidth() != cellDimension.getWidth()) {
GraphConstants.setBounds(attr, new Rectangle2D.Double(oldBounds.getX(), oldBounds.getY(),
cellDimension.getWidth(), cellDimension.getHeight()));
nest.put(cell, attr);
jcell.updatePortPositions(nest, GraphConstants.getIcon(attr), cellDimension);
graph.getGraphLayoutCache().edit(nest);
}
}
// Blocking region editing
else if ((cell != null) && (cell instanceof BlockingRegion)) {
showBlockingRegionParameterPanel(((BlockingRegion) cell).getKey());
}
}
示例2: setAttributes
import org.jgraph.graph.GraphConstants; //导入方法依赖的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;
}
示例3: setAttributes
import org.jgraph.graph.GraphConstants; //导入方法依赖的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;
}
示例4: positionVertexAt
import org.jgraph.graph.GraphConstants; //导入方法依赖的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);
}
示例5: evolvePosition
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
private void evolvePosition(GraphCell aCell, int movementX, int movementY) {
if (movementX != 0 || movementY != 0) {
Rectangle2D theBounds;
Map theAttributes = modelModifications.get(aCell);
if (theAttributes != null) {
theBounds = GraphConstants.getBounds(theAttributes);
} else {
theAttributes = new HashMap();
theBounds = GraphConstants.getBounds(aCell.getAttributes());
modelModifications.put(aCell, theAttributes);
}
theBounds.setRect(theBounds.getX() + movementX, theBounds.getY() + movementY, theBounds.getWidth(),
theBounds.getHeight());
GraphConstants.setBounds(theAttributes, theBounds);
}
}
示例6: positionVertexAt
import org.jgraph.graph.GraphConstants; //导入方法依赖的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);
}
示例7: layout
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
Map layout( ThreadModel thread_m )
{
Map attr = GraphConstants.createMap();
common( attr );
Coordinate c = (Coordinate) threadToCol.get( thread_m );
if ( c==null)
{
c = new Coordinate( threadToCol.size() +1, 0 );
threadToCol.put( thread_m, c );
}
Rectangle rec = new Rectangle( c.col*step_x + step_x/10, c.row*step_y, step_x - step_x/10, 3 * step_y/4 );
GraphConstants.setBounds( attr, rec );
c.row++;
threadToCol.put( thread_m, c );
return attr;
}
示例8: createCell
import org.jgraph.graph.GraphConstants; //导入方法依赖的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;
}
示例9: createVertex
import org.jgraph.graph.GraphConstants; //导入方法依赖的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());
}
示例10: createVertex
import org.jgraph.graph.GraphConstants; //导入方法依赖的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;
}
示例11: createBounds
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
public static Map createBounds(AttributeMap map, double x, double y, Dimension dimension, Color c, boolean moveable)
{
// final int ALPHA = 255;
GraphConstants.setBounds(map, map.createRect(x, y, dimension.getWidth(), dimension.getHeight()));
// GraphConstants.setBorder(map, BorderFactory.createBevelBorder(BevelBorder.RAISED));
GraphConstants.setForeground(map, Color.BLACK.darker().darker());//new Color(ALPHA - c.getRed(), ALPHA - c.getGreen(), ALPHA - c.getBlue(), ALPHA));
GraphConstants.setBackground(map, c.darker());
// Add a nice looking gradient background
GraphConstants.setGradientColor(map, c.darker());
// Make sure the cell is resized on insert
// GraphConstants.setSize();
// GraphConstants.setResize(map, true);
// Add a Border Color Attribute to the Map
GraphConstants.setBorderColor(map, Color.BLACK.darker().darker());
GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
GraphConstants.setMoveable(map, moveable);
GraphConstants.setOpaque(map, true);
GraphConstants.setResize(map, false);
GraphConstants.setAutoSize(map, true);
return map;
}
示例12: createBounds
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
public static Map createBounds(AttributeMap map, double x, double y, Dimension dimension, Color c, boolean moveable)
{
// final int ALPHA = 255;
GraphConstants.setBounds(map, map.createRect(x, y, dimension.getWidth(), dimension.getHeight()));
// GraphConstants.setBorder(map, BorderFactory.createBevelBorder(BevelBorder.RAISED));
GraphConstants.setForeground(map, Color.BLACK.darker().darker());//new Color(ALPHA - c.getRed(), ALPHA - c.getGreen(), ALPHA - c.getBlue(), ALPHA));
GraphConstants.setBackground(map, c.darker());
// Add a nice looking gradient background
GraphConstants.setGradientColor(map, c.darker());
// Make sure the cell is resized on insert
// GraphConstants.setSize();
// GraphConstants.setResize(map, true);
// Add a Border Color Attribute to the Map
GraphConstants.setBorderColor(map, Color.BLACK.darker().darker());
GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
GraphConstants.setMoveable(map, moveable);
GraphConstants.setOpaque(map, true);
GraphConstants.setResize(map, false);
GraphConstants.setAutoSize(map, true);
return map;
}
示例13: repositionSons
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
private void repositionSons(JmtCell padre, List<Object> sons, int numero, int cont) {
inRepositionSons = true;
Object[] listEdges = null;
GraphModel graphmodel = graph.getModel();
flag1 = true;
int j = 0;
Rectangle boundspadre = GraphConstants.getBounds(padre.getAttributes()).getBounds();
int w = boundspadre.y + ((heightMax + 35) * (numero + 1)) - 38;
for (int i = cont; i < sons.size(); i++) {
if (((JmtCell) sons.get(i)).seen == false) {
Rectangle bounds = GraphConstants.getBounds(((JmtCell) sons.get(i)).getAttributes()).getBounds();
bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
w - (int) (bounds.getHeight() / 2) + 80);
GraphConstants.setBounds(((JmtCell) sons.get(i)).getAttributes(), bounds);
((JmtCell) sons.get(i)).seen = true;
listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, sons.get(i));
if (listEdges.length > 0) {
flag = true;
j = searchNext((JmtCell) sons.get(i));
inRepositionSons = true;
}
if (j > 0) {
j = j - 1;
}
listEdges = null;
}
w = w + (heightMax + ((heightMax + 15) * j) + 30);
j = 0;
}
inRepositionSons = false;
}
示例14: positionVertexAt
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
private void positionVertexAt( Object vertex, int x, int y ) {
DefaultGraphCell cell = adapter.getVertexCell( vertex );
Map attr = cell.getAttributes( );
Rectangle b = GraphConstants.getBounds( attr ).getBounds();
GraphConstants.setBounds( attr, new Rectangle( x, y, b.width, b.height ) );
Map cellAttr = new HashMap( );
cellAttr.put( cell, attr );
adapter.edit( cellAttr, null, null, null );
}
示例15: startEditingAtCell
import org.jgraph.graph.GraphConstants; //导入方法依赖的package包/类
/**
* Selects the specified cell and initiates editing.
* The edit-attempt fails if the <code>CellEditor</code>
* does not allow
* editing for the specified item.
*/
public void startEditingAtCell(Object cell) {
graph.startEditingAtCell(cell);
if ((cell != null) && (cell instanceof JmtCell)) {
JmtCell jcell = (JmtCell) cell;
StationParameterPanel stationPanel = new jmt.gui.common.panels.StationParameterPanel(model, model,
((CellComponent) jcell.getUserObject()).getKey());
// Adds on the top a panel to change station name
stationPanel.add(new StationNamePanel(model, ((CellComponent) jcell.getUserObject()).getKey()), BorderLayout.NORTH);
dialogFactory.getDialog(stationPanel, "Editing " + jcell.getUserObject().toString() + " Properties...");
// Updates cell dimensions if name was changed too much...
Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
Dimension cellDimension = jcell.getSize(graph);
Map attr = jcell.getAttributes();
Rectangle2D oldBounds = GraphConstants.getBounds(attr);
if (oldBounds.getWidth() != cellDimension.getWidth()) {
GraphConstants.setBounds(attr, new Rectangle2D.Double(oldBounds.getX(), oldBounds.getY(), cellDimension.getWidth(), cellDimension
.getHeight()));
nest.put(cell, attr);
jcell.updatePortPositions(nest, GraphConstants.getIcon(attr), cellDimension);
graph.getGraphLayoutCache().edit(nest);
}
}
// Blocking region editing
else if ((cell != null) && (cell instanceof BlockingRegion)) {
Object regionKey = ((BlockingRegion) cell).getKey();
dialogFactory.getDialog(new BlockingRegionParameterPanel(model, model, regionKey), "Editing " + model.getRegionName(regionKey)
+ " Properties...");
}
}