Class TLcdGXYContext
- All Implemented Interfaces:
ILcdCloneable
,ILcdGXYContext
,Serializable
,Cloneable
ILcdGXYContext
. This class contains
the information to enable a painter (editor) to perform its drawing (editing)
on an ILcdGXYView
.- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor, which creates anTLcdGXYContext
without any information.TLcdGXYContext
(ILcdGXYContext aGXYContext) Constructs aTLcdGXYContext
from anotherILcdGXYContext
.TLcdGXYContext
(ILcdGXYView aGXYView, ILcdGXYLayer aGXYLayer) Create a newTLcdGXYContext
object.TLcdGXYContext
(ILcdGXYView aGXYView, ILcdGXYLayer aGXYLayer, List<Point> aOriginalLocations, List<Point> aCurrentLocations) Create a newTLcdGXYContext
object.TLcdGXYContext
(ILcdGXYView aGXYView, ILcdGXYPen aGXYPen, int aX, int aY, int aDeltaX, int aDeltaY) Create a newTLcdGXYContext
object -
Method Summary
Modifier and TypeMethodDescriptionclone()
MakesObject.clone()
public.final int
Returns the delta x for the first input point.int
getDeltaX
(int aIndex) Returns the delta x for the input point at indexaIndex
.final int
Returns the delta y for the first input point.int
getDeltaY
(int aIndex) Returns the delta y for the input point at indexaIndex
.double
Returns the DPI scaling factor for the view that is being rendered.final ILcdGXYLayer
final ILcdGXYPen
final ILcdGXYView
int
Returns the number of input pointsReturns a modifiable map to store and retrieve implementation specific context information.final int
This method returns the sensitivity that should be used for painting and editing purposes.Short forgetSnapTarget( 0 )
getSnapTarget
(int aIndex) The snap target at indexaIndex
if the painting or editing action requires one.Short forgetSnapTargetLayer( 0 )
getSnapTargetLayer
(int aIndex) final int
getX()
Returns the current x coordinate of the first input point.int
getX
(int aIndex) Returns the current x coordinate of the input point at the given index.final int
getY()
Returns the current y coordinate of the first input point.int
getY
(int aIndex) Returns the current y coordinate of the input point at the given index.final void
resetFor
(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView) Initializes thisTLcdGXYContext
with default values to paint/edit onaGXYView
anObject
that belongs toaGXYLayer
.final void
setDeltaX
(int aDeltaX) Short forsetDeltaX( aDeltaX, 0 )
void
setDeltaX
(int aDeltaX, int aIndex) Sets the delta of the x coordinate of the input point at indexaIndex
.final void
setDeltaY
(int aDeltaY) Short forsetDeltaY( aDeltaY, 0 )
void
setDeltaY
(int aDeltaY, int aIndex) Sets the delta of the y coordinate of the input point at indexaIndex
.void
setGXYLayer
(ILcdGXYLayer aGXYLayer) Sets anILcdGXYLayer
to thisTLcdGXYContext
.final void
setGXYPen
(ILcdGXYPen aPen) Sets anILcdGXYPen
to thisTLcdGXYContext
.void
setGXYView
(ILcdGXYView aGXYView) Sets anILcdGXYView
to thisTLcdGXYContext
.void
setGXYViewXYWorldTransformation
(ILcdGXYViewXYWorldTransformation aGXYViewXYWorldTransformation) Set a valid ILcdGXYViewXYWorldTransformation that can be used as support for painting or editing.void
setModelXYWorldTransformation
(ILcdModelXYWorldTransformation aModelXYWorldTransformation) Set a valid ILcdModelXYWorldTransformation that can be used as support for painting or editingfinal void
setSensitivity
(int aSensitivity) This method sets the sensitivity that should be used for painting and editing purposes.void
setSnapTarget
(Object aSnapTarget) Short forsetSnapTarget( aSnapTarget, 0 )
void
setSnapTarget
(Object aSnapTarget, int aIndex) Sets the snap target at indexaIndex
.void
setSnapTargetLayer
(ILcdGXYLayer aSnapTargetLayer) Short forsetSnapTargetLayer( aSnapTargetLayer, 0 )
void
setSnapTargetLayer
(ILcdGXYLayer aSnapTargetLayer, int aIndex) final void
setX
(int aX) Sets the current x coordinate of the first input point.void
setX
(int aX, int aIndex) Sets the current x coordinate of the input point at indexaIndex
.final void
setY
(int aY) Sets the current y coordinate of the first input point.void
setY
(int aY, int aIndex) Sets the current y coordinate of the input point at indexaIndex
.toString()
-
Constructor Details
-
TLcdGXYContext
public TLcdGXYContext()Default constructor, which creates anTLcdGXYContext
without any information. Use the available setters to store information in thisTLcdGXYContext
object. -
TLcdGXYContext
public TLcdGXYContext(ILcdGXYView aGXYView, ILcdGXYPen aGXYPen, int aX, int aY, int aDeltaX, int aDeltaY) Create a newTLcdGXYContext
object- Parameters:
aGXYView
- the view. SeegetGXYView()
aGXYPen
- the pen. SeegetGXYPen()
aX
- the x coordinate of the ( mouse ) location, expressed in view coordinates. SeegetX()
aY
- the y coordinate of the ( mouse ) location, expressed in view coordinates. SeegetY()
aDeltaX
- the delta x to consider when painting or editing. SeegetDeltaX()
aDeltaY
- the delta y to consider when painting or editing. SeegetDeltaY()
-
TLcdGXYContext
public TLcdGXYContext(ILcdGXYView aGXYView, ILcdGXYLayer aGXYLayer, List<Point> aOriginalLocations, List<Point> aCurrentLocations) Create a new
TLcdGXYContext
object.It allows to store multiple input points. The
aOriginalLocations
lists contains the location of all the input points.aCurrentLocations
contains the current locations of the points. Both lists should have the same length, and the first point inaOriginalLocations
should be the original location of the first point inaCurrentLocations
. The same applies for the other points in both lists.- Parameters:
aGXYView
- the view. SeegetGXYView()
aGXYLayer
- the layer. SeegetGXYLayer()
aOriginalLocations
- a list containing the original locations of all input points. The points should be expressed in view coordinates. Must not benull
. Use an empty list when no input points should be considered.aCurrentLocations
- a list containing the current locations of all input points. The points should be expressed in view coordinates. Must not benull
. Use an empty list when no input points should be considered.
-
TLcdGXYContext
Create a new
TLcdGXYContext
object. It is initialized with default values to paint/edit anObject
that belongs toaGXYLayer
onaGXYView
.- Parameters:
aGXYView
- the view. SeegetGXYView()
aGXYLayer
- the layer. SeegetGXYLayer()
-
TLcdGXYContext
Constructs aTLcdGXYContext
from anotherILcdGXYContext
.- Parameters:
aGXYContext
- the context on which the createdTLcdGXYContext
will be based. Must not benull
-
-
Method Details
-
getProperties
Description copied from interface:ILcdGXYContext
Returns a modifiable map to store and retrieve implementation specific context information. For example, an editor can use it to store information on an ongoing creation or editing process across multiple invocations, e.g. the handle that is currently being edited.- Specified by:
getProperties
in interfaceILcdGXYContext
- Returns:
- a modifiable map to store and retrieve implementation specific context information
-
getGXYViewXYWorldTransformation
When no
ILcdGXYViewXYWorldTransformation
is set but aILcdGXYView
is available, the transformation of the view will be returned.- Specified by:
getGXYViewXYWorldTransformation
in interfaceILcdGXYContext
- Returns:
- a valid
ILcdGXYViewXYWorldTransformation
that can be used as support for painting or editing. - See Also:
-
setGXYViewXYWorldTransformation
public void setGXYViewXYWorldTransformation(ILcdGXYViewXYWorldTransformation aGXYViewXYWorldTransformation) Set a valid ILcdGXYViewXYWorldTransformation that can be used as support for painting or editing.- Parameters:
aGXYViewXYWorldTransformation
- the transformation- See Also:
-
getModelXYWorldTransformation
Returns the set
ILcdModelXYWorldTransformation
.- Specified by:
getModelXYWorldTransformation
in interfaceILcdGXYContext
- Returns:
- a valid
ILcdModelXYWorldTransformation
that can be used as support for painting or editing. - See Also:
-
setModelXYWorldTransformation
public void setModelXYWorldTransformation(ILcdModelXYWorldTransformation aModelXYWorldTransformation) Set a valid ILcdModelXYWorldTransformation that can be used as support for painting or editing- Parameters:
aModelXYWorldTransformation
- the transformation- See Also:
-
getGXYView
- Specified by:
getGXYView
in interfaceILcdGXYContext
- Returns:
- the
ILcdGXYView
where the drawing or editing occurs. - See Also:
-
setGXYView
Sets anILcdGXYView
to thisTLcdGXYContext
.- Parameters:
aGXYView
- the view.
-
getGXYLayer
- Specified by:
getGXYLayer
in interfaceILcdGXYContext
- Returns:
- the
ILcdGXYLayer
(and therefor theILcdModel
) theObject
to paint or edit belongs to. - See Also:
-
setGXYLayer
Sets anILcdGXYLayer
to thisTLcdGXYContext
.- Parameters:
aGXYLayer
- the layer
-
resetFor
Initializes thisTLcdGXYContext
with default values to paint/edit onaGXYView
anObject
that belongs toaGXYLayer
.- Parameters:
aGXYLayer
- the layer. Must not benull
aGXYView
- the view. Must not benull
-
getGXYPen
- Specified by:
getGXYPen
in interfaceILcdGXYContext
- Returns:
- a valid
ILcdGXYPen
that can be used as support for painting or editing. - See Also:
-
setGXYPen
Sets anILcdGXYPen
to thisTLcdGXYContext
.- Parameters:
aPen
- the pen
-
getInputPointCount
public int getInputPointCount()Returns the number of input points- Specified by:
getInputPointCount
in interfaceILcdGXYContext
- Returns:
- the number of input points
-
setX
public final void setX(int aX) Sets the current x coordinate of the first input point.- Parameters:
aX
- the x coordinate of the current location of the input point at index 0 expressed in view coordinates- See Also:
-
setX
public void setX(int aX, int aIndex) Sets the current x coordinate of the input point at index
aIndex
.The number of input points will automatically be increased when
aIndex
>=getInputPointCount()
- Parameters:
aX
- the x coordinate of the current location of the input point at indexaIndex
. Should be expressed in view coordinates.aIndex
- the index of the input point- See Also:
-
setY
public final void setY(int aY) Sets the current y coordinate of the first input point.- Parameters:
aY
- the y coordinate of the current location of the input point at index 0 expressed in view coordinates- See Also:
-
setY
public void setY(int aY, int aIndex) Sets the current y coordinate of the input point at index
aIndex
.The number of input points will automatically be increased when
aIndex
>=getInputPointCount()
- Parameters:
aY
- the y coordinate of the current location of the input point at indexaIndex
. Should be expressed in view coordinates.aIndex
- the index of the input point- See Also:
-
getX
public final int getX()Description copied from interface:ILcdGXYContext
Returns the current x coordinate of the first input point.- Specified by:
getX
in interfaceILcdGXYContext
- Returns:
- the x coordinate of the current location of the input point at index
0 expressed in view coordinates. If
ILcdGXYContext.getInputPointCount()
== 0, 0 will be returned. - See Also:
-
getX
Description copied from interface:ILcdGXYContext
Returns the current x coordinate of the input point at the given index.- Specified by:
getX
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index of the input point- Returns:
- the x coordinate of the current location of the input point at index
aIndex
, expressed in view coordinates - Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())- See Also:
-
getY
public final int getY()Description copied from interface:ILcdGXYContext
Returns the current y coordinate of the first input point.- Specified by:
getY
in interfaceILcdGXYContext
- Returns:
- the y coordinate of the current location of the input point at index
0, expressed in view coordinates. If
ILcdGXYContext.getInputPointCount()
== 0, 0 will be returned. - See Also:
-
getY
Description copied from interface:ILcdGXYContext
Returns the current y coordinate of the input point at the given index.- Specified by:
getY
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index of the input point- Returns:
- the y coordinate of the current location of the input point at index
aIndex
, expressed in view coordinates - Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())- See Also:
-
setDeltaX
public final void setDeltaX(int aDeltaX) Short forsetDeltaX( aDeltaX, 0 )
- Parameters:
aDeltaX
- the delta x- See Also:
-
setDeltaX
public void setDeltaX(int aDeltaX, int aIndex) Sets the delta of the x coordinate of the input point at index
aIndex
.If for example this context describes a drag of the input point at index
aIndex
,getX( aIndex )
andgetY( aIndex )
describe the current location of that input point. This method allows to specify the difference with the original x location that triggered the drag operation. The original location can then be retrieved by subtracting thegetDeltaX( aIndex )
andgetDeltaY( aIndex )
from the current location.The number of input points will automatically be increased when
aIndex
>=getInputPointCount()
- Parameters:
aDeltaX
- the delta x, expressed in view coordinatesaIndex
- the index of the input point
-
setDeltaY
public final void setDeltaY(int aDeltaY) Short forsetDeltaY( aDeltaY, 0 )
- Parameters:
aDeltaY
- the delta y
-
setDeltaY
public void setDeltaY(int aDeltaY, int aIndex) Sets the delta of the y coordinate of the input point at index
aIndex
.If for example this context describes a drag of the input point at index
aIndex
,getX( aIndex )
andgetY( aIndex )
describe the current location of that input point. This method allows to specify the difference with the original x location that triggered the drag operation. The original location can then be retrieved by subtracting thegetDeltaX( aIndex )
andgetDeltaY( aIndex )
from the current location.The number of input points will automatically be increased when
aIndex
>=getInputPointCount()
- Parameters:
aDeltaY
- the delta y, expressed in view coordinatesaIndex
- the index of the input point
-
getDeltaX
public final int getDeltaX()Description copied from interface:ILcdGXYContext
Returns the delta x for the first input point. This is typically the difference between the current x value and the original x value triggering an interaction.
- Specified by:
getDeltaX
in interfaceILcdGXYContext
- Returns:
- the delta x value of the first input point, or 0 when
ILcdGXYContext.getInputPointCount()
== 0. - See Also:
-
getDeltaX
Description copied from interface:ILcdGXYContext
Returns the delta x for the input point at index
aIndex
. This is typically the difference between the current x value and the original x value triggering an interaction.- Specified by:
getDeltaX
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index- Returns:
- the delta x for the input point at index
aIndex
, expressed in view coordinates - Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())- See Also:
-
getDeltaY
public final int getDeltaY()Description copied from interface:ILcdGXYContext
Returns the delta y for the first input point. This is typically the difference between the current y value and the original y value triggering the interaction.
- Specified by:
getDeltaY
in interfaceILcdGXYContext
- Returns:
- the delta y value of the first input point, or 0 when
ILcdGXYContext.getInputPointCount()
== 0. - See Also:
-
getDeltaY
Description copied from interface:ILcdGXYContext
Returns the delta y for the input point at index
aIndex
. This is typically the difference between the current x value and the original y value triggering an interaction.- Specified by:
getDeltaY
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index- Returns:
- the delta y for the input point at index
aIndex
, expressed in view coordinates - Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())- See Also:
-
toString
-
getSnapTarget
Short for
getSnapTarget( 0 )
When
getInputPointCount()
== 0, this method will returnnull
, whilegetSnapTarget( 0 )
will throw anIndexOutOfBoundsException
.- Specified by:
getSnapTarget
in interfaceILcdGXYContext
- Returns:
- the first snap target, or
null
when no snap target is available - See Also:
-
getSnapTarget
The snap target at indexaIndex
if the painting or editing action requires one. This snap target should correspond to the input point at indexaIndex
.- Specified by:
getSnapTarget
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index- Returns:
- the snap target at index
aIndex
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())
-
setSnapTarget
Short forsetSnapTarget( aSnapTarget, 0 )
- Parameters:
aSnapTarget
- the snap target
-
setSnapTarget
Sets the snap target at index
aIndex
. Do not forget to set the ILcdGXYLayer containing the object.The number of snap targets will automatically be increased when
aIndex
>=getInputPointCount()
.- Parameters:
aSnapTarget
- the snap targetaIndex
- the index- See Also:
-
getSnapTargetLayer
Short for
getSnapTargetLayer( 0 )
When
getInputPointCount()
== 0, this method will returnnull
, whilegetSnapTarget( 0 )
will throw anIndexOutOfBoundsException
.- Specified by:
getSnapTargetLayer
in interfaceILcdGXYContext
- Returns:
- the layer of the first snap target, or
null
when no snap target is available
-
getSnapTargetLayer
Returns the
ILcdGXYLayer
of the snap target at indexaIndex
.- Specified by:
getSnapTargetLayer
in interfaceILcdGXYContext
- Parameters:
aIndex
- the index- Returns:
- the
ILcdGXYLayer
of the snap target at indexaIndex
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getInputPointCount())
-
setSnapTargetLayer
Short forsetSnapTargetLayer( aSnapTargetLayer, 0 )
- Parameters:
aSnapTargetLayer
- the layer of the first snap target
-
setSnapTargetLayer
Sets the
ILcdGXYLayer
of the snap target at indexaIndex
. Do not forget to set the correspondingsnap target
.- Parameters:
aSnapTargetLayer
- the layeraIndex
- the index- See Also:
-
getSensitivity
public final int getSensitivity()This method returns the sensitivity that should be used for painting and editing purposes. If this method returns a value smaller than zero, the painter/editor can choose the sensitivity to use.Note: by default this method will return -1. If you want to define your own sensitivity, you should call
setSensitivity(int)
.- Specified by:
getSensitivity
in interfaceILcdGXYContext
- Returns:
- the sensitivity for painting/editing purposes or a value smaller than zero if the sensitivity should be chosen by the painter/editor.
- See Also:
-
setSensitivity
public final void setSensitivity(int aSensitivity) This method sets the sensitivity that should be used for painting and editing purposes. A value smaller than zero means the painters/editors are responsible for choosing a sensitivity.- Parameters:
aSensitivity
- the sensitivity for painting/editing purposes or a value smaller than zero if the sensitivity should be chosen by the painter/editor.- See Also:
-
getDPIScale
public double getDPIScale()Returns the DPI scaling factor for the view that is being rendered. The return value is typically greater than or equal to 1.0, with 1.0 indicating that no scaling is performed. Please refer toILcdGXYView
for additional information about high DPI rendering support in GXY views.- Returns:
- the DPI scaling factor for the view that is being rendered
- Throws:
IllegalStateException
- when there is no view configured on this context- Since:
- 2019.0
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.java.lang.Object
, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }
- Specified by:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classObject
- See Also:
-