📄 rectangleshell.java
字号:
package org.goshawk.workflow.GUI.ShapeShell;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.Rectangle;
import java.awt.Shape;
import java.util.Map;
import org.goshawk.workflow.DoMain.WorkFlowEntity;
import org.goshawk.workflow.GUI.Action.CopyAndPasteShapeShellAction;
import org.goshawk.workflow.GUI.Action.CopyShapeShellAction;
import org.goshawk.workflow.GUI.Action.DeleteShapeShellAction;
public class RectangleShell extends ShapeShell
{
private int height = 60;
private int width = 90;
private Rectangle rect = null;
private PopupMenu popupMenu = null;
private WorkFlowEntity workStep = new WorkFlowEntity();
public RectangleShell()
{
rect = new Rectangle(30,30,width,height);
}
public RectangleShell(Rectangle rect)
{
this.rect = rect;
height = rect.height;
width = rect.width;
}
public RectangleShell(int x, int y, int width, int height)
{
rect = new Rectangle(x,y,width,height);
}
public Rectangle getRect()
{
return rect;
}
public void setRect(Rectangle rect)
{
this.rect = rect;
}
public Shape getShape()
{
return rect;
}
public void setShape(Shape shape) throws ShapeShellException
{
if(shape==null)
{
this.rect = null;
return ;
}
if(!(shape instanceof Rectangle))
throw new ShapeShellException("输入参数类型必须是java.awt.Rectangle");
this.rect = (Rectangle)shape;
}
public int getHeight()
{
return (int)rect.getHeight();
}
public void setHeight(int height)
{
rect.setFrame(rect.x,rect.y,rect.width,(double)height);
}
public int getWidth()
{
return (int)rect.getWidth();
}
public void setWidth(int width)
{
rect.setFrame(rect.x,rect.y,(double)width,rect.height);
}
public int getX()
{
return (int)rect.x;
}
public void setX(int x)
{
rect.setFrame((double)x,rect.y,rect.width,rect.height);
}
public int getY()
{
return (int)rect.y;
}
public void setY(int y)
{
rect.setFrame(rect.x,(double)y,rect.width,rect.height);
}
public int getCenterX()
{
return (int)rect.getCenterX();
}
public int getCenterY()
{
return (int)rect.getCenterY();
}
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
if(isSelected)
{
g2.setColor(selectedColor);
g2.draw(new Rectangle(rect.x-3,rect.y-3,rect.width+6,rect.height+6));
}
g2.setColor(unselectColor);
g2.draw(rect);
}
public PopupMenu getPopupMenu()
{
popupMenu = new PopupMenu("1");
MenuItem copyAndPasteItem = new MenuItem("复制并粘贴");
copyAndPasteItem.addActionListener(new CopyAndPasteShapeShellAction());
popupMenu.add(copyAndPasteItem);
MenuItem copyItem = new MenuItem("复制");
copyItem.addActionListener(new CopyShapeShellAction());
popupMenu.add(copyItem);
MenuItem deleteItem = new MenuItem("删除");
deleteItem.addActionListener(new DeleteShapeShellAction());
popupMenu.add(deleteItem);
return popupMenu;
}
public void setPopupMenu(PopupMenu menu)
{
this.popupMenu = menu;
}
public boolean contains(int x, int y)
{
return this.rect.contains(x,y);
}
public Object clone()
{
return new RectangleShell(rect.x,rect.y,rect.width,rect.height);
}
public WorkFlowEntity getWorkStep()
{
return workStep;
}
public void setWorkStep(WorkFlowEntity workStep)
{
this.workStep = workStep;
}
public void editShape(int mousex,int mousey)
{
}
public void addOtherShape(ShapeShell shape)
{
}
public Map getOtherShapes()
{
return null;
}
public Map setOtherShapes(Map shapes)
{
return null;
}
public ShapeShell getOtherShape(String id)
{
return null;
}
public ShapeShell removeOtherShape(String id)
{
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -