public class TLcdGXYContext extends Object implements ILcdGXYContext, ILcdCloneable
ILcdGXYContext
. This class contains
the information to enable a painter (editor) to perform its drawing (editing)
on an ILcdGXYView
.Constructor and Description |
---|
TLcdGXYContext()
Default constructor, which creates an
TLcdGXYContext without any information. |
TLcdGXYContext(ILcdGXYContext aGXYContext)
Constructs a
TLcdGXYContext from another ILcdGXYContext . |
TLcdGXYContext(ILcdGXYView aGXYView,
ILcdGXYLayer aGXYLayer)
Create a new
TLcdGXYContext object. |
TLcdGXYContext(ILcdGXYView aGXYView,
ILcdGXYLayer aGXYLayer,
List<Point> aOriginalLocations,
List<Point> aCurrentLocations)
Create a new
TLcdGXYContext object. |
TLcdGXYContext(ILcdGXYView aGXYView,
ILcdGXYPen aGXYPen,
int aX,
int aY,
int aDeltaX,
int aDeltaY)
Create a new
TLcdGXYContext object |
Modifier and Type | Method and Description |
---|---|
TLcdGXYContext |
clone()
Makes
Object.clone() public. |
int |
getDeltaX()
Returns the delta x for the first input point.
|
int |
getDeltaX(int aIndex)
Returns the delta x for the input point at index
aIndex . |
int |
getDeltaY()
Returns the delta y for the first input point.
|
int |
getDeltaY(int aIndex)
Returns the delta y for the input point at index
aIndex . |
double |
getDPIScale()
Returns the DPI scaling factor for the view that is being rendered.
|
ILcdGXYLayer |
getGXYLayer() |
ILcdGXYPen |
getGXYPen() |
ILcdGXYView |
getGXYView() |
ILcdGXYViewXYWorldTransformation |
getGXYViewXYWorldTransformation() |
int |
getInputPointCount()
Returns the number of input points
|
ILcdModelXYWorldTransformation |
getModelXYWorldTransformation() |
Map<Object,Object> |
getProperties()
Returns a modifiable map to store and retrieve implementation specific context information.
|
int |
getSensitivity()
This method returns the sensitivity that should be used for painting and editing purposes.
|
Object |
getSnapTarget()
Short for
getSnapTarget( 0 ) |
Object |
getSnapTarget(int aIndex)
The snap target at index
aIndex if the painting or editing action requires one. |
ILcdGXYLayer |
getSnapTargetLayer()
Short for
getSnapTargetLayer( 0 ) |
ILcdGXYLayer |
getSnapTargetLayer(int aIndex)
|
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.
|
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.
|
void |
resetFor(ILcdGXYLayer aGXYLayer,
ILcdGXYView aGXYView)
Initializes this
TLcdGXYContext with default values to paint/edit on
aGXYView an Object that belongs to aGXYLayer . |
void |
setDeltaX(int aDeltaX)
Short for
setDeltaX( aDeltaX, 0 ) |
void |
setDeltaX(int aDeltaX,
int aIndex)
Sets the delta of the x coordinate of the input point at index
aIndex . |
void |
setDeltaY(int aDeltaY)
Short for
setDeltaY( aDeltaY, 0 ) |
void |
setDeltaY(int aDeltaY,
int aIndex)
Sets the delta of the y coordinate of the input point at index
aIndex . |
void |
setGXYLayer(ILcdGXYLayer aGXYLayer)
Sets an
ILcdGXYLayer to this TLcdGXYContext . |
void |
setGXYPen(ILcdGXYPen aPen)
Sets an
ILcdGXYPen to this TLcdGXYContext . |
void |
setGXYView(ILcdGXYView aGXYView)
Sets an
ILcdGXYView to this TLcdGXYContext . |
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 editing
|
void |
setSensitivity(int aSensitivity)
This method sets the sensitivity that should be used for painting and editing purposes.
|
void |
setSnapTarget(Object aSnapTarget)
Short for
setSnapTarget( aSnapTarget, 0 ) |
void |
setSnapTarget(Object aSnapTarget,
int aIndex)
Sets the snap target at index
aIndex . |
void |
setSnapTargetLayer(ILcdGXYLayer aSnapTargetLayer)
Short for
setSnapTargetLayer( aSnapTargetLayer, 0 ) |
void |
setSnapTargetLayer(ILcdGXYLayer aSnapTargetLayer,
int aIndex)
|
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 index
aIndex . |
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 index
aIndex . |
String |
toString() |
public TLcdGXYContext()
TLcdGXYContext
without any information. Use
the available setters to store information in this TLcdGXYContext
object.public TLcdGXYContext(ILcdGXYView aGXYView, ILcdGXYPen aGXYPen, int aX, int aY, int aDeltaX, int aDeltaY)
TLcdGXYContext
objectaGXYView
- the view. See getGXYView()
aGXYPen
- the pen. See getGXYPen()
aX
- the x coordinate of the ( mouse ) location, expressed in view coordinates. See
getX()
aY
- the y coordinate of the ( mouse ) location, expressed in view coordinates. See
getY()
aDeltaX
- the delta x to consider when painting or editing. See getDeltaX()
aDeltaY
- the delta y to consider when painting or editing. See getDeltaY()
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 in
aOriginalLocations
should be the original location of the first point in
aCurrentLocations
. The same applies for the other points in both lists.
aGXYView
- the view. See getGXYView()
aGXYLayer
- the layer. See getGXYLayer()
aOriginalLocations
- a list containing the original locations of all input points. The
points should be expressed in view coordinates. Must not be
null
. 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 be
null
. Use an empty list when no input points should be
considered.public TLcdGXYContext(ILcdGXYView aGXYView, ILcdGXYLayer aGXYLayer)
Create a new TLcdGXYContext
object. It is initialized with default values to
paint/edit an Object
that belongs to aGXYLayer
on aGXYView
.
aGXYView
- the view. See getGXYView()
aGXYLayer
- the layer. See getGXYLayer()
public TLcdGXYContext(ILcdGXYContext aGXYContext)
TLcdGXYContext
from another ILcdGXYContext
.aGXYContext
- the context on which the created TLcdGXYContext
will be based.
Must not be null
public Map<Object,Object> getProperties()
ILcdGXYContext
getProperties
in interface ILcdGXYContext
public final ILcdGXYViewXYWorldTransformation getGXYViewXYWorldTransformation()
When no ILcdGXYViewXYWorldTransformation
is set but a
ILcdGXYView
is available, the transformation of the view will be returned.
getGXYViewXYWorldTransformation
in interface ILcdGXYContext
ILcdGXYViewXYWorldTransformation
that can be used as support for
painting or editing.ILcdGXYPen
public void setGXYViewXYWorldTransformation(ILcdGXYViewXYWorldTransformation aGXYViewXYWorldTransformation)
aGXYViewXYWorldTransformation
- the transformationgetGXYViewXYWorldTransformation()
public final ILcdModelXYWorldTransformation getModelXYWorldTransformation()
Returns the set ILcdModelXYWorldTransformation
.
getModelXYWorldTransformation
in interface ILcdGXYContext
ILcdModelXYWorldTransformation
that can be used as support for
painting or editing.ILcdGXYPen
public void setModelXYWorldTransformation(ILcdModelXYWorldTransformation aModelXYWorldTransformation)
aModelXYWorldTransformation
- the transformationgetModelXYWorldTransformation()
public final ILcdGXYView getGXYView()
getGXYView
in interface ILcdGXYContext
ILcdGXYView
where the drawing or editing occurs.ILcdGXYView
public void setGXYView(ILcdGXYView aGXYView)
ILcdGXYView
to this TLcdGXYContext
.aGXYView
- the view.public final ILcdGXYLayer getGXYLayer()
getGXYLayer
in interface ILcdGXYContext
ILcdGXYLayer
(and therefor the
ILcdModel
) the Object
to paint or edit belongs to.ILcdLayer.getModel()
public void setGXYLayer(ILcdGXYLayer aGXYLayer)
ILcdGXYLayer
to this TLcdGXYContext
.aGXYLayer
- the layerpublic final void resetFor(ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView)
TLcdGXYContext
with default values to paint/edit on
aGXYView
an Object
that belongs to aGXYLayer
.aGXYLayer
- the layer. Must not be null
aGXYView
- the view. Must not be null
public final ILcdGXYPen getGXYPen()
getGXYPen
in interface ILcdGXYContext
ILcdGXYPen
that can be used as support for
painting or editing.ILcdGXYPen
public final void setGXYPen(ILcdGXYPen aPen)
ILcdGXYPen
to this TLcdGXYContext
.aPen
- the penpublic int getInputPointCount()
getInputPointCount
in interface ILcdGXYContext
public final void setX(int aX)
aX
- the x coordinate of the current location of the input point at index
0 expressed in view coordinatesILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
getInputPointCount()
,
setX(int, int)
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()
aX
- the x coordinate of the current location of the input point at index
aIndex
. Should be expressed in view coordinates.aIndex
- the index of the input pointsetX(int)
,
getX()
,
getX(int)
,
getInputPointCount()
public final void setY(int aY)
aY
- the y coordinate of the current location of the input point at index
0 expressed in view coordinatesILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
getInputPointCount()
,
setY(int, int)
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()
aY
- the y coordinate of the current location of the input point at index
aIndex
. Should be expressed in view coordinates.aIndex
- the index of the input pointsetY(int)
,
getY()
,
getY(int)
,
getInputPointCount()
public final int getX()
ILcdGXYContext
getX
in interface ILcdGXYContext
ILcdGXYContext.getInputPointCount()
== 0, 0 will be returned.ILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYContext.getInputPointCount()
,
ILcdGXYContext.getX(int)
public int getX(int aIndex) throws IndexOutOfBoundsException
ILcdGXYContext
getX
in interface ILcdGXYContext
aIndex
- the index of the input pointaIndex
, expressed in view coordinatesIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())ILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYContext.getInputPointCount()
public final int getY()
ILcdGXYContext
getY
in interface ILcdGXYContext
ILcdGXYContext.getInputPointCount()
== 0, 0 will be returned.ILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYContext.getInputPointCount()
,
ILcdGXYContext.getY(int)
public int getY(int aIndex) throws IndexOutOfBoundsException
ILcdGXYContext
getY
in interface ILcdGXYContext
aIndex
- the index of the input pointaIndex
, expressed in view coordinatesIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())ILcdGXYPainter.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYEditor.edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYContext.getInputPointCount()
public final void setDeltaX(int aDeltaX)
setDeltaX( aDeltaX, 0 )
aDeltaX
- the delta xsetDeltaX(int, int)
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 )
and getY( 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 the
getDeltaX( aIndex )
and getDeltaY( aIndex )
from the current
location.
The number of input points will automatically be increased when aIndex
>=
getInputPointCount()
aDeltaX
- the delta x, expressed in view coordinatesaIndex
- the index of the input pointpublic final void setDeltaY(int aDeltaY)
setDeltaY( aDeltaY, 0 )
aDeltaY
- the delta ypublic 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 )
and getY( 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 the
getDeltaX( aIndex )
and getDeltaY( aIndex )
from the current
location.
The number of input points will automatically be increased when aIndex
>=
getInputPointCount()
aDeltaY
- the delta y, expressed in view coordinatesaIndex
- the index of the input pointpublic final int getDeltaX()
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.
getDeltaX
in interface ILcdGXYContext
ILcdGXYContext.getInputPointCount()
== 0.ILcdGXYContext.getInputPointCount()
,
ILcdGXYContext.getDeltaX(int)
public int getDeltaX(int aIndex) throws IndexOutOfBoundsException
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.
getDeltaX
in interface ILcdGXYContext
aIndex
- the indexaIndex
, expressed in view coordinatesIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())ILcdGXYContext.getInputPointCount()
public final int getDeltaY()
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.
getDeltaY
in interface ILcdGXYContext
ILcdGXYContext.getInputPointCount()
== 0.ILcdGXYContext.getInputPointCount()
,
ILcdGXYContext.getDeltaY(int)
public int getDeltaY(int aIndex) throws IndexOutOfBoundsException
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.
getDeltaY
in interface ILcdGXYContext
aIndex
- the indexaIndex
, expressed in view coordinatesIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())ILcdGXYContext.getInputPointCount()
public Object getSnapTarget()
Short for getSnapTarget( 0 )
When getInputPointCount()
== 0, this method will return null
, while
getSnapTarget( 0 )
will throw an IndexOutOfBoundsException
.
getSnapTarget
in interface ILcdGXYContext
null
when no snap target is availablegetSnapTarget(int)
public Object getSnapTarget(int aIndex) throws IndexOutOfBoundsException
aIndex
if the painting or editing action requires one. This
snap target should correspond to the input point at index aIndex
.getSnapTarget
in interface ILcdGXYContext
aIndex
- the indexaIndex
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())public void setSnapTarget(Object aSnapTarget)
setSnapTarget( aSnapTarget, 0 )
aSnapTarget
- the snap targetpublic void setSnapTarget(Object aSnapTarget, int aIndex)
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()
.
aSnapTarget
- the snap targetaIndex
- the indexsetSnapTargetLayer(ILcdGXYLayer, int)
public ILcdGXYLayer getSnapTargetLayer()
Short for getSnapTargetLayer( 0 )
When getInputPointCount()
== 0, this method will return null
, while
getSnapTarget( 0 )
will throw an IndexOutOfBoundsException
.
getSnapTargetLayer
in interface ILcdGXYContext
null
when no snap target is
availablepublic ILcdGXYLayer getSnapTargetLayer(int aIndex) throws IndexOutOfBoundsException
Returns the ILcdGXYLayer
of the snap target at
index aIndex
.
getSnapTargetLayer
in interface ILcdGXYContext
aIndex
- the indexILcdGXYLayer
of the snap target at
index aIndex
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
getInputPointCount())public void setSnapTargetLayer(ILcdGXYLayer aSnapTargetLayer)
setSnapTargetLayer( aSnapTargetLayer, 0 )
aSnapTargetLayer
- the layer of the first snap targetpublic void setSnapTargetLayer(ILcdGXYLayer aSnapTargetLayer, int aIndex)
Sets the ILcdGXYLayer
of the snap target at
index aIndex
. Do not forget to set the corresponding snap target
.
aSnapTargetLayer
- the layeraIndex
- the indexsetSnapTargetLayer(ILcdGXYLayer, int)
public final int getSensitivity()
Note: by default this method will return -1. If you want to define your own sensitivity, you
should call setSensitivity(int)
.
getSensitivity
in interface ILcdGXYContext
setSensitivity(int)
public final void setSensitivity(int aSensitivity)
aSensitivity
- the sensitivity for painting/editing purposes or a value smaller than zero
if the sensitivity should be chosen by the painter/editor.getSensitivity()
public double getDPIScale()
ILcdGXYView
for additional information about high DPI
rendering support in GXY views.IllegalStateException
- when there is no view configured on this contextpublic TLcdGXYContext clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()