public class JViewer extends Object implements CommandListener, ChangeListener, PropertyListener
Modifier and Type | Class and Description |
---|---|
static class |
JViewer.AccelerationFunctionExp
The
JViewer.AccelerationFunctionExp class implements the following function in
[0:JViewer.AccelerationFunctionExp.ZERO_AT ]:
5.0 * Math.exp(-x / 15.0) - 3.0
Two methods are provided:
JViewer.AccelerationFunctionExp.of(double) : computes the function;
JViewer.AccelerationFunctionExp.inverseOf(double) : computes the inverse of the function. |
protected static class |
JViewer.BarType |
Modifier and Type | Field and Description |
---|---|
protected JTopology |
jtp |
protected JSlider |
slideBar |
protected JViewer.BarType |
slideBarType |
protected TopologySerializerFilenameMatcher |
topologySerializerFilenameMatcher |
protected JFrame |
window |
Constructor and Description |
---|
JViewer(JTopology jtopo)
Creates a windowed viewer encapsulating the specified jtopology.
|
JViewer(JTopology jtopo,
boolean windowed)
Creates a viewer encapsulating the specified jtopology.
|
JViewer(Topology topo)
Creates a windowed viewer for the specified topology.
|
JViewer(Topology topo,
boolean selfContained)
Creates a viewer for the specified topology.
|
Modifier and Type | Method and Description |
---|---|
void |
addSlideBar(JViewer.BarType type,
int value)
Adds a slide bar at the top of the topology.
|
void |
addTopologySerializer(String regexp,
TopologySerializer topologySerializer)
Records and links the provided
TopologySerializer to a specific regular expression. |
protected static double |
computeClockSpeed(double maxValue,
double value) |
protected static double |
computeSliderPosition(double maxValue,
double value) |
JTopology |
getJTopology()
Returns the jtopology attached to this viewer.
|
void |
onCommand(String command)
Provides a way to react upon command selection.
|
void |
onPropertyChanged(Properties o,
String p)
Notifies that a property of this object has changed.
|
void |
removeSlideBar()
Removes the slide bar, if any.
|
void |
setSize(int width,
int height)
Sets the size of the inner jtopology to the specified dimension.
|
void |
setTitle(String title)
Sets the title of the corresponding window
|
void |
stateChanged(ChangeEvent e) |
protected JTopology jtp
protected JSlider slideBar
protected TopologySerializerFilenameMatcher topologySerializerFilenameMatcher
protected JViewer.BarType slideBarType
protected JFrame window
public JViewer(Topology topo)
topo
- The topology to be drawn and/or manipulated.public JViewer(Topology topo, boolean selfContained)
selfContained
is true
, a new window will be created to contain the viewer
(similarly to JViewer(Topology)
). If it is false
,
no window will be created and the viewer can be subsequently
integrated to another swing container (e.g. another JFrame
or a JApplet
).topo
- The topology to be drawn and/or manipulated.selfContained
- Set this to false to avoid creating a JFrame
(e.g. for embedding the JViewer in your own frame).public JViewer(JTopology jtopo)
jtopo
- The jtopology to be encapsulated.public JViewer(JTopology jtopo, boolean windowed)
selfContained
is true
, a new window will be created
to contain the viewer (similarly to JViewer(Topology)
). If it
is false
, no window will be created and the viewer can be
subsequently integrated to another swing container (e.g. another
JFrame
or a JApplet
).jtopo
- The JTopology to be encapsulated.windowed
- Set this to false to avoid creating a JFrame
(e.g. for embedding the JViewer in your own frame).public JTopology getJTopology()
public void setSize(int width, int height)
width
- The desired width, in pixels.height
- The desired height, in pixels.public void setTitle(String title)
title
- the new title, as a String
.public void addSlideBar(JViewer.BarType type, int value)
type
- the JViewer.BarType
to add.value
- the value for the slide bar, as an integer.public void removeSlideBar()
public void onCommand(String command)
CommandListener
onCommand
in interface CommandListener
command
- the command which has risen.public void addTopologySerializer(String regexp, TopologySerializer topologySerializer)
Records and links the provided TopologySerializer
to a specific regular expression.
This couple will be used during Topology
import/export. If the file's name matches the provided regular
expression, the linked TopologySerializer
will be used for (de)serialization.
regexp
- a regular expression matching the file namestopologySerializer
- the TopologySerializer
to be recordedpublic void onPropertyChanged(Properties o, String p)
PropertyListener
onPropertyChanged
in interface PropertyListener
o
- The object.p
- The name of the changed property.public void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
protected static double computeClockSpeed(double maxValue, double value)
protected static double computeSliderPosition(double maxValue, double value)