⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jgraph.java

📁 用JGraph编的软件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	}	/**	 * Sets if cells are cloned on CTRL-Drag operations.	 */	public void setCloneable(boolean flag) {		cloneable = flag;	}	/**	 * Returns true if the graph allows cells to be resized.	 */	public boolean isSizeable() {		return sizeable;	}	/**	 * Sets if the graph allows cells to be resized.	 */	public void setSizeable(boolean flag) {		sizeable = flag;	}	/**	 * Returns true if selected edges should be disconnected from	 * unselected vertices when they are moved.	 */	public boolean isDisconnectOnMove() {		return disconnectOnMove && disconnectable;	}	/**	 * Sets if selected edges should be disconnected from	 * unselected vertices when they are moved.	 */	public void setSelectNewCells(boolean flag) {		selectNewCells = flag;	}	/**	 * Returns true if selected edges should be disconnected from	 * unselected vertices when they are moved.	 */	public boolean isSelectNewCells() {		return selectNewCells;	}	/**	 * Sets if selected edges should be disconnected from	 * unselected vertices when they are moved.	 */	public void setDisconnectOnMove(boolean flag) {		disconnectOnMove = flag;	}	/**	 * Returns true if the grid is active.	 * @see #snap	 *	 */	public boolean isGridEnabled() {		return gridEnabled;	}	/**	 * If set to true, the grid will be active.	 * @see #snap	 *	 */	public void setGridEnabled(boolean flag) {		gridEnabled = flag;	}	/**	 * Returns the maximum distance between the mousepointer and a cell to	 * be selected.	 */	public int getTolerance() {		return tolerance;	}	/**	 * Sets the maximum distance between the mousepointer and a cell to	 * be selected.	 */	public void setTolerance(int size) {		tolerance = size;	}	/**	 * Returns the size of the handles.	 */	public int getHandleSize() {		return handleSize;	}	/**	 * Sets the size of the handles.	 */	public void setHandleSize(int size) {		handleSize = size;	}	/**	 * Returns the miminum amount of pixels for a move operation.	 */	public int getMinimumMove() {		return minimumMove;	}	/**	 * Sets the miminum amount of pixels for a move operation.	 */	public void setMinimumMove(int pixels) {		minimumMove = pixels;	}	//	// Laf-Specific color scheme. These colors are changed	// by BasicGraphUI when the laf changes.	//	/**	 * Returns the current grid color.	 */	public Color getGridColor() {		return gridColor;	}	/**	 * Sets the current grid color.	 */	public void setGridColor(Color newColor) {		gridColor = newColor;	}	/**	 * Returns the current handle color.	 */	public Color getHandleColor() {		return handleColor;	}	/**	 * Sets the current handle color.	 */	public void setHandleColor(Color newColor) {		handleColor = newColor;	}	/**	 * Returns the current second handle color.	 */	public Color getLockedHandleColor() {		return lockedHandleColor;	}	/**	 * Sets the current second handle color.	 */	public void setLockedHandleColor(Color newColor) {		lockedHandleColor = newColor;	}	/**	 * Returns the current marquee color.	 */	public Color getMarqueeColor() {		return marqueeColor;	}	/**	 * Sets the current marquee color.	 */	public void setMarqueeColor(Color newColor) {		marqueeColor = newColor;	}	/**	 * Returns the current highlight color.	 */	public Color getHighlightColor() {		return highlightColor;	}	/**	 * Sets the current selection highlight color.	 */	public void setHighlightColor(Color newColor) {		highlightColor = newColor;	}	//	// Bound properties	//	/**	 * Returns the current scale.	 * @return the current scale as a double	 */	public double getScale() {		return scale;	}	/**	 * Sets the current scale.	 * <p>	 * Fires a property change for the SCALE_PROPERTY.	 * @param newValue the new scale	 */	public void setScale(double newValue) {		if (newValue > 0) {			double oldValue = this.scale;			scale = newValue;			firePropertyChange(SCALE_PROPERTY, oldValue, newValue);		}	}	/**	 * Returns the size of the grid in pixels.	 * @return the size of the grid as an int	 */	public int getGridSize() {		return gridSize;	}	/**	 * Returns the current grid view mode.	 */	public int getGridMode() {		return gridMode;	}	/**	 * Sets the size of the grid.	 * <p>	 * Fires a property change for the GRID_SIZE_PROPERTY.	 * @param newSize the new size of the grid in pixels	 */	public void setGridSize(int newSize) {		int oldValue = this.gridSize;		this.gridSize = newSize;		firePropertyChange(GRID_SIZE_PROPERTY, oldValue, newSize);	}	/**	 * Sets the current grid view mode.	 *	 * @param mode The current grid view mode. Valid values are	 *    <CODE>DOT_GRID_MODE</CODE>,	 *    <CODE>CROSS_GRID_MODE</CODE>, and	 *    <CODE>LINE_GRID_MODE</CODE>.	 */	public void setGridMode(int mode) {		if (mode == DOT_GRID_MODE			|| mode == CROSS_GRID_MODE			|| mode == LINE_GRID_MODE) {			gridMode = mode;			repaint();		}	}	/**	 * Returns true if the grid will be visible.	 * @return true if the grid is visible	 */	public boolean isGridVisible() {		return gridVisible;	}	/**	 * If set to true, the grid will be visible. <p>	 * Fires a property change for the GRID_VISIBLE_PROPERTY.	 */	public void setGridVisible(boolean flag) {		boolean oldValue = gridVisible;		gridVisible = flag;		firePropertyChange(GRID_VISIBLE_PROPERTY, oldValue, flag);	}	/**	 * Returns true if the ports will be visible.	 * @return true if the ports are visible	 */	public boolean isPortsVisible() {		return portsVisible;	}	/**	 * If set to true, the ports will be visible. <p>	 * Fires a property change for the PORTS_VISIBLE_PROPERTY.	 */	public void setPortsVisible(boolean flag) {		boolean oldValue = portsVisible;		portsVisible = flag;		firePropertyChange(PORTS_VISIBLE_PROPERTY, oldValue, flag);	}	/**	 * Returns true if the graph will be anti aliased.	 * @return true if the graph is anti aliased	 */	public boolean isAntiAliased() {		return antiAliased;	}	/**	 * Sets antialiasing on or off based on the boolean value.	 * <p>	 * Fires a property change for the ANTIALIASED_PROPERTY.	 * @param newValue whether to turn antialiasing on or off	 */	public void setAntiAliased(boolean newValue) {		boolean oldValue = this.antiAliased;		this.antiAliased = newValue;		firePropertyChange(ANTIALIASED_PROPERTY, oldValue, newValue);	}	/**	 * Returns true if the graph is editable, ie. if it allows	 * cells to be edited.	 * @return true if the graph is editable	 */	public boolean isEditable() {		return editable;	}	/**	 * Determines whether the graph is editable. Fires a property	 * change event if the new setting is different from the existing	 * setting.	 * <p>	 * Note: Editable determines whether the graph allows editing. This	 * is not to be confused with enabled, which allows the graph to	 * handle mouse events (including editing).	 * @param flag a boolean value, true if the graph is editable	 */	public void setEditable(boolean flag) {		boolean oldValue = this.editable;		this.editable = flag;		firePropertyChange(EDITABLE_PROPERTY, oldValue, flag);	}	/**	 * Returns the <code>GraphModel</code> that is providing the data.	 * @return the model that is providing the data	 */	public GraphModel getModel() {		return graphModel;	}	/**	 * Sets the <code>GraphModel</code> that will provide the data.	 * Note: Updates the current GraphLayoutCache's model using setModel if the	 * GraphLayoutCache points to a different model. <p>	 * Fires a property change for the GRAPH_MODEL_PROPERTY.	 * @param newModel the <code>GraphModel</code> that is to provide the data	 */	public void setModel(GraphModel newModel) {		GraphModel oldModel = graphModel;		graphModel = newModel;		firePropertyChange(GRAPH_MODEL_PROPERTY, oldModel, graphModel);		// FIX: Use Listener		if (graphLayoutCache != null			&& graphLayoutCache.getModel() != graphModel)			graphLayoutCache.setModel(graphModel);		invalidate();	}	/**	 * Returns the <code>GraphLayoutCache</code> that is providing the view-data.	 * @return the view that is providing the view-data	 */	public GraphLayoutCache getGraphLayoutCache() {		return graphLayoutCache;	}	/**	 * Sets the <code>GraphLayoutCache</code> that will provide the view-data. <p>	 * Note: Updates the GraphLayoutCache's model using setModel if the	 * GraphLayoutCache points to an other model than this graph. <p>	 * Fires a property change for the GRAPH_LAYOUT_CACHE_PROPERTY.	 * @param newView the <code>GraphLayoutCache</code> that is to provide the view-data	 */	public void setGraphLayoutCache(GraphLayoutCache newLayoutCache) {		GraphLayoutCache oldLayoutCache = graphLayoutCache;		graphLayoutCache = newLayoutCache;		firePropertyChange(			GRAPH_LAYOUT_CACHE_PROPERTY,			oldLayoutCache,			graphLayoutCache);		// FIX: Use Listener		if (graphLayoutCache != null			&& graphLayoutCache.getModel() != getModel())			graphLayoutCache.setModel(getModel());		invalidate();	}	/**	 * Returns the <code>MarqueeHandler</code> that will handle	 * marquee selection.	 */	public BasicMarqueeHandler getMarqueeHandler() {		return marquee;	}	/**	 * Sets the <code>MarqueeHandler</code> that will handle	 * marquee selection.	 */	public void setMarqueeHandler(BasicMarqueeHandler newMarquee) {		BasicMarqueeHandler oldMarquee = marquee;		marquee = newMarquee;		firePropertyChange(MARQUEE_HANDLER_PROPERTY, oldMarquee, newMarquee);		invalidate();	}	/**	 * Determines what happens when editing is interrupted by selecting	 * another cell in the graph, a change in the graph's data, or by some	 * other means. Setting this property to <code>true</code> causes the	 * changes to be automatically saved when editing is interrupted.	 * <p>	 * Fires a property change for the INVOKES_STOP_CELL_EDITING_PROPERTY.	 * @param newValue true means that <code>stopCellEditing</code> is invoked	 * when editing is interruped, and data is saved; false means that	 * <code>cancelCellEditing</code> is invoked, and changes are lost	 */	public void setInvokesStopCellEditing(boolean newValue) {		boolean oldValue = invokesStopCellEditing;		invokesStopCellEditing = newValue;		firePropertyChange(			INVOKES_STOP_CELL_EDITING_PROPERTY,			oldValue,			newValue);	}	/**	 * Returns the indicator that tells what happens when editing is	 * interrupted.	 * @return the indicator that tells what happens when editing is	 * interrupted	 * @see #setInvokesStopCellEditing	 *	 */	public boolean getInvokesStopCellEditing() {		return invokesStopCellEditing;	}	/**	 * Returns <code>isEditable</code>. This is invoked from the UI before	 * editing begins to ensure that the given cell can be edited. This	 * is provided as an entry point for subclassers to add filtered	 * editing without having to resort to creating a new editor.	 * @return true if the specified cell is editable	 * @see #isEditable	 *	 */	public boolean isCellEditable(Object cell) {		if (cell != null) {			CellView view = graphLayoutCache.getMapping(cell, false);			if (view != null) {				return isEditable()				&& GraphConstants.isEditable(view.getAllAttributes());			}		}		return false;	}	/**	 * Overrides <code>JComponent</code>'s <code>getToolTipText</code>	 * method in order to allow the graph to create a tooltip	 * for the topmost cell under the mousepointer. This differs from JTree	 * where the renderers tooltip is used.	 * <p>	 * NOTE: For <code>JGraph</code> to properly display tooltips of its	 * renderers, <code>JGraph</code> must be a registered component with the	 * <code>ToolTipManager</code>.  This can be done by invoking	 * <code>ToolTipManager.sharedInstance().registerComponent(graph)</code>.	 * This is not done automatically!	 * @param event the <code>MouseEvent</code> that initiated the	 * <code>ToolTip</code> display	 * @return a string containing the  tooltip or <code>null</code>	 * if <code>event</code> is null	 */	public String getToolTipText(MouseEvent event) {		if (event != null) {			Object cell = getFirstCellForLocation(event.getX(), event.getY());			String s = convertValueToString(cell);			return (s != null && s.length() > 0) ? s : null;		}		return null;	}	//	// The following are convenience methods that get forwarded to the	// current GraphSelectionModel.	//	/**	 * Sets the graph's selection model. When a <code>null</code> value is	 * specified an emtpy	 * <code>selectionModel</code> is used, which does not allow selections.	 * @param selectionModel the <code>GraphSelectionModel</code> to use,	 * or <code>null</code> to disable selections	 * @see GraphSelectionModel	 *	 */	public void setSelectionModel(GraphSelectionModel selectionModel) {		if (selectionModel == null)			selectionModel = EmptySelectionModel.sharedInstance();		GraphSelectionModel oldValue = this.selectionModel;		// Remove Redirector From Old Selection Model		if (this.selectionModel != null && selectionRedirector != null)			this.selectionModel.removeGraphSelectionListener(				selectionRedirector);		this.selectionModel = selectionModel;		// Add Redirector To New Selection Model		if (selectionRedirector != null)			this.selectionModel.addGraphSelectionListener(selectionRedirector);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -