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

📄 gpgraphpad.java

📁 用JGraph编的软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			new FormatTextPositionMiddle(this),
			new FormatTextPositionRight(this),
			new FormatTextPositionTop(this),
			new FormatUnlockBendable(this),
			new FormatUnlockConnectable(this),
			new FormatUnlockConnections(this),
			new FormatUnlockDisconnectable(this),
			new FormatUnlockPosition(this),
			new FormatUnlockSize(this),
			new FormatUnlockValue(this),
			new GraphApplyLayoutAlgorithm(this),
			new GraphArrange(this),
			new GraphBackgroundColor(this),
			new GraphBackgroundImage(this),
			new GraphBackgroundNoImage(this),
			new GraphDragEnabled(this),
			new GraphDropEnabled(this),
			new GraphEditable(this),
			new GraphEnabled(this),
			new GraphLayout(this),
			new GraphOptionsBendable(this),
			new GraphOptionsCloneable(this),
			new GraphOptionsConnectable(this),
			new GraphOptionsDisconnectable(this),
			new GraphOptionsDisconnectOnMove(this),
			new GraphOptionsDoubleBuffered(this),
			new GraphOptionsMoveable(this),
			new GraphOptionsSizeable(this),
			new GraphTilt(this),
			new HelpAbout(this),
			new HelpSubmitABug(this),
			new HelpHomepage(this),
			new SelectAll(this),
			new SelectAllClear(this),
			new SelectEdges(this),
			new SelectEdgesClear(this),
			new SelectInverse(this),
			new SelectMinimalSpanTree(this),
			new SelectShortestPath(this),
			new SelectVertices(this),
			new SelectVerticesClear(this),
			new ShapeAlignBottom(this),
			new ShapeAlignCenter(this),
			new ShapeAlignLeft(this),
			new ShapeAlignMiddle(this),
			new ShapeAlignRight(this),
			new ShapeAlignTop(this),
			new ShapeBestPorts(this),
			new ShapeCloneAttributes(this),
			new ShapeCloneLabel(this),
			new ShapeCloneSize(this),
			new ShapeDefaultPorts(this),
			new ShapeDisconnect(this),
			new ShapeGroup(this),
			new ShapeToBack(this),
			new ShapeToFront(this),
			new ShapeUngroup(this),
			new ToolBoxEdge(this),
			new ToolBoxActivity(this),
			new ToolBoxDecision(this),
                        //
                        new ToolBoxInclusiveGateway(this),
                         new ToolBoxComplexGateway(this),
                          new ToolBoxParallelGateway(this),
                        new ToolBoxPool(this),
                         new ToolBoxLane(this),
                         //subProcess
                         new ToolBoxSubProcess(this),
                         //dataObj
                         new ToolBoxDataObj(this),
                         //textAnnotation
                         new ToolBoxTextAnnotation(this),
			new ToolBoxStart(this),
                        new ToolBoxInter(this),
			new ToolBoxEnd(this),
			new ToolBoxSplit(this),
			new ToolBoxJoin(this),
			new ToolBoxLine(this),
                        new ToolBoxSequence(this),
                        new ToolBoxMessage(this),
                        new ToolBoxAssociate(this),
                       	new ToolBoxSelect(this),
			new ToolBoxText(this),
			new ToolBoxZoomArea(this),
			new ToolsGridSize(this),
			new ToolsLookAndFeel(this),
			new ToolsMetric(this),
			new ToolsPortSize(this),
			new ToolsShowOverview(this),
			new ToolsShowStatusbar(this),
			new ToolsShowToolbar(this),
			new ToolsShowExplorer(this),
			new ToolsSnapSize(this),
			new ToolsStatusbar(this),
			new ToolsTooltips(this),
			new ViewActualSize(this),
			new ViewAntiAlias(this),
			new ViewFit(this),
			new ViewGrid(this),
			new ViewLayout(this),
			new ViewPorts(this),
			new ViewRuler(this),
			new ViewScaleCustom(this),
			new ViewScaleZoomIn(this),
			new ViewScaleZoomOut(this),
			new WindowCascade(this),
			new WindowLogConsole(this),
			new WindowMaximize(this),
			new WindowMinimize(this),
			new WindowWindows(this)};

	/**
	 * Returns the current graph.
	 * @return GPGraph
	 */
	public GPGraph getCurrentGraph() {
		GPDocument doc = getCurrentDocument();
		if (doc == null)
			return null;
		return doc.getGraph();
	}

	public GraphModelProvider getCurrentGraphModelProvider() {
		GPDocument doc = getCurrentDocument();
		if (doc == null)
			return null;
		return doc.getGraphModelProvider();
	}

	/**
	 * Returns the current export model.
	 * @return GPGraph
	 */
	public ModelExportImpl getExportModel() {
		GPDocument doc = getCurrentDocument();
		if (doc == null)
			return null;
		return doc.getExportModel();
	}

	/**
	 * Sets the current export model
	 * @param model
	 */
	public void setExportModel(ModelExportImpl model) {
		GPDocument doc = getCurrentDocument();
		if (doc != null)
		{
		    doc.setExportModel(model);
		}
	}

	/**
	 * Returns the currently selected internal frame
	 * If no one is selected, then the first one will be select.
	 *
	 * @return GPDocument
	 */
	public JInternalFrame getCurrentInternalFrame() {
		GPInternalFrame internalFrame =
			(GPInternalFrame) desktop.getSelectedFrame();
		if (internalFrame == null) {
			JInternalFrame[] frames = desktop.getAllFrames();
			if (frames.length > 0) {
				try {
					frames[0].setSelected(true);
					internalFrame = (GPInternalFrame) frames[0];
				} catch (PropertyVetoException e) {
					return null;
				}
			}
		}
		if (internalFrame == null)
			return null;
		return internalFrame;
	}

	/**
	 * Returns the currently selected document.
	 * If no one is selected, then the first one will be select.
	 * @return GPDocument
	 */
	public GPDocument getCurrentDocument() {
		GPInternalFrame internalFrame =
			(GPInternalFrame) desktop.getSelectedFrame();
		if (internalFrame == null) {
			JInternalFrame[] frames = desktop.getAllFrames();
			if (frames.length > 0) {
				try {
					frames[0].setSelected(true);
					internalFrame = (GPInternalFrame) frames[0];
				} catch (PropertyVetoException e) {
					return null;
				}
			}
		}
		if (internalFrame == null)
			return null;
		return internalFrame.getDocument();
	}

	/**
	 * Returns all of the documents.
	 * @return GPGraphTools or <code>null</code> if no documents
	 */
	public GPDocument[] getAllDocuments() {
		JInternalFrame[] frames = desktop.getAllFrames();

		if (frames != null && frames.length > 0) {
			ArrayList docs = new ArrayList();
			for (int i = 0; i < frames.length; i++) {
				// make sure to only pick up GPInternalFrame instances
				if (frames[i] instanceof GPInternalFrame) {
					docs.add(((GPInternalFrame) frames[i]).getDocument());
				}
			}
			return (GPDocument[]) docs.toArray(new GPDocument[docs.size()]);
		} else
			return null;
	}

	/**
	 * Returns the graphTools.
	 * @return GPGraphTools
	 */
	public static GPGraphTools getGraphTools() {
		return graphTools;
	}

	/**
	 * Returns the undoAction.
	 * @return UndoAction
	 */
	public AbstractActionDefault getEditUndoAction() {
		return (AbstractActionDefault) currentActionMap.get(
			Utilities.getClassNameWithoutPackage(EditUndo.class));
	}

	/**
	 * Returns the redoAction.
	 *
	 * @return RedoAction
	 */
	public AbstractActionDefault getEditRedoAction() {
		return (AbstractActionDefault) currentActionMap.get(
			Utilities.getClassNameWithoutPackage(EditRedo.class));
	}

	public GPLogConsole getLogConsole() {
		return logger;
	}

	public boolean isToolBarsVisible() {
		return this.toolBarsVisible;
	}

	public void setToolBarsVisible(boolean state) {
		this.toolBarsVisible = state;

		if (state == true) {
			mainPanel.remove(desktop);
			toolBarInnerPanel.add(BorderLayout.CENTER, desktop);
			mainPanel.add(BorderLayout.CENTER, toolBarMainPanel);
		} else {
			mainPanel.remove(toolBarMainPanel);
			toolBarInnerPanel.remove(desktop);
			mainPanel.add(BorderLayout.CENTER, desktop);
		}
		desktop.repaint();
	}

	/** Adds a new Internal Frame to the Graphpad
	 */
	public void addGPInternalFrame(GPInternalFrame f) {
		desktop.add(f);
		try {
			f.setSelected(true);
		} catch (Exception ex) {
		}
		doc2InternalFrame.put(f.getDocument(), f);
	}

	/** removes the specified Internal Frame from the Graphpad
	 */
	public void removeGPInternalFrame(GPInternalFrame f) {
		if (f == null)
			return;
		f.setVisible(false);
		desktop.remove(f);
		doc2InternalFrame.remove(f.getDocument());
		JInternalFrame[] frames = desktop.getAllFrames();
		if (frames.length > 0) {
			try {
				frames[0].setSelected(true);
			} catch (PropertyVetoException e) {
			}
		}
	}

	/** Adds a new Document based on the GraphModelProvider.
	 *
	 */
	public void exit() {

		if (!isApplet()) {
			System.exit(0);
		} else {
			getApplet().exit(this);
		}
	}

	/** Adds a new Document based on the GraphModelProvider.
	 *
	 */
	public void setApplet(JGraphpad applet) {
		this.applet = applet;
	}

	/** Adds a new Document based on the GraphModelProvider.
	 *
	 */
	public JGraphpad getApplet() {
		return applet;
	}

	/** Adds a new Document based on the GraphModelProvider.
	 *
	 */
	public boolean isApplet() {
		return (applet != null);
	}

	/** Adds a new Document based on the GraphModelProvider.
	 *
	 */
	public void addDocument(GraphModelProvider graphModelProvider) {
		addDocument(null, graphModelProvider, null, null, null);
	}

	/**
	 * You can add a document by giving the filename.
	 * Before you can add a document with the specified filename
	 * you must add the corresponding GraphModelProvider and the
	 * corresponding GraphModelFileFormat at the GraphModelProviderRegistry.
	 *
	 * @see org.jgraph.pad.GraphModelProviderRegistry
	 * @see org.jgraph.pad.GraphModelProvider
		 * @see org.jgraph.pad.GraphModelFileFormat
		 *
	 */
	public void addDocument(URL file) {
		GraphModelProvider graphModelProvider = null;
		GraphModelFileFormat fileFormat = null;
		try {
			graphModelProvider =
				GraphModelProviderRegistry.getGraphModelProvider(
					file.toString());
			fileFormat =
				GraphModelProviderRegistry.getGraphModelFileFormat(
					file.toString());

			// try to use the defaults,
			// if there is no provider available
			if (graphModelProvider == null)
				graphModelProvider = new DefaultGraphModelProvider();
			if (fileFormat == null)
				fileFormat = new DefaultGraphModelFileFormatXML();

			/* Don't do this call directly!
			 * We have a multi file format support
			 * and you kick it out with this code!
			 *
			 *
			GraphModelProvider graphModelProvider =
				new DefaultGraphModelProvider();
			GraphModelFileFormat fileFormat =
				new DefaultGraphModelFileFormatXML();
			*/

			GraphModel model = graphModelProvider.createCleanGraphModel();
			GPGraph gpGraph = graphModelProvider.createCleanGraph(model);
			fileFormat.read(file, null, gpGraph);
			addDocument(file, graphModelProvider, gpGraph, model, null);
		} catch (Exception e) {
			JOptionPane.showMessageDialog(
				getFrame(),
				e
					+ "\nFile="
					+ file
					+ "\nFileFormat="
					+ fileFormat
					+ "\nGraphModelProvider="
					+ graphModelProvider,
				Translator.getString("Error"),
				JOptionPane.ERROR_MESSAGE);
		}
	}

	/** Opens a new document frame based on the parameters
	 *
	 * */
	public void addDocument(
		URL file,
		GraphModelProvider graphModelProvider,
		GPGraph gpGraph,
		GraphModel model,
		GraphUndoManager undo) {

		if (graphModelProvider == null)
			return;

		if (model == null)
			model = graphModelProvider.createCleanGraphModel();

		if (gpGraph == null) {
			gpGraph = graphModelProvider.createCleanGraph(model);
		}

		gpGraph.setSelectNewCells(true);
		gpGraph.setInvokesStopCellEditing(true);
		gpGraph.setMarqueeHandler(getMarqueeHandler());

		GPDocument doc =
			new GPDocument(
				this,
				file,
				graphModelProvider,
				gpGraph,
				model,
				null);

		GPInternalFrame iframe = new GPInternalFrame(doc);
		addGPInternalFrame(iframe);
		iframe.show();
		/*
		try {
			//iframe.setMaximum(true);
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/

		iframe.grabFocus();
	}

	public void removeDocument(GPDocument doc) {
		GPInternalFrame iFrame = (GPInternalFrame) doc2InternalFrame.get(doc);
		removeGPInternalFrame(iFrame);
	}

	public void update() {
		GPDocument currentDoc = getCurrentDocument();

		Object[] keys = currentActionMap.keys();
		for (int i = 0; i < keys.length; i++) {
			Action a = currentActionMap.get(keys[i]);
			if (a instanceof AbstractActionDefault) {
				((AbstractActionDefault) a).update();
			} else {
				if (currentDoc == null) {
					a.setEnabled(false);
				} else {
					a.setEnabled(true);
				}
			}
		}

		if (currentActionMap == defaultActionMap)
			return;

		keys = defaultActionMap.keys();
		for (int i = 0; i < keys.length; i++) {
			Action a = defaultActionMap.get(keys[i]);
			if (a instanceof AbstractActionDefault) {
				((AbstractActionDefault) a).update();
			}
		}
	}

	/**
	 * Returns the barFactory.
	 * @return GPBarFactory
	 */
	public GPBarFactory getBarFactory() {
		return barFactory;
	}

	/**
	 * Sets the barFactory.
	 * @param barFactory The barFactory to set
	 */
	public void setBarFactory(GPBarFactory barFactory) {
		this.barFactory = barFactory;
	}

	public JInternalFrame[] getAllFrames() {
		return desktop.getAllFrames();
	}

	public void setParentActionMap(ActionMap map) {
		defaultActionMap.setParent(map);
	}
	/**
	 * Returns the applicationIcon.
	 * @return ImageIcon
	 */
	public static ImageIcon getApplicationIcon() {
		return applicationIcon;
	}

	/**
	 * Sets the applicationIcon.
	 * @param applicationIcon The applicationIcon to set
	 */
	public static void setApplicationIcon(ImageIcon applicationIcon) {
		GPGraphpad.applicationIcon = applicationIcon;
	}

	/**
	 * Returns the marqueeHandler.
	 * @return JGpdMarqueeHandler
	 */
	public JGpdMarqueeHandler getMarqueeHandler() {
		return marqueeHandler;
	}

	public void addDesktopContainerListener(ContainerListener listener) {
		desktop.addContainerListener(listener);
	}

	public void removeDesktopContainerListener(ContainerListener listener) {
		desktop.removeContainerListener(listener);
	}
}

⌨️ 快捷键说明

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