public class SpenObjectShapeBase extends SpenObjectBase
ObjectShapeBase is a base class of ObjectShape and ObjectLine.
It supports connection between two ObjectShapeBase objects.
An ObjectShapeBase object can connect to the other ObjectShapeBase object.
Exactly, a connection point can connect to a connection point of the other object.
After it connect to other object, it influences other object when it moves, resizes or scales.
It depends on an implementation which attributes are influenced by these changes.
It can also select which visual effect will be applied.
There are various effects. Line color, line style.
| Modifier and Type | Class and Description |
|---|---|
static class |
SpenObjectShapeBase.ConnectedInfo
A class used to inform details of current connection.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECTION_MODE_LOOSELY_COUPLED
Connection Mode : An object is loosely coupled with connected objects.
|
static int |
CONNECTION_MODE_TIGHTLY_COUPLED
Connection Mode : An object is tightly coupled with connected objects
All connection related events would be generated to connected objects.
|
OBJECT_MINIMUM_SIZE, RESIZE_OPTION_DISABLE, RESIZE_OPTION_FREE, RESIZE_OPTION_KEEP_RATIO, SPEN_INFINITY_FLOAT, SPEN_INFINITY_INT, TYPE_CONTAINER, TYPE_IMAGE, TYPE_LINE, TYPE_NONE, TYPE_SHAPE, TYPE_STROKE, TYPE_TEXT_BOX| Modifier and Type | Method and Description |
|---|---|
void |
copy(SpenObjectBase source)
Copy data from the specified object.
|
int |
getConnectedInfoCount()
Get the number of the connection information.
|
int |
getConnectionMode()
Get current connection mode.
|
void |
getLineColorEffect(SpenLineColorEffect effect)
Get the line color effect.
|
void |
getLineStyleEffect(SpenLineStyleEffect effect)
Get the line style effect.
|
SpenObjectShapeBase.ConnectedInfo |
getMagneticConnectionInfo(int index)
Get magnetic connection info of the specified index.
|
PointF |
getMagneticConnectionPoint(int index)
Get current magnetic connection point of the specified index.
|
PointF |
getMagneticConnectionPoint(int index,
float degree)
Get magnetic connection point of the specified index with a degree.
|
int |
getMagneticConnectionPointCount()
Get the number of magnetic connection points.
|
int |
getNearestMagneticConnectionPointIndex(float x,
float y)
Get index of the nearest magnetic connection point from the specified position.
|
void |
resetLineColorEffect()
Reset the line color effect as the default one.
|
boolean |
resetLineStyleEffect()
Reset the line style effect as the default one.
|
void |
setConnectionMode(int mode)
Set the connection mode.
|
void |
setLineColorEffect(SpenLineColorEffect effect)
Set the line color effect.
|
void |
setLineStyleEffect(SpenLineStyleEffect effect)
Set the line style effect.
|
attachFile, clearChangedFlag, detachFile, equals, getAttachedFile, getDrawnRect, getExtraDataByteArray, getExtraDataInt, getExtraDataString, getExtraDataStringArray, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getRect, getResizeOption, getRotation, getRuntimeHandle, getSorDataInt, getSorDataString, getSorInfo, getSorPackageLink, getTemplateProperty, getType, getUserId, hasExtraDataByteArray, hasExtraDataInt, hasExtraDataString, hasExtraDataStringArray, hashCode, hasSorDataInt, hasSorDataString, isChanged, isFlipEnabled, isMovable, isOutOfViewEnabled, isRecorded, isRotatable, isSelectable, isVisible, removeExtraDataByteArray, removeExtraDataInt, removeExtraDataString, removeExtraDataStringArray, removeSorDataInt, removeSorDataString, setExtraDataByteArray, setExtraDataInt, setExtraDataString, setExtraDataStringArray, setFlipEnabled, setMaxSize, setMinSize, setMovable, setOutOfViewEnabled, setRecorded, setRect, setResizeOption, setRotatable, setRotation, setSelectable, setSorDataInt, setSorDataString, setSorInfo, setSorPackageLink, setUserId, setVisibilitypublic static final int CONNECTION_MODE_TIGHTLY_COUPLED
public static final int CONNECTION_MODE_LOOSELY_COUPLED
public void setLineColorEffect(SpenLineColorEffect effect)
effect - Line color effect to set.getLineColorEffect(SpenLineColorEffect),
resetLineColorEffect()public void getLineColorEffect(SpenLineColorEffect effect)
effect - (output)
The instance of a line color effect. Result will be copied to this instance.IllegalArgumentException - If the effect is null.setLineColorEffect(SpenLineColorEffect),
resetLineColorEffect()public void resetLineColorEffect()
setLineColorEffect(SpenLineColorEffect),
getLineColorEffect(SpenLineColorEffect)public void setLineStyleEffect(SpenLineStyleEffect effect)
effect - Line style effect to set.getLineStyleEffect(SpenLineStyleEffect),
resetLineStyleEffect()public void getLineStyleEffect(SpenLineStyleEffect effect)
effect - (output)
The instance of a line style effect. Result will be copied to this instance.IllegalArgumentException - If the effect is null.setLineStyleEffect(SpenLineStyleEffect),
resetLineStyleEffect()public boolean resetLineStyleEffect()
setLineStyleEffect(SpenLineStyleEffect),
getLineStyleEffect(SpenLineStyleEffect)public void setConnectionMode(int mode)
Each object has its own connection points. Each connection point has a position information and object lists which is connected. Generally speaking, if two objects are connected to each other, it means their "connection points" are connected each other. The connected connection points usually should have same connection information.
Let's assume there are a rectangle shape and a line.
A rectangle shape has four connection points on its four side. Let's call theme as "A", "B", "C", "D".
A line has two connection points on its both edge. Let's call them as "a", "b".
Now connect two objects. At this time, "A" would connect to "a". "A" and "a" would locate at same position.
The "a" which is connected to "A" would registered to the object list of "A" and vice versa.
Let's move the rectangle shape to another place. As the object moves, the connection point "A" should move to corresponding position.
At time, if we check the connection information, we can find they are connected each other but the position is different.
That is, the integrity of connection information is broken.
Connection mode determines how we fix this problem. SPen supports below two modes.
Tightly Coupled Mode : This mode always try to keep the integrity of connection information. Let's see above example again. If "a" follows "A", the integrity will be kept. If "a" doesn't want to move its position, "a" can decide to disconnect from "A". Although the position is different from each other, it's not a problem because they are disconnected.
Loosely Coupled Mode : This mode never try to keep the integrity of connection information. They can be in connected even they locate at different position.
Two modes have different event propagation mechanism.
In tightly coupled mode, when "A" is changed, the event that it is changed propagates to "a". So "a" can decide it should follow "A" or disconnect from "A". Beside this, in loosely coupled mode, when "A" is changed, the event that it is changed never propagates to "a". Now "a" doesn't know what happens to "A", "a" doesn't do anything. Integrity would be broken.
When the mode is changed from loosely coupled mode to tightly coupled mode, because the integrity in loosely coupled mode can be broken, it should recover the integrity.
It finds all of the connection points which have integrity problem and reports them to connected objects.
When it does group level operation, the loosely coupled mode can be useful. If we moves more than two connected objects, a move command would generate various intermediate event which affect connected object. These changes can make side effect to following original move command. To prevent this problem, we can use loosely coupled mode.
mode - Connection mode to set. It can be CONNECTION_MODE_TIGHTLY_COUPLED or CONNECTION_MODE_LOOSELY_COUPLED.IllegalArgumentException - Thrown if the mode is not CONNECTION_MODE_TIGHTLY_COUPLED
or CONNECTION_MODE_LOOSELY_COUPLED.getConnectionMode()public int getConnectionMode()
CONNECTION_MODE_TIGHTLY_COUPLED or CONNECTION_MODE_LOOSELY_COUPLED.setConnectionMode(int)public int getMagneticConnectionPointCount()
getMagneticConnectionPoint(int),
getMagneticConnectionPoint(int, float)public PointF getMagneticConnectionPoint(int index)
index - The specified index.getMagneticConnectionPointCount(),
getMagneticConnectionPoint(int, float)public PointF getMagneticConnectionPoint(int index, float degree)
index - The specified index.degree - The specified degree to get.getMagneticConnectionPointCount(),
getMagneticConnectionPoint(int)public SpenObjectShapeBase.ConnectedInfo getMagneticConnectionInfo(int index)
index - The specified index.getMagneticConnectionPointCount(),
getMagneticConnectionPoint(int)public int getNearestMagneticConnectionPointIndex(float x,
float y)
x - The x-coordinate value to find.y - The y-coordinate value to find.public int getConnectedInfoCount()
getConnectedInfo(int)public void copy(SpenObjectBase source)
copy in class SpenObjectBasesource - The source object.IllegalArgumentException - Thrown if class type is different.
Or if source is null.