📄 graphportview.java
字号:
/*
* @(#)MyPortView.java 3.3 23-APR-04
*
* Copyright (c) 2001-2005, Gaudenz Alder All rights reserved.
*
* See LICENSE file in distribution for licensing details of this source file
*/
package flow.graph.gui.graph.item;
import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.jgraph.JGraph;
import org.jgraph.graph.CellViewRenderer;
import org.jgraph.graph.DefaultCellViewFactory;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.Port;
import org.jgraph.graph.PortRenderer;
import org.jgraph.graph.PortView;
import flow.graph.gui.graph.GraphManager;
public class GraphPortView extends PortView {
protected static ImageIcon portIcon = new ImageIcon(GraphManager.class.getResource("images/port.gif"));
protected static MyPortRenderer renderer = new MyPortRenderer();
public GraphPortView(Object cell) {
super(cell);
}
/**
* Returns the bounds for the port view.
*/
public Rectangle2D getBounds() {
if (portIcon != null) {
Point2D pt = (Point2D) getLocation().clone();
int width = portIcon.getIconWidth();
int height = portIcon.getIconHeight();
Rectangle2D bounds = new Rectangle2D.Double();
bounds.setFrame(pt.getX() - width / 2,
pt.getY() - height / 2,
width,
height);
return bounds;
}
return super.getBounds();
}
public CellViewRenderer getRenderer() {
return renderer;
}
public static class MyPortRenderer extends PortRenderer {
public void paint(Graphics g) {
portIcon.paintIcon(this, g, 0, 0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -