本文整理汇总了Java中org.jgraph.graph.GraphConstants类的典型用法代码示例。如果您正苦于以下问题:Java GraphConstants类的具体用法?Java GraphConstants怎么用?Java GraphConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphConstants类属于org.jgraph.graph包,在下文中一共展示了GraphConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintSelectionBorder
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
/**
* Provided for subclassers to paint a selection border.
*/
protected void paintSelectionBorder(Graphics g)
{
((Graphics2D) g).setStroke(GraphConstants.SELECTION_STROKE);
if (childrenSelected)
{
if(graph.get()!=null)
g.setColor(((JGraph)graph.get()).getGridColor());
}
else if (focus && selected)
{
if(graph.get()!=null)
g.setColor(((JGraph)graph.get()).getLockedHandleColor());
}
else if (selected)
{
g.setColor(getDecidedHighlightColor());
}
if (childrenSelected || selected)
{
Dimension d = getSize();
g.drawRect(0, 0, d.width-1, d.height-1);
}
}
示例2: 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());
}
}
示例3: getOffset
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
public int getOffset() {
JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
GraphModel graphmodel = mediator.getGraph().getModel();
Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
int max = (int) boundsSource.getMaxX();
for (Object father : fathers) {
if (father instanceof JmtEdge) {
JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
max = (int) boundsSource2.getMaxX();
}
}
}
}
return (int) (max - boundsSource.getMaxX());
}
示例4: 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;
}
示例5: getOffset
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
public int getOffset() {
JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
Object[] listEdges = null;
GraphModel graphmodel = mediator.getGraph().getModel();
// System.out.println("Padre: "+targetOfEdge);
Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
int max = (int) boundsSource.getMaxX();
for (Object father : fathers) {
// System.out.println("Dentro il for");
if (father instanceof JmtEdge) {
JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
max = (int) boundsSource2.getMaxX();
}
}
}
}
return (int) (max - boundsSource.getMaxX());
}
示例6: 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;
}
示例7: clearAllEdgePoints
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
/** Clear all intermediate points from all edges. */
public void clearAllEdgePoints() {
Map<JCell<G>,AttributeMap> change = new HashMap<>();
for (JCell<G> jCell : getModel().getRoots()) {
if (jCell instanceof JEdge) {
VisualMap visuals = jCell.getVisuals();
List<Point2D> points = visuals.getPoints();
// don't make the change directly in the cell,
// as this messes up the undo history
List<Point2D> newPoints =
Arrays.asList(points.get(0), points.get(points.size() - 1));
AttributeMap newAttributes = new AttributeMap();
GraphConstants.setPoints(newAttributes, newPoints);
change.put(jCell, newAttributes);
}
}
getModel().edit(change, null, null, null);
}
示例8: 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);
}
示例9: 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);
}
}
示例10: RelationEdge
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
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));
}
示例11: testJGraph
import org.jgraph.graph.GraphConstants; //导入依赖的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));
}
示例12: mouseReleased
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
public void mouseReleased(MouseEvent e) {
if (index != -1) {
cachedBounds = computeBounds(e);
int cachedStartPoint = computeStartCorner(e);
vertex.setBounds(cachedBounds);
TBoardConstants.setStartCorner(vertex.getAttributes(),
cachedStartPoint);
CellView[] views = AbstractCellView
.getDescendantViews(new CellView[] { vertex });
Map attributes = GraphConstants.createAttributes(views, null);
graph.getGraphLayoutCache().edit(attributes, null, null, null);
}
e.consume();
cachedBounds = null;
initialBounds = null;
firstDrag = true;
}
示例13: paint
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
boolean tmp = selected;
try {
setBorder(null);
setOpaque(false);
selected = false;
super.paint(g);
} finally {
selected = tmp;
}
if (borderColor != null) {
g2.setStroke(new BasicStroke(lineWidth));
g.setColor(borderColor);
drawThisLine(g);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(getHighlightColor());
drawThisLine(g);
}
}
示例14: getRendererComponent
import org.jgraph.graph.GraphConstants; //导入依赖的package包/类
public Component getRendererComponent(JGraph graph, CellView view,
boolean sel, boolean focus, boolean preview) {
gridColor = graph.getGridColor();
highlightColor = graph.getHighlightColor();
lockedHandleColor = graph.getLockedHandleColor();
isDoubleBuffered = graph.isDoubleBuffered();
if (view instanceof VertexView) {
this.view = (VertexView)view;
this.hasFocus = focus;
this.childrenSelected = graph.getSelectionModel()
.isChildrenSelected(view.getCell());
this.selected = sel;
this.preview = preview;
if (this.view.isLeaf()
|| GraphConstants.isGroupOpaque(view.getAllAttributes()))
installAttributes(view);
else
resetAttributes();
return this;
}
return null;
}
示例15: 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);
}