📄 jfgroup.java
字号:
/**
* $Id:JFGroup.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved. *
*/
package com.jfimagine.jfgraph.shape.union;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.Stroke;
import java.awt.BasicStroke;
import java.awt.geom.GeneralPath;
import com.jfimagine.jfdom.Document;
import com.jfimagine.jfdom.Element;
import com.jfimagine.jfgraph.geom.JFPoint;
import com.jfimagine.jfgraph.geom.Rect;
import com.jfimagine.jfgraph.geom.GeomConst;
import com.jfimagine.jfgraph.geom.LineSeg;
import com.jfimagine.jfgraph.shape.decorate.Arrow;
import com.jfimagine.jfgraph.shape.decorate.FontFormat;
import com.jfimagine.jfgraph.shape.decorate.LineFormat;
import com.jfimagine.jfgraph.shape.decorate.FillFormat;
import com.jfimagine.jfgraph.shape.base.AbstractObject;
import com.jfimagine.jfgraph.shape.base.AbstractShape;
import com.jfimagine.jfgraph.shape.base.ShapeConst;
import com.jfimagine.jfgraph.shape.base.ObjectList;
import com.jfimagine.jfgraph.shape.base.Port;
import com.jfimagine.jfgraph.shape.base.Node;
import com.jfimagine.jfgraph.shape.base.JFVersion;
import com.jfimagine.jfgraph.shape.rectangle.AbstractRectangle;
public class JFGroup extends AbstractShape{
/**
* A XML string tag represents a group.
*/
public static final String XML_GROUP ="JFGroup";
/**
* An rectangle object for the outline of this rectangle.
*/
protected Rect m_rect =new Rect();
/**
* Internal object list within a group.
*/
protected ObjectList m_objList=new ObjectList();
/**
* Constructor for group.
*/
public JFGroup(){
setObjectType(ShapeConst.SHAPETYPE_GROUP);
setXMLTag(XML_GROUP);
initNodes();
}
/**
* Get the x offset of current group.
* The x offset is the left-x coordinate position of this group.
*
* @return The x offset of current group.
*
*/
public double getX(){
return m_rect.getX();
}
/**
* Get the y offset of current group.
* The y offset is the top-y coordinate position of this group.
*
* @return The y offset of current group.
*
*/
public double getY(){
return m_rect.getY();
}
/**
* Get the width of current group.
*
* @return The width of current group 'box'.
*
*/
public double getWidth(){
return m_rect.getWidth();
}
/**
* Get the height of current group.
*
* @return The height of current group 'box'.
*
*/
public double getHeight(){
return m_rect.getHeight();
}
/**
* Get internal object list.
* @return Internal object list of this group.
*/
public ObjectList getList(){
return m_objList;
}
/**
* Set internal object list.
* @param objList A new internal object list.
*/
public void setList(List objList){
m_objList.setList(objList);
m_rect.setValue(getBoundsOfObjects());
}
/**
* Get the fill format of current group.
*
* @return The fill format.
*
*/
public FillFormat getFillFormat(){
//get the fill format of an arbitrary object in the group objects list.
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
FillFormat fillFormat =aShape.getFillFormat();
if (fillFormat!=null)
return fillFormat;
}
return null;
}
/**
* Set the fill format of current line.
*
* @param fillFormat A new fill format.
*
*/
public void setFillFormat(FillFormat fillFormat){
if (fillFormat==null)
return;
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setFillFormat(fillFormat);
}
}
/**
* Get the line format of current line.
*
* @return The line format.
*
*/
public LineFormat getLineFormat(){
//get the fill format of an arbitrary object in the group objects list.
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
LineFormat lineFormat =aShape.getLineFormat();
if (lineFormat!=null)
return lineFormat;
}
return null;
}
/**
* Set the line format of current line.
*
* @param lineFormat A new line format.
*
*/
public void setLineFormat(LineFormat lineFormat){
if (lineFormat==null)
return;
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setLineFormat(lineFormat);
}
}
/**
* Get the arrow format of current object.
*
* @return The arrow format.
*
*/
public Arrow getArrow(){
//get the fill format of an arbitrary object in the group objects list.
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
Arrow arrow =aShape.getArrow();
if (arrow!=null)
return arrow;
}
return null;
}
/**
* Set the arrow of current line.
*
* @param arrow A new arrow.
*
*/
public void setArrow(Arrow arrow){
if (arrow==null)
return;
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setArrow(arrow);
}
}
/**
* Get the font format of current object.
*
* @return The font format.
*
*/
public FontFormat getFontFormat(){
return super.getFontFormat();
}
/**
* Set the font format of current object.
*
* @param fontFormat A new font format.
*
*/
public void setFontFormat(FontFormat fontFormat){
super.setFontFormat(fontFormat);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setFontFormat(fontFormat);
}
}
/**
* set disable scaling
*/
public void setDisableScaling(boolean disable){
super.setDisableScaling(disable);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setDisableScaling(disable);
}
}
/**
* set disable modifying properties
*/
public void setDisableModifyingProperties(boolean disable){
super.setDisableModifyingProperties(disable);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setDisableModifyingProperties(disable);
}
}
/**
* set disable motion
*/
public void setDisableMotion(boolean disable){
super.setDisableMotion(disable);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setDisableMotion(disable);
}
}
/**
* set if is invisible
*/
public void setInvisible(boolean invisible){
super.setInvisible(invisible);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setInvisible(invisible);
}
}
/**
* Set all nodes/ports/labels' parent, this method will be called
* after a clone method because of a clone method will not clone their parent.
*/
public void setParent(){
super.setParent();
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setParent();
}
}
/** set if show or hide current object's design info
*/
public void setShowDesign(boolean showDesign){
super.setShowDesign(showDesign);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.setShowDesign(showDesign);
}
}
/**
* Get a max object id of current object,object id starts at 0.
* This action is same as getObjectId when the object is an indifidual object,
* but is different as getObjectId when the object is just a group object.
*
* @return The object id.
*
*/
public int getMaxObjectId(){
int maxId =getObjectId();
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
int objectId =aShape.getMaxObjectId();
if (objectId>maxId)
maxId =objectId;
}
return maxId;
}
/**
* Clear the access times of this object.
*
*/
public void clearAccessTimes(){
super.clearAccessTimes();
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.clearAccessTimes();
}
}
/** set zoom scale
* @param zoomScale A new zoom scale.
*/
public void setZoomScale(double zoomScale){
super.setZoomScale(zoomScale);
m_objList.setZoomScale(zoomScale);
}
/**
* move relational ports while moving this object.
* @param movedList An object list that has already processed, so don't change them further.
*/
public void moveRelationalPorts(ObjectList movedList){
super.moveRelationalPorts(movedList);
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.moveRelationalPorts(movedList);
}
}
/**
* unbound broken ports
*/
public void unboundBrokenPorts(){
super.unboundBrokenPorts();
Iterator it =m_objList.getList().iterator();
while (it!=null && it.hasNext()){
AbstractShape aShape =(AbstractShape)it.next();
aShape.unboundBrokenPorts();
}
}
/**
* Get the bounds of this rectangle.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -