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

The following examples show how to use org.jgraph.graph.GraphConstants#setLineColor() . 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: 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 2
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 3
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 4
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 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 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 6
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 7
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 8
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 9
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 10
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * TRIANGLES CF2012 Set the attributes for display of a triangle edge.
 * 
 * @param edge the edge to read attributes from
 * @return a map of attributes to be used for new triangle edges
 */
private static AttributeMap triangleEdgeAttributes(
		TriangleEdge<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge> edge) {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, edge.getLineEnd());
	GraphConstants.setLineBegin(map, edge.getLineBegin());
	GraphConstants.setLineWidth(map, edge.getWidth());
	GraphConstants.setLineColor(map, edge.getColor());
	GraphConstants.setForeground(map, edge.getColor());
	GraphConstants.setDashPattern(map, new float[] { edge.getWidth(), 3 });

	return map;
}
 
Example 11
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns the attribute map for highlighted virtual edges.
 *
 * @return a map of attributes to be used for highlighted virtual edges
 */
private AttributeMap virtualHighlightedEdgeAttributes() {
	AttributeMap map = virtualEdgeAttributes();
	Color color = getColor(_mode + "edge_virtual_highlighted");

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

	return map;
}
 
Example 12
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * TRIANGLES CF2012 Set the attributes for display of a triangle edge.
 * 
 * @param edge the edge to read attributes from
 * @return a map of attributes to be used for new triangle edges
 */
private static AttributeMap triangleEdgeAttributes(
		TriangleEdge<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge> edge) {
	AttributeMap map = commonEdgeAttributes();

	GraphConstants.setLineEnd(map, edge.getLineEnd());
	GraphConstants.setLineBegin(map, edge.getLineBegin());
	GraphConstants.setLineWidth(map, edge.getWidth());
	GraphConstants.setLineColor(map, edge.getColor());
	GraphConstants.setForeground(map, edge.getColor());
	GraphConstants.setDashPattern(map, new float[] { edge.getWidth(), 3 });

	return map;
}
 
Example 13
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns the attribute map for highlighted virtual edges.
 *
 * @return a map of attributes to be used for highlighted virtual edges
 */
private AttributeMap virtualHighlightedEdgeAttributes() {
	AttributeMap map = virtualEdgeAttributes();
	Color color = getColor(_mode + "edge_virtual_highlighted");

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

	return map;
}
 
Example 14
Source File: OverviewGraphModel.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Overridden method to get cell attributes; we make sure the appropriate
 * attributes are applied to the Easik objects before returning them.
 *
 * @see DefaultGraphModel.getAttributes(Object)
 *
 * @param o
 *
 * @return
 */
@Override
public AttributeMap getAttributes(Object o) {
	if (o instanceof GraphCell) {
		GraphCell cell = (GraphCell) o;
		AttributeMap attribs = cell.getAttributes();
		AttributeMap easikAttribs = null;

		if (cell instanceof SketchNode) {
			easikAttribs = sketchAttributes((SketchNode) cell);
		} else if (cell instanceof ViewNode) {
			easikAttribs = viewAttributes((ViewNode) cell);
		} else if (cell instanceof ViewDefinitionEdge) {
			easikAttribs = viewEdgeAttributes((ViewDefinitionEdge) cell);

			// easikAttribs =
			// easik.sketch.util.graph.SketchGraphModel.normalEdgeAttributes();
		}

		if (easikAttribs != null) {
			if (_overview.isCellSelected(cell)) {
				Color selColor = getColor("selection");
				float lineWidth = getWidth("selection", 3);
				int borderWidth = 1;
				Border currentBorder = GraphConstants.getBorder(easikAttribs);

				if (currentBorder instanceof LineBorder) {
					borderWidth = ((LineBorder) currentBorder).getThickness();
				}

				GraphConstants.setBorder(easikAttribs, BorderFactory.createLineBorder(selColor, borderWidth));
				GraphConstants.setForeground(easikAttribs, selColor);
				GraphConstants.setLineColor(easikAttribs, selColor);
				GraphConstants.setLineWidth(easikAttribs, lineWidth);
			}

			if (attribs == null) {
				cell.setAttributes(easikAttribs);

				attribs = easikAttribs;
			} else {
				attribs.applyMap(easikAttribs);
			}

			return attribs;
		}
	}

	return super.getAttributes(o);
}
 
Example 15
Source File: ViewGraphModel.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Overridden method to get cell attributes; we make sure the appropriate
 * attributes are applied to the Easik objects before returning them.
 *
 * @see DefaultGraphModel.getAttributes(Object)
 *
 * @param o
 *
 * @return
 */
@Override
@SuppressWarnings("unchecked")
public AttributeMap getAttributes(Object o) {
	_mode = (_view.getSketch().getFrame().getMode() == Mode.EDIT) ? "edit_" : "manip_";

	if (o instanceof GraphCell) {
		GraphCell cell = (GraphCell) o;
		AttributeMap attribs = cell.getAttributes();
		AttributeMap easikAttribs = null;

		if (cell instanceof View_Edge) {
			easikAttribs = (cell instanceof InjectiveViewEdge) ? injectiveEdgeAttributes()
					: (cell instanceof PartialViewEdge) ? partialEdgeAttributes() : normalEdgeAttributes();
		} else if (cell instanceof TriangleEdge) {
			easikAttribs = triangleEdgeAttributes(
					(TriangleEdge<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>) cell);
		} else if (cell instanceof GuideEdge) {
			easikAttribs = ((GuideEdge<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>) cell).isHighlighted()
					? virtualHighlightedEdgeAttributes()
					: virtualEdgeAttributes();
		} else if (cell instanceof ModelConstraint) {
			easikAttribs = virtualVertexAttributes();
		} else if (cell instanceof QueryNode) {
			easikAttribs = vertexAttributes();
		}

		if (easikAttribs != null) {
			if (_view.isCellSelected(cell)) {
				Color selColor;
				float lineWidth;

				if (_view.getStateManager().peekState() instanceof GetPathState) {
					selColor = getColor("path_selection");
					lineWidth = getWidth("path_selection", 2);
				} else {
					selColor = getColor("selection");
					lineWidth = getWidth("selection", 3);
				}

				int borderWidth = getIntWidth(
						_mode + ((cell instanceof ModelConstraint) ? "constraint" : "entity") + "_border", 1);

				GraphConstants.setBorder(easikAttribs, BorderFactory.createLineBorder(selColor, borderWidth));
				GraphConstants.setForeground(easikAttribs, selColor);
				GraphConstants.setLineColor(easikAttribs, selColor);
				GraphConstants.setLineWidth(easikAttribs, lineWidth);
			}

			if (attribs == null) {
				cell.setAttributes(easikAttribs);

				attribs = easikAttribs;
			} else {
				attribs.applyMap(easikAttribs);
			}

			return attribs;
		}
	}

	return super.getAttributes(o);
}
 
Example 16
Source File: SketchGraphModel.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Overridden method to get cell attributes; we make sure the appropriate
 * attributes are applied to the Easik objects before returning them.
 *
 * @see DefaultGraphModel.getAttributes(Object)
 *
 * @param o
 *
 * @return
 */
@Override
@SuppressWarnings("unchecked")
public AttributeMap getAttributes(Object o) {
	_mode = (_sketch.getFrame().getMode() == Mode.EDIT) ? "edit_" : "manip_";

	if (o instanceof GraphCell) {
		GraphCell cell = (GraphCell) o;
		AttributeMap attribs = cell.getAttributes();
		AttributeMap easikAttribs = null;

		if (cell instanceof SketchEdge) {
			easikAttribs = (cell instanceof InjectiveEdge) ? injectiveEdgeAttributes()
					: (cell instanceof PartialEdge) ? partialEdgeAttributes() : normalEdgeAttributes();
		} else if (cell instanceof TriangleEdge) {
			easikAttribs = triangleEdgeAttributes(
					(TriangleEdge<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>) cell);
		} else if (cell instanceof GuideEdge) {
			easikAttribs = ((GuideEdge<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>) cell)
					.isHighlighted() ? virtualHighlightedEdgeAttributes() : virtualEdgeAttributes();
		} else if (cell instanceof ModelConstraint) {
			easikAttribs = virtualVertexAttributes();
		} else if (cell instanceof EntityNode) {
			easikAttribs = vertexAttributes();
		}

		if (easikAttribs != null) {
			if (_sketch.isCellSelected(cell)) {
				Color selColor;
				float lineWidth;

				if (_sketch.getStateManager().peekState() instanceof GetPathState) {
					selColor = getColor("path_selection");
					lineWidth = getWidth("path_selection", 2);
				} else {
					selColor = getColor("selection");
					lineWidth = getWidth("selection", 3);
				}

				int borderWidth = getIntWidth(
						_mode + ((cell instanceof ModelConstraint) ? "constraint" : "entity") + "_border", 1);

				GraphConstants.setBorder(easikAttribs, BorderFactory.createLineBorder(selColor, borderWidth));
				GraphConstants.setForeground(easikAttribs, selColor);
				GraphConstants.setLineColor(easikAttribs, selColor);
				GraphConstants.setLineWidth(easikAttribs, lineWidth);
			}

			if (attribs == null) {
				cell.setAttributes(easikAttribs);

				attribs = easikAttribs;
			} else {
				attribs.applyMap(easikAttribs);
			}

			return attribs;
		}
	}

	return super.getAttributes(o);
}