📄 legend.java
字号:
package net.sourceforge.jpowergraph;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.swing.Action;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import net.sourceforge.jpowergraph.lens.Lens;
import net.sourceforge.jpowergraph.lens.LensSet;
import net.sourceforge.jpowergraph.lens.NodeFilterLens;
import net.sourceforge.jpowergraph.painters.NodePainter;
/**
* @author Mick Kerrigan
*
* Created on 07-Aug-2005
* Committed by $Author: morcen $
*
* $Source: /cvsroot/jpowergraph/swt/src/net/sourceforge/jpowergraph/Legend.java,v $,
* @version $Revision: 1.2 $ $Date: 2005/08/12 13:10:22 $
*/
public class Legend {
private ArrayList nodePainters = new ArrayList();
private ArrayList nodeClasses = new ArrayList();
private ArrayList nodeDescriptions = new ArrayList();
private NodeFilterLens nodeFilterLens = null;
private Rectangle location = new Rectangle(0, 0, 0, 0);
private HashMap rectangleActionMap = new HashMap();
public Legend() {
}
public Rectangle getLocation(){
return location;
}
public void setLocation(Rectangle theLocation) {
this.location = theLocation;
}
public void clear() {
this.nodePainters.clear();
this.nodeClasses.clear();
this.nodeDescriptions.clear();
}
public ArrayList getNodePainters(){
return nodePainters;
}
public Class getNodeClassForPainter(NodePainter nodePainter){
int index = nodePainters.indexOf(nodePainter);
if (index != -1){
return (Class) nodeClasses.get(index);
}
return null;
}
public String getDescriptionForPainter(NodePainter nodePainter){
int index = nodePainters.indexOf(nodePainter);
if (index != -1){
return (String) nodeDescriptions.get(index);
}
return null;
}
public void add(NodePainter theNodePainter, Class theNodeClass, String nodeDescription) {
if (!nodePainters.contains(theNodePainter)){
this.nodePainters.add(theNodePainter);
this.nodeClasses.add(theNodeClass);
this.nodeDescriptions.add(nodeDescription);
}
}
public void setLens(Lens lens) {
if (lens instanceof NodeFilterLens){
nodeFilterLens = (NodeFilterLens) lens;
}
else if (lens instanceof LensSet){
List lenses = ((LensSet) lens).getLensOfType(NodeFilterLens.class);
if (lenses != null && lenses.size() > 0){
nodeFilterLens = (NodeFilterLens) lenses.get(0);
}
}
}
public NodeFilterLens getNodeFilterLens(){
return nodeFilterLens;
}
public boolean isNodeFilterInUse(){
return nodeFilterLens != null;
}
public void clearActionMap(){
rectangleActionMap.clear();
}
public void addActionRectangle(Rectangle theRectangle, Action theAction){
rectangleActionMap.put(theRectangle, theAction);
}
public Action getActionAtPoint(Point point) {
for (Iterator i = rectangleActionMap.keySet().iterator(); i.hasNext();) {
Rectangle rectangle = (Rectangle) i.next();
if (rectangle.contains(point)){
return (Action) rectangleActionMap.get(rectangle);
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -