📄 flowportview.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;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
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.item.Triangle2D;
public class FlowPortView extends PortView {
protected static ImageIcon portIcon = new ImageIcon(GraphManager.class.getResource("images/port1.gif"));
protected FlowPortRenderer renderer = new FlowPortRenderer();
public FlowPortView(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 FlowPortRenderer extends PortRenderer {
public void paint(Graphics g) {
/*
portIcon.paintIcon(this, g, 0, 0);
super.paint(g);
*/
/*
Dimension d = getSize();
System.out.println("Size="+d);
Graphics2D g2 = (Graphics2D) g;
//Shape sp = new Triangle2D(0, 0, d.width, d.height, false);
Shape sp = new Polygon();
boolean tmp = selected;
g2.setColor(Color.gray); // Switch to black
g2.draw(sp); // Outline the shape with it
g2.setPaint(new GradientPaint(0, 0,Color.WHITE,d.width, d.height,Color.RED ));
g2.fill(sp);
*/
//super.paint(g);
Dimension d = getSize();
//System.out.println("Size="+d);
if(getSize().width > portIcon.getIconWidth())
return;
Graphics2D g2 = (Graphics2D) g;
int[] x = new int[3];
int[] y = new int[3];
x[0] = 5;x[1] = 5;x[2] = 15;
y[0] = 1;y[1] = 11;y[2] = 11/2;
Shape sp = new Polygon(x, y, 3);
g2.fill(sp);
g2.setPaint(new GradientPaint(0, 0,new Color(203,173,21),d.width, d.height,new Color(203,173,21) ));
g2.fill(sp);
}
//public void repaint(){};
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -