public abstract class GUIelement
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CHECKBOX |
static int |
READOUT |
static int |
SELECTBOX |
static int |
SLIDER |
Constructor and Description |
---|
GUIelement() |
GUIelement(GUITab gut) |
Modifier and Type | Method and Description |
---|---|
static void |
addElementTypeMapping(java.lang.String source,
java.lang.String target)
Add an elementType-specific mapping to this particular type of
GUIelement . |
void |
addFloatProperty(int id,
java.lang.String name,
float value)
Initialize a new Float property and then add it.
|
static void |
addGlobalElementMapping(java.lang.String source,
java.lang.String target)
Add an global mapping, applicable for all
GUIelement s, when they
are being edited. |
void |
addIntegerProperty(int id,
java.lang.String name,
int value)
Initialize a new Integer property and then add it.
|
void |
addMapping(java.lang.String source,
java.lang.String target)
Add an instance-specific mapping to this particular instance of
GUIelement . |
void |
addProperty(Property p)
Register a new
Property for this GUIelement . |
void |
addStringProperty(int id,
java.lang.String name,
java.lang.String value)
Initialize a new String property and then add it.
|
void |
addTags(java.lang.String t)
Add letter tags, one for each letter of the string provided, if this tag
is not already present for this element.
|
void |
copyPropertiesTo(GUIelement ge)
|
javafx.scene.paint.Color |
getColor1() |
javafx.scene.paint.Color |
getColor2() |
javafx.scene.paint.Color |
getColor3() |
javafx.scene.paint.Color |
getColor4() |
java.lang.String |
getContextDependantName()
Either returns the name of this element (same as calling
getName ,
or the UniqueName (same as calling getUniqueName ). |
static MappingManager |
getElementTypeMappingManager()
Getter for the mapping manager for the specific type of GUI elements.
|
static MappingManager |
getGlobalElementMappingManager() |
java.lang.String |
getGUIelementName() |
GUIPanel |
getGUIPanel() |
int |
getHeight() |
java.util.HashMap<java.lang.Integer,java.lang.String> |
getId2NameMap() |
java.util.HashMap<java.lang.Integer,Property> |
getId2PropertyMap() |
FloatPoint |
getLastPositionDrawnTo() |
float |
getMax() |
Menu |
getMenu() |
float |
getMin() |
int |
getModuleGUIID()
Returns the ID, assigned by the module during the initialization stage,
if this
GUIelement was initialized by a module. |
java.lang.String |
getName() |
java.util.HashMap<java.lang.String,java.lang.Integer> |
getName2IdMap() |
java.util.HashMap<Property,java.lang.Integer> |
getProperty2idMap()
Deprecated.
|
Property |
getPropertyById(int id)
Return the
Property object, provided its unique ID. |
Property |
getPropertyByName(java.lang.String name)
Return the
Property object, provided its unique name. |
Register |
getRegister() |
java.lang.String |
getTags()
Return a string, representing all the tags stored in this element.
|
MappingManager |
getThisInstanceMappingManager()
Getter for the mapping manager of the specific instance of a GUI element.
|
java.lang.String |
getUniqueName()
Returns the UniqueName of this element.
|
float |
getValue() |
int |
getWidth() |
boolean |
hasTag(java.lang.String t)
Whether or not does the GUI element have ALL of the tags listed as
letters in the string t.
|
boolean |
isDeleted() |
boolean |
isEnabled() |
boolean |
isFocused() |
boolean |
isSelected() |
boolean |
isVisible() |
boolean |
isWithinBounds(double x,
double y)
Return whether or not the point defined by the coordinates provided is
within the bounds of this
GUIelement . |
GUIelement |
makeCopy() |
boolean |
notifyAboutKeyPress(java.lang.String eventText,
boolean runLiteralWhenNoMatch)
Do some action, provided a String to parse as a sequence of key presses.
|
void |
paint(javafx.scene.canvas.GraphicsContext gc,
double x,
double y)
Paint this
GUIelement on some place on the
GraphicsContext provided, on position, determined by the x and y
arguments. |
void |
recalculateUniqueName(GUITab gt)
Regenerate the UniqueName, based on the current user readable name and
current tab.
|
void |
recompileEvents()
Compile the bytecode for all CLUC events, that can be fired by this
GUIelement , including the getters and setters of the individual
Property objects. |
void |
removeAllTags()
Remove all the tags, assigned to this
GUIelement |
void |
removeTags(java.lang.String t)
Remove all tags, letter of which matches one of the letters in the
provided string
|
void |
requestRepaint()
Call the
GUITab this GUIelement is placed on and request
it to repaint it sometime later. |
void |
setDeleted(boolean deleted)
set whether or not the element has been deleted and not placed on any tab again yet.
|
void |
setEnabled(boolean enabled) |
void |
setFloatProperty(java.lang.String name,
float value,
boolean undoable)
Deprecated.
!!!This method should not be used, or should be reimplemented
first!!! It doesn't fire the callbacks at all and replaces the
Property with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value) instead. |
void |
setFocused(boolean focused)
Focus this
GUIelement |
void |
setGUIPanel(GUIPanel gup)
This method sets the containing GUI Panel of the GUI element.
|
void |
setGUITab(GUITab gut)
Set the respective
GUITab this GUIelement is on to the
one provided. |
void |
setId2NameMap(java.util.HashMap<java.lang.Integer,java.lang.String> id2NameMap)
|
void |
setId2PropertyMap(java.util.HashMap<java.lang.Integer,Property> id2PropertyMap)
Set the
HashMap that maps the IDs of Property objects to
these objects themselves. |
void |
setIntegerProperty(java.lang.String name,
int value,
boolean undoable)
Deprecated.
!!!This method should not be used, or should be reimplemented
first!!! It doesn't fire the callbacks at all and replaces the
Property with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value) instead. |
void |
setMenu(Menu m)
Set the
Menu , which will get displayed whenever this
GUIelement is being edited. |
void |
setModuleGUIID(int ID)
Used to set the ID, assigned by the module during the initialization
stage, if this
GUIelement was initialized by a module. |
void |
setName(java.lang.String name)
Set the user-readable name to the one provided.
|
void |
setName2IdMap(java.util.HashMap<java.lang.String,java.lang.Integer> name2IdMap)
|
void |
setProperty2idMap(java.util.HashMap<Property,java.lang.Integer> property2idMap)
Set the
HashMap that maps the Property objects to their
respective unique integer IDs |
void |
setRegister(Register reg) |
void |
setSelected(boolean selected) |
void |
setStringProperty(java.lang.String name,
java.lang.String value,
boolean undoable)
Deprecated.
!!!This method should not be used, or should be reimplemented
first!!! It doesn't fire the callbacks at all and replaces the
Property with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value) instead. |
void |
setValue(float value)
Set the Value
Property to a new number, firing the Java callbacks
as well as CLUC callbacks afterwards. |
void |
setVisible(boolean visible) |
java.lang.String |
shortDesc()
Deprecated.
@return a short description of this GUI element.
|
void |
update() |
public static final int SLIDER
public static final int READOUT
public static final int CHECKBOX
public static final int SELECTBOX
public GUIelement()
public GUIelement(GUITab gut)
public int getModuleGUIID()
GUIelement
was initialized by a module. Otherwise,
returns -1. Each GUIelement
has 2 IDs - the one that was assigned
by this GUI application and one that was assigned by the module which
requested the creation of this GUIelement (if any). The ID, assigned by
the module is only used temporarily, to refer to the given GUI element in
the module-PC communication when initializing. Once initialized, the ID
assigned by the GUI app is used, even in the communicationpublic void setModuleGUIID(int ID)
GUIelement
was initialized by a module.ID
- the module ID to set.getModuleGUIID()
public void addProperty(Property p)
Property
for this GUIelement
. Once this
method is called, it is possible to set the value of this property and
retrieve it using the set[PropertyName] or get[PropertyName] CLUC
functions.
The registration of this property is handled by correctly adjusting the
name2IdMap
, id2NameMap
, property2idMap
and
property2idMap
HashMap
s.p
- the Property
to addpublic void addIntegerProperty(int id, java.lang.String name, int value)
id
- the ID of this new Property, which will be used to refer to it
in the CLUC code, internally.name
- the name of the new propertyvalue
- the value to initialize the property withpublic void addFloatProperty(int id, java.lang.String name, float value)
id
- the ID of this new Property, which will be used to refer to it
in the CLUC code, internally.name
- the name of the new propertyvalue
- the value to initialize the property withpublic void addStringProperty(int id, java.lang.String name, java.lang.String value)
id
- the ID of this new Property, which will be used to refer to it
in the CLUC code, internally.name
- the name of the new propertyvalue
- the value to initialize the property withpublic void setIntegerProperty(java.lang.String name, int value, boolean undoable)
Property
with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value)
instead.name
- value
- undoable
- public void setFloatProperty(java.lang.String name, float value, boolean undoable)
Property
with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value)
instead.name
- value
- undoable
- public void setStringProperty(java.lang.String name, java.lang.String value, boolean undoable)
Property
with a new one, which discards all callbacks and
negatively alters some other functionality. Use
getPropertyByName(name).setValue(value)
instead.name
- value
- undoable
- public boolean notifyAboutKeyPress(java.lang.String eventText, boolean runLiteralWhenNoMatch)
runLiteralWhenNoMatch
is false) or the input String
sequence (eventText
) will be used to simulate the key presses.eventText
- runLiteralWhenNoMatch
- public void recompileEvents()
GUIelement
, including the getters and setters of the individual
Property
objects.public boolean isWithinBounds(double x, double y)
GUIelement
. That is,
return (x > fp.x && x < fp.x + this.getWidth() && y > fp.y && y < fp.y + this.getHeight());
where fp.x and fp.y are the coordinates the GUIelement
appears
on.x
- y
- GUIelement
public float getMin()
Value
Property
can be set to.public float getMax()
Value
Property
can be set to.public java.util.HashMap<java.lang.String,java.lang.Integer> getName2IdMap()
public void setName2IdMap(java.util.HashMap<java.lang.String,java.lang.Integer> name2IdMap)
HashMap
that maps the names of Property
objects
to their IDs, which are unique for each Property
name2IdMap
- public java.util.HashMap<java.lang.Integer,java.lang.String> getId2NameMap()
public javafx.scene.paint.Color getColor1()
GUIelement
.public javafx.scene.paint.Color getColor2()
GUIelement
.public javafx.scene.paint.Color getColor3()
public javafx.scene.paint.Color getColor4()
public void setId2NameMap(java.util.HashMap<java.lang.Integer,java.lang.String> id2NameMap)
HashMap
that maps the IDs of Property
objects to
their names, which are unique for each Property
id2NameMap
- the new HashMap
public java.util.HashMap<java.lang.Integer,Property> getId2PropertyMap()
HashMap
that maps the IDs of Property
objects
to these objects themselves.public void setId2PropertyMap(java.util.HashMap<java.lang.Integer,Property> id2PropertyMap)
HashMap
that maps the IDs of Property
objects to
these objects themselves.id2PropertyMap
- the new HashMap
@Deprecated public java.util.HashMap<Property,java.lang.Integer> getProperty2idMap()
public void setProperty2idMap(java.util.HashMap<Property,java.lang.Integer> property2idMap)
HashMap
that maps the Property
objects to their
respective unique integer IDsproperty2idMap
- the new HashMap
public Property getPropertyById(int id)
Property
object, provided its unique ID. This method
is semantically equivalent with getId2PropertyMap().get(id);
public Property getPropertyByName(java.lang.String name)
Property
object, provided its unique name. This method
is semantically equivalent to
getId2PropertyMap.get(getName2IdMap.get(name));
public boolean isVisible()
public void setVisible(boolean visible)
public boolean isEnabled()
public boolean isSelected()
public void setSelected(boolean selected)
public void setRegister(Register reg)
public Register getRegister()
public final GUIPanel getGUIPanel()
public static final MappingManager getGlobalElementMappingManager()
public static MappingManager getElementTypeMappingManager()
public MappingManager getThisInstanceMappingManager()
public void setGUIPanel(GUIPanel gup)
gup
- public void addMapping(java.lang.String source, java.lang.String target)
GUIelement
. Whenever a sequence of keys that translates to the
source
is pressed, it will get treated as if the target
sequence was pressed instead. This is ensured by using
MappingManager
s internally.source
- the source String of the mappingtarget
- the target String of the mappingpublic static void addElementTypeMapping(java.lang.String source, java.lang.String target)
GUIelement
. Whenever a sequence of keys that translates to the
source
is pressed, it will get treated as if the target
sequence was pressed instead. This is ensured by using
MappingManager
s internally. TODO: isource
- the source String of the mappingtarget
- the target String of the mappingpublic static void addGlobalElementMapping(java.lang.String source, java.lang.String target)
GUIelement
s, when they
are being edited. Whenever a sequence of keys that translates to the
source
is pressed, it will get treated as if the target
sequence was pressed instead. This is ensured by using
MappingManager
s internally.source
- the source String of the mappingtarget
- the target String of the mappingpublic void setGUITab(GUITab gut)
GUITab
this GUIelement
is on to the
one provided.gut
- public Menu getMenu()
Menu
, which will get displayed whenever this
GUIelement
is being edited.public void setMenu(Menu m)
Menu
, which will get displayed whenever this
GUIelement
is being edited.public void setEnabled(boolean enabled)
public boolean isFocused()
GUIelement
is focusedpublic void setFocused(boolean focused)
GUIelement
public FloatPoint getLastPositionDrawnTo()
GUIelement
was drawn
(the upper left point). The position is expressed in pixels, relatively
to the GUIPanel.canvasPane
it's being drawn to. The coordinate
system is consistent with JavaFX (left to right, down to up).public java.lang.String shortDesc()
public void requestRepaint()
GUITab
this GUIelement
is placed on and request
it to repaint it sometime later. If this GUIelement
has been
repainted recently (later than 30ms ago), do nothing (to prevent
excessive redrawing, which would be resource-heavy). This method uses the Platform.runLater(java.lang.Runnable)
Method, so it can be considered thread-safe. (TODO: can it tho?) It is
the preferred method for refreshing an element.public void paint(javafx.scene.canvas.GraphicsContext gc, double x, double y)
GUIelement
on some place on the
GraphicsContext
provided, on position, determined by the x and y
arguments.gc
- the GraphicsContext
to draw tox
- the x position to draw toy
- the y position to draw topublic void setValue(float value)
Property
to a new number, firing the Java callbacks
as well as CLUC callbacks afterwards. Said callbacks might modify this
number, so subsequent call to getValue
may not yield a number
identical to the one just set.value
- the number to set the Value Property to.public float getValue()
Property
, firing the Java
callbacks as well as CLUC callbacks beforehand. Said callbacks might
modify this number, so this call to getValue
may not yield a
number identical to the one just set by the setValue
method.public int getHeight()
public int getWidth()
public java.lang.String getName()
getUniqueName()
public java.lang.String getUniqueName()
public java.lang.String getContextDependantName()
getName
,
or the UniqueName (same as calling getUniqueName
). Which one of
those it is depends on the current settings
(GUIPanel.showUniqueNames()
).GUIPanel.showUniqueNames()
.public java.lang.String getTags()
public void removeAllTags()
GUIelement
getTags()
public void addTags(java.lang.String t)
t
- the string, containing the tags to addpublic void removeTags(java.lang.String t)
t
- the string, representing the tags, which should be removed.public boolean hasTag(java.lang.String t)
t
- the string containing the possible tagspublic java.lang.String getGUIelementName()
GUIelement
.public void recalculateUniqueName(GUITab gt)
gt
- the current GUITab
getUniqueName()
,
getName()
public GUIelement makeCopy()
GUIelement
. All Property
objects are also duplicated. The callbacks are not preserved.copyPropertiesTo(InstrumentationPlatformGUI.Elements.GUIelement)
public void copyPropertiesTo(GUIelement ge)
Property
objects of this GUIelement
to the
GUIelement
provided. This works by iterating through the
properthies in this GUIelement
, finding matching ones by name in
the target GUIelement
and then transfering the values between the
matching ones, using the Property.setValue(value,true,false)
calls. This means that Property
objects that the source
GUIelement
has, but the target lacks will not be transfered. Java
callbacks are fired during this operation; CLUC callbacks are surpressed.ge
- public void setName(java.lang.String name)
name
- the new user-readable namepublic void update()
public boolean isDeleted()
public void setDeleted(boolean deleted)
deleted
- whether or not the element has been deleted and not placed on any tab again yet.