Java Code Examples for org.jgraph.graph.GraphConstants#setBounds()

The following examples show how to use org.jgraph.graph.GraphConstants#setBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphVisitor.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
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;
    }
 
Example 2
Source File: Overview.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Add one one of our verticies to the overview
 *
 * @param theNode The node to be added
 */
public void addVertex(OverviewVertex theNode) {
	// The next call will fire a rendering. At this point, the model adapter
	// does not know
	// where it should place the node, and picks a default value. This will
	// cause an update
	// in our Node's x and y coordinates, making it forget where it was
	// initialized.
	// We store it's initializeded position so as not to lose them in the
	// first rendering.
	int initX = theNode.getX();
	int initY = theNode.getY();

	// Make sure the name is unique; increment it if not.
	if (isNameUsed(theNode.getName())) {
		theNode.setName(getNewName(theNode.getName()));
	}

	// Add our sketch to the graph
	getGraphLayoutCache().insert(theNode);

	// Add our vertex to the appropriate map
	if (theNode instanceof SketchNode) {
		_sketchNodes.put(theNode.toString(), (SketchNode) theNode);
		_appFrame.getInfoTreeUI().addSketch((SketchNode) theNode);
	} else if (theNode instanceof ViewNode) {
		_viewNodes.put(theNode.toString(), (ViewNode) theNode);
		_appFrame.getInfoTreeUI().addView((ViewNode) theNode);
	}

	// Set the on-screen position of our sketch to the attributes of the
	// sketch
	AttributeMap nAttribs = theNode.getAttributes();

	GraphConstants.setAutoSize(nAttribs, true);
	GraphConstants.setBounds(nAttribs, new Rectangle2D.Double(initX, initY, 0, 0));

	// Reload the graph to reflect the new changes
	refresh(theNode);
}
 
Example 3
Source File: TableCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
public TableCell(Table aTable) {
    super(aTable);

    GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(20,
            20, 40, 20));
    GraphConstants.setGradientColor(getAttributes(), Color.orange);
    GraphConstants.setOpaque(getAttributes(), false);
    GraphConstants.setAutoSize(getAttributes(), true);
    GraphConstants.setEditable(getAttributes(), true);
    addPort();
}
 
Example 4
Source File: TableCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferPropertiesToAttributes(Table aObject) {

    Point2D thePoint = aObject
            .getProperties().getPoint2DProperty(ModelItem.PROPERTY_LOCATION);
    if (thePoint != null) {
        GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(
                thePoint.getX(), thePoint.getY(), -1, -1));
    }
}
 
Example 5
Source File: ViewCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
public ViewCell(View aTable) {
    super(aTable);

    GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(20,
            20, 40, 20));
    GraphConstants.setGradientColor(getAttributes(), Color.orange);
    GraphConstants.setOpaque(getAttributes(), false);
    GraphConstants.setAutoSize(getAttributes(), true);
    GraphConstants.setEditable(getAttributes(), true);
    addPort();
}
 
Example 6
Source File: ViewCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferPropertiesToAttributes(View aObject) {

    Point2D thePoint = aObject
            .getProperties().getPoint2DProperty(ModelItem.PROPERTY_LOCATION);
    if (thePoint != null) {
        GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(
                thePoint.getX(), thePoint.getY(), -1, -1));
    }
}
 
Example 7
Source File: CommentCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
public CommentCell(Comment aTable) {
    super(aTable);

    GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(20,
            20, 40, 20));
    GraphConstants.setOpaque(getAttributes(), false);
    GraphConstants.setAutoSize(getAttributes(), true);
    GraphConstants.setResize(getAttributes(), true);
    GraphConstants.setEditable(getAttributes(), true);
}
 
Example 8
Source File: CommentCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferPropertiesToAttributes(Comment aObject) {

    Point2D thePoint = aObject
            .getProperties().getPoint2DProperty(ModelItem.PROPERTY_LOCATION);
    if (thePoint != null) {
        GraphConstants.setBounds(getAttributes(), new Rectangle2D.Double(
                thePoint.getX(), thePoint.getY(), 100, 100));
    }
}
 
Example 9
Source File: Main.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static void positionVertexAt(Object vertex, int x, int y) {
    DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();
    AttributeMap map = new AttributeMap();

    GraphConstants.setBounds(map, new Rectangle2D.Double(50, 50, 90, 30));
    GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder());
    GraphConstants.setBackground(map, Color.BLUE);
    GraphConstants.setForeground(map, Color.white);
    GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
    GraphConstants.setOpaque(map, true);

    Rectangle2D bounds = GraphConstants.getBounds(map);

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight());

    GraphConstants.setBounds(map, newBounds);
    GraphConstants.setBounds(attr, newBounds);

    AttributeMap cellAttr = new AttributeMap();

    if (findGoalByName((String) vertex).isSliced)
        cellAttr.put(cell, map);
    else
        cellAttr.put(cell, attr);

    jgAdapter.edit(cellAttr, null, null, null);
}
 
Example 10
Source File: AbstractGraphVertex.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Sets new value to horizontal and vertical positions
 * @param x
 * @param y
 */
public void setPosition(Point point) {
	
	Map attrs = new Hashtable();
	GraphConstants.setBounds(attrs, new Rectangle2D.Double(
			point.getX(), point.getY(), getDefaultWidth(), getDefaultHeight()));
			
	graph.getGraphLayoutCache().editCell(this, attrs);
	
	graph.repaint();
}
 
Example 11
Source File: TableCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setBounds(Rectangle2D aBounds) {
    GraphConstants.setBounds(getAttributes(), aBounds);
}
 
Example 12
Source File: ViewCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setBounds(Rectangle2D aBounds) {
    GraphConstants.setBounds(getAttributes(), aBounds);
}
 
Example 13
Source File: CommentCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setBounds(Rectangle2D aBounds) {
    GraphConstants.setBounds(getAttributes(), aBounds);
}