📄 workflow_abstractactiondefault.java
字号:
package treedoc;
//从GRAPHPAD包中提取......用于fileImportGxl类
import java.awt.Component;
import java.util.Map;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import org.jgraph.GPGraphpad;
import org.jgraph.graph.GraphLayoutCache;
import org.jgraph.pad.GPBarFactory;
import org.jgraph.pad.GPDocument;
import org.jgraph.pad.GPGraph;
import org.jgraph.pad.resources.TranslatorConstants;
import org.jgraph.utils.Utilities;
/** An abstract JGraphpad action.
* The base class for
* all JGraphpad actions.
*/
public abstract class workflow_AbstractActionDefault
extends AbstractAction
implements TranslatorConstants {
/** A reference back to the graphpad.
* If an action was performed the
* Actions applies the changes to the current
* Document at the graphpad.
*
*
*/
protected GPGraphpad graphpad;
/**
* Constructor for AbstractActionDefault.
* The Abstract action uses the class name
* without package prefix as action name.
*
* @see Action#NAME
*
*/
public workflow_AbstractActionDefault() {
this((GPGraphpad)null);
}
/**
* Constructor for AbstractActionDefault.
* The Abstract action uses the class name
* without package prefix as action name.
*
*
* @param graphpad The reference to the graphpad for this action
* @see Action#NAME
*
*/
public workflow_AbstractActionDefault(GPGraphpad graphpad) {
this.graphpad = graphpad;
// build the name for this action
// without the package prefix
putValue(Action.NAME, Utilities.getClassNameWithoutPackage(getClass()));
}
/**
* Constructor for AbstractActionDefault.
*
* @param name Key for the name of this action
*/
public workflow_AbstractActionDefault(String name) {
super(name);
}
/**
* Constructor for AbstractActionDefault.
*
* @param graphpad The reference to the graphpad for this action
* @param name Key for the name of this action
*/
public workflow_AbstractActionDefault(GPGraphpad graphpad, String name) {
super(name);
this.graphpad = graphpad;
}
/**
* Constructor for AbstractActionDefault.
*
* @param graphpad The reference to the graphpad for this action
* @param name Key for the name of the action
* @param icon The icon for this action
*/
public workflow_AbstractActionDefault(GPGraphpad graphpad, String name, Icon icon) {
super(name, icon);
this.graphpad = graphpad;
}
/**
* Constructor for AbstractActionDefault.
*
* @param name Key for the name of this action
* @param icon The icon for this action
*/
public workflow_AbstractActionDefault(String name, Icon icon) {
super(name, icon);
}
/** 返回一些重要数据
*
*/
public String getName() {
return (String) getValue(NAME);
}
public GPGraph getCurrentGraph() {
return graphpad.getCurrentGraph();
}
public GraphLayoutCache getCurrentGraphLayoutCache() {
return graphpad.getCurrentDocument().getGraphLayoutCache();
}
public void setSelectionAttributes(Map map) {
if (graphpad != null && graphpad.getCurrentDocument() != null)
graphpad.getCurrentDocument().setSelectionAttributes(map);
}
public void setFontSizeForSelection(float size) {
if (graphpad != null && graphpad.getCurrentDocument() != null)
graphpad.getCurrentDocument().setFontSizeForSelection(size);
}
public void setFontStyleForSelection(int style) {
if (graphpad != null && graphpad.getCurrentDocument() != null)
graphpad.getCurrentDocument().setFontStyleForSelection(style);
}
public void setFontNameForSelection(String fontName) {
if (graphpad != null && graphpad.getCurrentDocument() != null)
graphpad.getCurrentDocument().setFontNameForSelection(fontName);
}
public GPDocument getCurrentDocument() {
return graphpad.getCurrentDocument();
}
/** Creates by default an arry with one
* entry. The entry contains a JMenuItem
* which joins the instance of this Action.
*/
public Component[] getMenuComponents() {
return new Component[] { getMenuComponent(null)};
}
/** Returns by default a list with one JButton.
* The button joints this action.
*
*
*/
public Component[] getToolComponents() {
return new Component[] { getToolComponent(null)};
}
/** Returns a JMenuItem with a link to this action.
*/
protected Component getMenuComponent(String actionCommand) {
JMenuItem item = new JMenuItem(this);
GPBarFactory.fillMenuButton(item, getName(), actionCommand);
String presentationText = getPresentationText(actionCommand);
if (presentationText != null)
item.setText(presentationText);
return item;
}
/** Returns a clean JButton which has a link to this action.
*
*/
protected Component getToolComponent(String actionCommand) {
AbstractButton b = new JButton(this) {
public float getAlignmentY() {
return 0.5f;
}
};
return GPBarFactory.fillToolbarButton(
b,
getName(),
actionCommand);
}
/** empty implementation for this typ of action
*
*/
public void update() {
if (graphpad.getCurrentDocument() == null)
setEnabled(false);
else
setEnabled(true);
}
/** Should return presentation Text for the
* action command or null
* for the default
*/
public String getPresentationText(String actionCommand) {
return null;
}
/**
* Sets the graphpad.
* @param graphpad The graphpad to set
*/
public void setGraphpad(GPGraphpad graphpad) {
this.graphpad = graphpad;
}
/**
* Returns the graphpad.
* @return GPGraphpad
*/
public GPGraphpad getGraphpad() {
return graphpad;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -