javax.swing.undo.AbstractUndoableEdit#org.jgraph.graph.GraphLayoutCache源码实例Demo

下面列出了javax.swing.undo.AbstractUndoableEdit#org.jgraph.graph.GraphLayoutCache 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CQL   文件: View.java
/**
 * When we initialize the sketch, we flush out all the data concerning the
 * sketch itself. Even the modelAdapter is reinitialized.
 *
 * This methods serves as a "new sketch" function.
 */
@Override
public void initialiseModel() {
	clearSelection();

	model = new ViewGraphModel(this);

	final GraphLayoutCache glc = new GraphLayoutCache(model,
			new ModelViewFactory<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge>());

	setModel(model);
	setGraphLayoutCache(glc);

	_nodes = new LinkedHashMap<>();
	_edges = new LinkedHashMap<>();

	if (_Frame.getInfoTreeUI() != null) {
		_Frame.setInfoTreeUI(new ModelInfoTreeUI<>(_Frame)); // Wipe
																// Tree
		_Frame.getInfoTreeUI().refreshTree();
	}

	_docInfo.reset();

	model.discardUndo();
}
 
源代码2 项目: CQL   文件: ModelConstraint.java
/**
 * Sets if the constraint should be visible or not
 *
 * @param inIsVisible If the constraint should be visible or not.
 */
public void setVisible(boolean inIsVisible) {
	if (inIsVisible != _isVisible) {
		_isVisible = inIsVisible;

		_theModel.setDirty();
	}

	// GuideEdge<F, GM, M, N, E>[] visuals = _visuals.toArray(new GuideEdge[0]);
	@SuppressWarnings("unused")
	GraphLayoutCache glc = _theModel.getGraphLayoutCache();

	if (_isVisible && !_edgesVisualized) {
		addVisualsToModel();
	} else if (!_isVisible && _edgesVisualized) {
		removeVisualsFromModel();
	}

	_theModel.clearSelection();
}
 
源代码3 项目: CQL   文件: ModelConstraint.java
/**
 * 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();
}
 
源代码4 项目: CQL   文件: Sketch.java
/**
 * When we initialise the sketch, we flush out all the data concerning the
 * sketch itself.
 *
 * This methods serves as a "new sketch" function.
 */
@Override
public void initialiseModel() {
	clearSelection();

	model = new SketchGraphModel(this);

	final GraphLayoutCache glc = new GraphLayoutCache(model,
			new ModelViewFactory<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>());

	setModel(model);
	setGraphLayoutCache(glc);

	_nodes = new LinkedHashMap<>();
	_edges = new LinkedHashMap<>();

	if (_Frame.getInfoTreeUI() != null) {
		_Frame.setInfoTreeUI(new ModelInfoTreeUI<>(_Frame)); // Wipe
																// Tree
		_Frame.getInfoTreeUI().refreshTree();
	}

	_docInfo.reset();

	_views = new HashMap<>();
	_connParams = new HashMap<>();

	model.discardUndo();
}
 
源代码5 项目: MogwaiERDesignerNG   文件: ERDesignerGraph.java
public ERDesignerGraph(Model aDBModel, GraphModel aModel,
                       GraphLayoutCache aLayoutCache) {
    super(aModel, aLayoutCache);
    model = aDBModel;

    setMoveIntoGroups(true);
    setMoveOutOfGroups(true);
}
 
源代码6 项目: microba   文件: Birdview.java
/**
 * Makes this component track the provided graph and scroller. Set
 * parameters to <code>null</code> to unbind thie component.
 * 
 * @param graph
 *            the graph component. May be <code>null</code>
 * @param scroller
 *            the croller, usually the one that holds the graph. May be
 *            <code>null</code>
 */
public void setTrackingFor(JGraph graph, JScrollPane scroller) {
	if (this.peerGraph != null) {
		this.peerGraph.getModel().removeGraphModelListener(scrollerListener);
		this.peerGraph.removePropertyChangeListener(graphPropertyChangeListener);
	}

	this.peerGraph = graph;

	if (this.peerGraph != null) {
		this.peerGraph.getModel().addGraphModelListener(scrollerListener);
		this.peerGraph.addPropertyChangeListener(graphPropertyChangeListener);

		this.displayGraph.setGraphLayoutCache(peerGraph.getGraphLayoutCache());

	} else {
		this.displayGraph.setGraphLayoutCache(new GraphLayoutCache());
	}

	//
	if (this.peerScroller != null) {
		this.peerScroller.getHorizontalScrollBar().removeAdjustmentListener(
				scrollerListener);
		this.peerScroller.getVerticalScrollBar().removeAdjustmentListener(
				scrollerListener);
	}

	this.peerScroller = scroller;

	if (this.peerScroller != null) {
		this.peerScroller.getHorizontalScrollBar().addAdjustmentListener(
				scrollerListener);
		this.peerScroller.getVerticalScrollBar().addAdjustmentListener(
				scrollerListener);
	}

	update();
	repaint();

}
 
源代码7 项目: Pydev   文件: GraphView.java
private void loadGraph(String fileName) throws FileNotFoundException, IOException, Throwable {
    ASTGraph ast = new ASTGraph();
    ParseOutput objects = ast.parseFile(fileName);

    graph.setGraphLayoutCache(new GraphLayoutCache());
    DefaultGraphCell[] cells = ast.generateTree((SimpleNode) objects.ast);

    graph.getGraphLayoutCache().insert(cells);
    graph.clearSelection();
}
 
源代码8 项目: chipster   文件: MicroarrayGraph.java
public MicroarrayGraph(GraphModel model, GraphLayoutCache cache, GraphPanel graphPanel) {
	super(model, cache);

	this.model = model;
	this.graphPanel = graphPanel;
	this.setBackground(Color.WHITE);

	// Direct call to parents L&F update, see this.updateUI()
	super.updateUI();

	/*
	 * Regardles of the updateUI-call jus before the font size of graph cell is fixed only when the first cell is added. To handle
	 * situations when the font size is changed before importing any data we force the jgraph to initialise itself by inserting dummy
	 * vertex and removing it. This *should* happen before any repaint operation, and thus the vertex won't ever show.
	 */
	GroupVertex vertex = new GroupVertex(0, 0, null, this);
	getGraphLayoutCache().insert(vertex);
	getGraphLayoutCache().remove(new Object[] { vertex });

	// registers the graph object with the tooltip manager
	ToolTipManager.sharedInstance().registerComponent(this);
	
	model.addGraphModelListener(this);

	// start listening
	application.getDataManager().addDataChangeListener(this);
	application.addClientEventListener(this);
}
 
源代码9 项目: CQL   文件: EdgeRouter.java
/**
 * Calculates intermediate points for multiple loops. This is the same algorithm
 * used by DefaultEdge.LoopRouting, but we scale the loop box for parallel
 * self-referencing edges.
 *
 * @param cache
 * @param edge
 *
 * @return
 */
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public List routeLoop(final GraphLayoutCache cache, final EdgeView edge) {
	final CellView sourceNode = edge.getSource();
	final List newPoints = new ArrayList();

	newPoints.add(sourceNode);

	final CellView sourceParent = (sourceNode != null) ? sourceNode.getParentView() : edge.getSourceParentView();
	if (sourceNode == null) {
		throw new RuntimeException("Internal EASIK error, please report");
	}
	final Object[] edges = DefaultGraphModel.getEdgesBetween(cache.getModel(), sourceNode.getCell(),
			sourceNode.getCell(), true);
	int position = 0;

	if (edges != null) {
		for (int i = 0; i < edges.length; i++) {
			if (edges[i] == edge.getCell()) {
				position = i;

				break;
			}
		}
	}

	if (sourceParent != null) {
		final Point2D from = AbstractCellView.getCenterPoint(sourceParent);
		final Rectangle2D rect = sourceParent.getBounds();
		final double posWidthFactor = 1.25 + 0.75 * position;
		final double posHeightFactor = 1.5 + position;
		final double width = rect.getWidth();
		final double height2 = rect.getHeight() / 2;
		double loopWidth = Math.min(20, Math.max(10, width / 8));
		double loopHeight = Math.min(30, Math.max(12, Math.max(loopWidth + 4, height2 / 2)));

		loopWidth *= posWidthFactor;
		loopHeight *= posHeightFactor;

		newPoints.add(edge.getAttributes().createPoint(from.getX() - loopWidth,
				from.getY() - height2 - loopHeight * 1.0));

		final double midpointY = from.getY() - height2 - 1.5 * loopHeight;

		newPoints.add(edge.getAttributes().createPoint(from.getX(), midpointY));
		newPoints.add(edge.getAttributes().createPoint(from.getX() + loopWidth,
				from.getY() - height2 - loopHeight * 1.0));
		newPoints.add(edge.getTarget());

		return newPoints;
	}

	return null;
}