org.jgraph.graph.GraphConstants Java Examples

The following examples show how to use org.jgraph.graph.GraphConstants. 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: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for partial edges.
 *
 * @return a map of attributes to be used for partial edges
 */
private AttributeMap partialEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_LINE);
	GraphConstants.setBeginFill(map, true);
	GraphConstants.setBeginSize(map, 15);

	Color color = getColor(_mode + "edge_partial");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_partial", 1.5));

	return map;
}
 
Example #2
Source File: View.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Checks to see if any of the query nodes have moved and, if so, updates them
 * and sets the view to dirty. If the view is already dirty, we don't have to do
 * anything at all.
 */
public void checkDirty() {
	if (_dirty) {
		return;
	}

	for (QueryNode n : _nodes.values()) {
		if (n == null) {
			// not sure why this would ever be null
		} else {
			Rectangle2D newBounds = GraphConstants.getBounds(n.getAttributes());
			if ((int) newBounds.getX() != n.getLastKnownX()) {
				setDirty(true);
				return;
			}
		}
	}

}
 
Example #3
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 #4
Source File: OverviewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns an attribute map for Overview view edges
 *
 *
 * @param edge
 * @return a map of attributes to be used for a sketchnode
 */
public static AttributeMap viewEdgeAttributes(ViewDefinitionEdge edge) {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);

	Color color = getColor("edge_overview_view");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth("edge_overview_view", 1.5));

	return map;
}
 
Example #5
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for injective edges.
 *
 * @return a map of attributes to be used for new injective edges
 */
private AttributeMap injectiveEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_DIAMOND);
	GraphConstants.setBeginFill(map, false);
	GraphConstants.setBeginSize(map, 15);

	Color color = getColor(_mode + "edge_injective");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_injective", 1.5));

	return map;
}
 
Example #6
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns an attribute map for normal (non-injective, non-partial) edges.
 *
 * @return a map of attributes to be used for new normal edges
 */
private AttributeMap normalEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);

	Color color = getColor(_mode + "edge_normal");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_normal", 1.5));

	return map;
}
 
Example #7
Source File: OverviewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 *
 * @param vertex
 *
 * @return
 */
private static AttributeMap commonVertexAttributes(OverviewVertex vertex) {
	AttributeMap map = new AttributeMap();

	GraphConstants.setAutoSize(map, true);
	GraphConstants.setInset(map, 5);
	GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12));
	GraphConstants.setOpaque(map, true);

	ImageIcon icon = vertex.getThumbnail();

	if (icon != null) {
		GraphConstants.setIcon(map, vertex.getThumbnail());
	} else {
		GraphConstants.setIcon(map, new ImageIcon());
	}

	GraphConstants.setVerticalTextPosition(map, SwingConstants.TOP);

	return map;
}
 
Example #8
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for virtual edges.
 *
 * @return a map of attributes to be used for new virtual edges
 */
private AttributeMap virtualEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_NONE);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_NONE);
	GraphConstants.setDashPattern(map, new float[] { 5.0f, 3.0f });

	Color color = getColor(_mode + "edge_virtual");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_virtual", 1.5));

	return map;
}
 
Example #9
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns an attribute map for normal (non-injective, non-partial) edges.
 *
 * @return a map of attributes to be used for new normal edges
 */
private AttributeMap normalEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);

	Color color = getColor(_mode + "edge_normal");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_normal", 1.5));

	return map;
}
 
Example #10
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for injective edges.
 *
 * @return a map of attributes to be used for new injective edges
 */
private AttributeMap injectiveEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_DIAMOND);
	GraphConstants.setBeginFill(map, false);
	GraphConstants.setBeginSize(map, 15);

	Color color = getColor(_mode + "edge_injective");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_injective", 1.5));

	return map;
}
 
Example #11
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for partial edges.
 *
 * @return a map of attributes to be used for partial edges
 */
private AttributeMap partialEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setEndFill(map, true);
	GraphConstants.setEndSize(map, 10);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_LINE);
	GraphConstants.setBeginFill(map, true);
	GraphConstants.setBeginSize(map, 15);

	Color color = getColor(_mode + "edge_partial");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_partial", 1.5));

	return map;
}
 
Example #12
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the attribute map for virtual edges.
 *
 * @return a map of attributes to be used for new virtual edges
 */
private AttributeMap virtualEdgeAttributes() {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, GraphConstants.ARROW_NONE);
	GraphConstants.setLineBegin(map, GraphConstants.ARROW_NONE);
	GraphConstants.setDashPattern(map, new float[] { 5.0f, 3.0f });

	Color color = getColor(_mode + "edge_virtual");

	GraphConstants.setLineColor(map, color);
	GraphConstants.setForeground(map, color);
	GraphConstants.setLineWidth(map, getWidth(_mode + "edge_virtual", 1.5));

	return map;
}
 
Example #13
Source File: ModelConstraint.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Removes the visuals from the sketch (when hiding)
 */
private void removeVisualsFromModel() {
	// Push loading state
	_theModel.getStateManager().pushState(new LoadingState<>(_theModel));
	_theModel.getGraphModel().beginInsignificantUpdate();

	GraphLayoutCache glc = _theModel.getGraphLayoutCache();

	glc.remove(_visuals.toArray(new GuideEdge[0]));
	_visuals.clear();

	_edgesVisualized = false;

	GraphConstants.setSelectable(getAttributes(), false);
	_theModel.refresh();
	_theModel.getGraphModel().cancelInsignificantUpdate();

	// Pop state
	_theModel.getStateManager().popState();
}
 
Example #14
Source File: GetPathState.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * When pushed on, the first thing done is clearing the selection and then
 * disabling selection for all items except for edges.
 */
@Override
@SuppressWarnings("rawtypes")
public void pushedOn() {
	setNextButton(false);
	setCancelButton(true);
	setFinishButton(false);

	_selectable = new Hashtable();
	_unselectable = new Hashtable();

	GraphConstants.setSelectable(_selectable, true);
	GraphConstants.setSelectable(_unselectable, false);

	// Initially, we allow all edges and entities to be selected
	_ourModel.clearSelection();
	_ourModel.refresh();

	// Gets pushed on by all "add constraint" states. We don't want to be
	// able to imbed adding constraints
	_ourModel.getFrame().enableAddConstraintItems(false);
}
 
Example #15
Source File: GetFullyDefinedPathState.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * When pushed on, the first thing done is clearing the selection and then
 * disabling selection for all items except for edges.
 */
@Override
@SuppressWarnings("rawtypes")
public void pushedOn() {
	setNextButton(false);
	setCancelButton(true);
	setFinishButton(false);

	_selectable = new Hashtable();
	_unselectable = new Hashtable();

	GraphConstants.setSelectable(_selectable, true);
	GraphConstants.setSelectable(_unselectable, false);

	// Initially, we allow all edges and entities to be selected
	_ourModel.clearSelection();
	_ourModel.refresh();

	// Gets pushed on by all "add constraint" states. We don't want to be
	// able to imbed adding constraints
	_ourModel.getFrame().enableAddConstraintItems(false);
}
 
Example #16
Source File: RelationEdge.java    From MogwaiERDesignerNG with GNU General Public License v3.0 6 votes vote down vote up
public RelationEdge(Relation aRelation, TableCell aImporting, TableCell aExporting) {

        super(aRelation);

        GraphConstants.setLineStyle(getAttributes(), GraphConstants.STYLE_ORTHOGONAL);
        GraphConstants.setConnectable(getAttributes(), false);
        GraphConstants.setDisconnectable(getAttributes(), false);
        GraphConstants.setBendable(getAttributes(), true);

        GraphConstants.setLineWidth(getAttributes(), 1);
        GraphConstants.setLineBegin(getAttributes(), LINE_BEGIN);
        GraphConstants.setLineEnd(getAttributes(), LINE_END);

        setSource(aImporting.getChildAt(0));
        setTarget(aExporting.getChildAt(0));
    }
 
Example #17
Source File: EasikGraphModel.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the common attribute mapping for edges. Used by
 * normalEdgeAttributes() et al. to establish the common attributes for an edge.
 * 
 * @return The attribute mapping
 */
@SuppressWarnings("static-access")
public static AttributeMap commonEdgeAttributes() {
	AttributeMap map = new AttributeMap();

	GraphConstants.setLabelAlongEdge(map, true);
	GraphConstants.setBendable(map, false);
	GraphConstants.setMoveable(map, false);
	GraphConstants.setConnectable(map, false);
	GraphConstants.setDisconnectable(map, false);

	EdgeRouter er = EdgeRouter.getSharedInstance();

	er.setEdgeSeparation(20.0);
	er.setEdgeDeparture(50.0);
	GraphConstants.setRouting(map, er);
	GraphConstants.setLineStyle(map, GraphConstants.STYLE_SPLINE);

	return map;
}
 
Example #18
Source File: VertexCellElement.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Point getLocation() {

    GraphCell theCell = getCell();
    Rectangle2D theBounds = GraphConstants.getBounds(theCell.getAttributes());
    return new Point((int) theBounds.getX(), (int) theBounds.getY());
}
 
Example #19
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 #20
Source File: RelationTool.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
protected void paintPort(Graphics g) {
    if (port != null) {
        boolean o = (GraphConstants.getOffset(port.getAllAttributes()) != null);
        Rectangle2D r = (o) ? port.getBounds() : port.getParentView().getBounds();
        r = graph.toScreen((Rectangle2D) r.clone());
        r.setFrame(r.getX() - 3, r.getY() - 3, r.getWidth() + 6, r.getHeight() + 6);
        graph.getUI().paintCell(g, port, r, true);
    }
}
 
Example #21
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 #22
Source File: MicroarrayGraph.java    From chipster with MIT License 5 votes vote down vote up
private static void setDerivationEdgeStyle(DefaultEdge edge) {
	setEdgeStyle(edge);
	GraphConstants.setLineBegin(edge.getAttributes(), GraphConstants.ARROW_TECHNICAL);
	GraphConstants.setBeginFill(edge.getAttributes(), true);
	GraphConstants.setBeginSize(edge.getAttributes(), 5);
	GraphConstants.setLineWidth(edge.getAttributes(), 1);
}
 
Example #23
Source File: RelationEdge.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferPropertiesToAttributes(Relation aRelation) {
    Point2D thePoint;

    // PROPERTY_TEXT_OFFSET
    // skip processing of the offset-property, instead remove it from
    // relation to be compatible to earlier versions
    thePoint = aRelation.getProperties().getPoint2DProperty(
            Relation.PROPERTY_TEXT_OFFSET);
    if (thePoint != null) {
        GraphConstants.setOffset(getAttributes(), thePoint);
    }

    // PROPERTY_LABEL_POSITION)
    // instead of storing the offset, store the location of the label now
    thePoint = aRelation.getProperties().getPoint2DProperty(
            Relation.PROPERTY_LABEL_POSITION);
    if (thePoint != null) {
        GraphConstants.setLabelPosition(getAttributes(), thePoint);
    }

    // PROPERTY_POINTS
    String thePoints = aRelation.getProperties().getProperty(Relation.PROPERTY_POINTS);
    if (thePoints != null) {
        List<Point2D> thePointList = new ArrayList<>();

        for (StringTokenizer theSt = new StringTokenizer(thePoints, ","); theSt.hasMoreTokens(); ) {
            thePoint = ModelProperties.toPoint2D(theSt.nextToken());
            thePointList.add(thePoint);
        }

        GraphConstants.setPoints(getAttributes(), thePointList);
    }
}
 
Example #24
Source File: RelationEdge.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferAttributesToProperties(Map aAttributes) {
    Relation theRelation = (Relation) getUserObject();

    // PROPERTY_TEXT_OFFSET
    Point2D theOffset = GraphConstants.getOffset(aAttributes);
    if (theOffset != null) {
        theRelation.getProperties().setPointProperty(Relation.PROPERTY_TEXT_OFFSET, (int) theOffset.getX(), (int) theOffset.getY());
    }

    // PROPERTY_LABEL_POSITION
    Point2D theLabelPosition = GraphConstants.getLabelPosition(aAttributes);
    if (theLabelPosition != null) {
        theRelation.getProperties().setPointProperty(Relation.PROPERTY_LABEL_POSITION, (int) theLabelPosition.getX(), (int) theLabelPosition.getY());
    }

    // PROPERTY_POINTS
    List<Point2D> thePoints = GraphConstants.getPoints(aAttributes);
    if (thePoints != null) {
        StringBuilder theBuffer = new StringBuilder();

        for (Point2D thePoint : thePoints) {
            if (theBuffer.length() > 0) {
                theBuffer.append(",");
            }

            theBuffer.append(ModelProperties.toString(thePoint));
        }

        String thePointBuffer = theBuffer.toString();
        theRelation.getProperties().setProperty(Relation.PROPERTY_POINTS, thePointBuffer);
    }
}
 
Example #25
Source File: AbstractGraphVertex.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Constructor for graph
 * 
 * @param x
 * @param y
 * @param data
 * @param graph
 */
public AbstractGraphVertex(int x, int y, DataItem data,
		MicroarrayGraph graph) {
	super(data);
	this.graph = graph;
	this.setPosition(new Point(x,y));
	
	GraphConstants.setGradientColor(
			this.getAttributes(),
			DEFAULT_VERTEX_COLOR);
	
	GraphConstants.setBorderColor(
			this.getAttributes(), 
			Color.black);
	
	GraphConstants.setOpaque(
			this.getAttributes(), 
			true);
	
	GraphConstants.setVerticalAlignment(
			this.getAttributes(), 
			JLabel.TOP);
	
	Font font = GraphConstants.getFont(this.getAttributes());
	font = font.deriveFont((float)font.getSize() + 3);
	GraphConstants.setFont(this.getAttributes(), font);
}
 
Example #26
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 #27
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 #28
Source File: TableCell.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void transferAttributesToProperties(Map aAttributes) {

    Table theTable = (Table) getUserObject();
    Rectangle2D theBounds = GraphConstants.getBounds(aAttributes);
    theTable.getProperties().setPointProperty(ModelItem.PROPERTY_LOCATION,
            (int) theBounds.getX(), (int) theBounds.getY());
}
 
Example #29
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 #30
Source File: ModelVertex.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Accessor for the Y Coordinate
 * 
 * @return The Y Coordinate
 */
public int getY() {
	Rectangle2D bounds = GraphConstants.getBounds(getAttributes());

	if (bounds != null) {
		return (int) bounds.getY();
	}
	return _initY;

}