|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--y.view.Graph2DView
This is a powerful component to view graphs in 2-dimensional space.
It displays a Graph2D
object. The same Graph2D object can be
displayed at different zoom levels in different views.
Features of this component include
Field Summary | |
static byte |
BG_LAYER
Background layer constant. |
static byte |
FG_LAYER
Foreground layer constant. |
static int |
LAYER_MODE
Drawing mode constant. |
static int |
MOVE_SELECTION_MODE
Drawing mode constant. |
static int |
NORMAL_MODE
Drawing mode constant. |
static int |
SELECTION_BOX_MODE
Drawing mode constant. |
static int |
UNBUFFERED_MODE
Drawing mode constant. |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface y.view.View2DConstants |
GRID_CROSS, GRID_LINES, GRID_NONE, GRID_POINTS |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Graph2DView()
Creates a new Graph2DView containing an empty graph. |
|
Graph2DView(Graph2D graph)
Creates a new Graph2DView for a given graph. |
|
Graph2DView(Graph2D graph,
ViewControl vc)
Creates a new Graph2DView for a given graph and viewcontrol. |
Method Summary | |
void |
addBackgroundDrawable(Drawable d)
Adds a background drawable to this view. |
void |
addDrawable(Drawable d)
Adds a drawable to this view. |
void |
addViewChangeListener(ViewChangeListener l)
View can not change, so this method does nothing |
void |
addViewMode(ViewMode vm)
Adds a view mode to this Graph2DView. |
boolean |
adjustScrollBarVisibility()
Updates scrollbar visibility and adjustment for this view . |
void |
animationPerformed(AnimationEvent e)
AnimationListener implementation. |
void |
fitContent()
Fits the contents inside this view. |
void |
fitRectangle(Rectangle r)
Fits the given rectangle inside this view. |
void |
fitWorldRect()
Set the size and offset of the displayed document's world rectangle to the size and offset of this view. |
void |
focusView(double newZoom,
Point2D newCenter,
boolean animated)
|
BackgroundRenderer |
getBackgroundRenderer()
Returns the current BackgroundRenderer of this view. |
JComponent |
getCanvasComponent()
Returns the component that displays the contents of this view. |
Dimension |
getCanvasSize()
Returns the size of the canvas part of this component. |
Point2D |
getCenter()
Returns the world coordinate that is displayed in the center of this view. |
Component |
getComponent()
Returns this. |
View |
getCurrentView()
Returns this View. |
boolean |
getFitContentOnResize()
Whether or not the fitContentOnResize feature
is enabled. |
Frame |
getFrame()
Returns the frame this components belongs to. |
Graph2D |
getGraph2D()
Returns the graph that this view displays. |
Graph2DRenderer |
getGraph2DRenderer()
Returns the renderer used to render the bound Graph2D. |
Color |
getGridColor()
Returns the currently set grid color |
boolean |
getGridMode()
Asks if grid is on or off on the view. |
double |
getGridResolution()
Get resolution of grid. |
int |
getGridType()
Get type of grid. |
int |
getHorizontalScrollBarPolicy()
Returns the scroll bar policy for the horizontal scroll bar. |
Image |
getImage()
Deprecated. use Graph2DView.paintVisibleContent(Graphics2D) with a
graphics context of an appropriate image type instead. |
double |
getPaintDetailThreshold()
Returns the scale threshold after that less detailed versions of the graph are displayed |
int |
getVerticalScrollBarPolicy()
Returns the scroll bar policy for the vertical scroll bar. |
void |
getVerticalScrollBarPolicy(int policy)
Sets the scroll bar policy for the vertical scroll bar. |
ViewControl |
getViewControl()
Returns the view control of this view. |
Cursor |
getViewCursor()
Returns the cursor that is displayed when the mouse is over this view. |
Point |
getViewPoint()
Returns the world coordinate this view displays at its the upper left corner. |
Point2D |
getViewPoint2D()
Returns the world coordinate this view displays at its the upper left corner. |
Dimension |
getViewSize()
Returns the size of the drawing canvas. |
Rectangle |
getVisibleRect()
Returns the visible part of the world rectangle. |
Rectangle |
getWorldRect()
Returns the world rectangle defined for this view. |
double |
getZoom()
Returns the current zoom level of this view. |
void |
gridCursorActive(boolean active)
Activates/Deactivates the grid cursor. |
boolean |
isAntialiasedPainting()
Getter for property antialiasedPainting. |
boolean |
isFocusTraversable()
|
boolean |
isGridVisible()
Asks if grid is visible in the view. |
boolean |
isValidateRoot()
Returns true . |
void |
openLabelEditor(YLabel label,
double x,
double y)
Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener) .
|
void |
openLabelEditor(YLabel label,
double x,
double y,
PropertyChangeListener listener)
Same as Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean)
but uses single-line mode by default. |
void |
openLabelEditor(YLabel label,
double x,
double y,
PropertyChangeListener listener,
boolean useSingleLineMode)
Opens a label editor for the given label at world coordinate (x,y) .
|
void |
paintVisibleContent(Graphics2D gfx)
Paints the visible part of this view's content on the given graphics context. |
void |
print(Graphics g)
Prints the currently displayed contents of this view to the given graphics context. |
void |
registerKeyboardAction(ActionListener anAction,
KeyStroke aKeyStroke,
int aCondition)
Registers a keyboard action for this view. |
void |
registerKeyboardAction(ActionListener anAction,
String aCommand,
KeyStroke aKeyStroke,
int aCondition)
Registers a keyboard action for this view. |
void |
removeBackgroundDrawable(Drawable d)
Removes a background drawable from this view. |
void |
removeDrawable(Drawable d)
Removes a drawable from this view. |
void |
removeViewMode(ViewMode vm)
Remove a view mode from this Graph2DView. |
void |
requestFocus()
|
void |
setAntialiasedPainting(boolean antialiasedPainting)
Setter for property antialiasedPainting. |
void |
setBackgroundRenderer(BackgroundRenderer renderer)
Sets the BackgroundRenderer of this view. |
void |
setBounds(int x,
int y,
int w,
int h)
Sets the bounds of this component. |
void |
setCenter(double x,
double y)
Sets the world coordinate that should be displayed in the center of this view. |
void |
setDrawingMode(int mode)
Sets the drawing mode for this view. |
void |
setFitContentOnResize(boolean b)
Specifies whether or not to fit the content inside the view automatically whenever this component changes it's size. |
void |
setGraph2D(Graph2D graph)
Sets the graph that this view displays. |
void |
setGraph2DRenderer(Graph2DRenderer renderer)
Sets the renderer used to render the bound Graph2D. |
void |
setGridColor(Color color)
Sets the color of the grid By default the grid is painted in gray. |
void |
setGridCursorPosition(double x,
double y)
Sets the position of the gridcursor. |
void |
setGridMode(boolean b)
Turns grid on or off on the view. |
void |
setGridResolution(double res)
Sets resolution of the grid. |
void |
setGridType(int type)
Sets type of the grid. |
void |
setGridVisible(boolean b)
Turns grid's visibility on or off on the view. |
void |
setHorizontalScrollBarPolicy(int policy)
Sets the scroll bar policy for the horizontal scroll bar. |
void |
setPaintDetailThreshold(double thresh)
Sets the scale threshold after that less detailed versions of the graphs are displayed. |
void |
setScrollBarPolicy(int vsbp,
int hsbp)
Sets the scroll bar policy for the scroll bars. |
void |
setSecureDrawingMode(boolean b)
If set to true , all drawing optimizations will be
disabled. |
void |
setSelectionBoxBounds(Rectangle r)
Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE .
|
void |
setSelectionBoxBounds2D(Rectangle2D r)
Sets the bounds of the selection box beeing displayed while in SELECTION_BOX_MODE .
|
void |
setToolTipText(String text)
Sets the tool tip text. this method can be used in a view mode to show tip texts to show context sensitive tips over nodes, etc. |
void |
setViewControl(ViewControl vc)
Sets the view control for this view. |
void |
setViewCursor(Cursor c)
Sets the cursor that is displayed when the mouse is over this view. |
void |
setViewPoint(int x,
int y)
Sets the world coordinate that is being displayed at the upper left corner of this view. |
void |
setViewPoint2D(double x,
double y)
Sets the world coordinate that is being displayed at the upper left corner of this view. |
void |
setWorldRect(int x,
int y,
int w,
int h)
Sets the bounds of the world rectangle. |
void |
setZoom(double zoom)
Sets the current zoom level that will be used to display the contents. |
void |
showPopup(JPopupMenu popup,
double x,
double y)
Displays the given popup menu at world coordinate (x,y) . |
int |
toViewCoordX(double x)
Transforms a x world-coordinate to a y view-coordinate. |
int |
toViewCoordY(double y)
Transforms a y world-coordinate to a y view-coordinate. |
double |
toWorldCoordX(int x)
Transforms a x view-coordinate to a y world-coordinate. |
double |
toWorldCoordY(int y)
Transforms a y view-coordinate to a y world-coordinate. |
void |
unregisterKeyboardAction(KeyStroke aKeyStroke)
Unregisters a keyboard action for this view. |
void |
updateView()
Forces this view to repaint its contents. |
void |
updateWorldRect()
Updates the current world rectangle. |
void |
zoomToArea(double x,
double y,
double width,
double height)
Adjusts the zoom level and view point of this view such that the given bounds are visible in this view. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NORMAL_MODE
public static final int MOVE_SELECTION_MODE
public static final int SELECTION_BOX_MODE
public static final int LAYER_MODE
public static final int UNBUFFERED_MODE
public static final byte FG_LAYER
public static final byte BG_LAYER
Constructor Detail |
public Graph2DView()
public Graph2DView(Graph2D graph)
graph
- The graph which should be displayedpublic Graph2DView(Graph2D graph, ViewControl vc)
graph
- The graph which should be displayedvc
- The viewcontrol for this ViewMethod Detail |
public void fitWorldRect()
public void setFitContentOnResize(boolean b)
public boolean getFitContentOnResize()
fitContentOnResize
feature
is enabled.
Graph2DView.setFitContentOnResize(boolean b)
public void setBounds(int x, int y, int w, int h)
setBounds
in class Component
public void setViewControl(ViewControl vc)
public ViewControl getViewControl()
getViewControl
in interface ViewContainer
public int getHorizontalScrollBarPolicy()
public int getVerticalScrollBarPolicy()
public void setHorizontalScrollBarPolicy(int policy)
public void getVerticalScrollBarPolicy(int policy)
public void setScrollBarPolicy(int vsbp, int hsbp)
vsbp
- policy for the vertical scroll barhsbp
- policy for the horizontal scroll bar
Policy constants as defined in javax.swing.JScrollPaneConstants
may be used.public boolean adjustScrollBarVisibility()
public boolean isValidateRoot()
true
.
isValidateRoot
in class JComponent
public void addViewMode(ViewMode vm)
vm
- A ViewModepublic void removeViewMode(ViewMode vm)
vm
- A ViewMode which hab been added to this view.public void setGridMode(boolean b)
public void setGridVisible(boolean b)
public boolean getGridMode()
public boolean isGridVisible()
public void setGridResolution(double res)
res
- A positive numberpublic double getGridResolution()
public void setGridType(int type)
View2DConstants
.
type
- Type of the gridpublic int getGridType()
View2DConstants
public void setGridColor(Color color)
color
- the color of the gridpublic Color getGridColor()
Graph2DView.setGridColor(Color)
public void setGridCursorPosition(double x, double y)
public void gridCursorActive(boolean active)
public void setWorldRect(int x, int y, int w, int h)
public Rectangle getWorldRect()
public JComponent getCanvasComponent()
public Image getImage()
Graph2DView.paintVisibleContent(Graphics2D)
with a
graphics context of an appropriate image type instead.
public void fitContent()
public void fitRectangle(Rectangle r)
By calling this method the view port is adjusted in such a way that the given rectangular area is visible.
public Dimension getCanvasSize()
public void paintVisibleContent(Graphics2D gfx)
public void setCenter(double x, double y)
public Point2D getCenter()
public Dimension getViewSize()
public void updateView()
Note that invoking repaint
on this component
does not necessarily display the current contents.
updateView
in interface View
public void updateWorldRect()
public double getZoom()
public void setZoom(double zoom)
By default the zoom level is 1.0
public void zoomToArea(double x, double y, double width, double height)
public void setViewCursor(Cursor c)
public Cursor getViewCursor()
public Graph2D getGraph2D()
getGraph2D
in interface View
public void setGraph2D(Graph2D graph)
public void setDrawingMode(int mode)
By default NORMAL_MODE
is active.
Graph2DView.NORMAL_MODE
,
Graph2DView.MOVE_SELECTION_MODE
,
Graph2DView.SELECTION_BOX_MODE
,
Graph2DView.LAYER_MODE
,
Graph2DView.UNBUFFERED_MODE
public void setSelectionBoxBounds(Rectangle r)
SELECTION_BOX_MODE
.
The given rectangle is interpreted in world coordinates.
public void setSelectionBoxBounds2D(Rectangle2D r)
SELECTION_BOX_MODE
.
The given rectangle is interpreted in world coordinates.
public void showPopup(JPopupMenu popup, double x, double y)
(x,y)
.
public Frame getFrame()
null
is returned.
getFrame
in interface View
public void openLabelEditor(YLabel label, double x, double y)
Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener)
.
Uses no PropertyChangeListener by default.
public void openLabelEditor(YLabel label, double x, double y, PropertyChangeListener listener)
Graph2DView.openLabelEditor(YLabel,double,double,PropertyChangeListener,boolean)
but uses single-line mode by default.
public void openLabelEditor(YLabel label, double x, double y, PropertyChangeListener listener, boolean useSingleLineMode)
(x,y)
.
To open the label editor at the location were the given label currently resides use
(label.getBox.getX(), label.getBox().getY())
as coordinates.
Additionally a PropertyChangeListener can be provided
that gets informed after the label text has been changed.
To use no PCL one should pass null
as an argument.
The last argument specifies whether the the label editor should work in single-line or in multi-line mode. In single-line mode pressing the "Enter" key terminates the input and "Ctrl-Enter" adds a newline to the label. In multi-line mode the behaviour is the other way around. In both modes the editor can be canceled by hitting the "Escape" key.
public Component getComponent()
getComponent
in interface View
public Rectangle getVisibleRect()
getVisibleRect
in class JComponent
public void print(Graphics g)
print
in class JComponent
public void setViewPoint(int x, int y)
public void setViewPoint2D(double x, double y)
public Point getViewPoint()
public Point2D getViewPoint2D()
public void setSecureDrawingMode(boolean b)
true
, all drawing optimizations will be
disabled.
public View getCurrentView()
getCurrentView
in interface ViewContainer
public void addViewChangeListener(ViewChangeListener l)
addViewChangeListener
in interface ViewContainer
public void addDrawable(Drawable d)
d
- A drawablepublic void removeDrawable(Drawable d)
d
- A drawablepublic void addBackgroundDrawable(Drawable d)
d
- A drawablepublic void removeBackgroundDrawable(Drawable d)
d
- A drawablepublic Graph2DRenderer getGraph2DRenderer()
DefaultGraph2DRenderer
is used as Renderer of this view.
public void setGraph2DRenderer(Graph2DRenderer renderer)
public void setPaintDetailThreshold(double thresh)
The default value is 0.3
public double getPaintDetailThreshold()
Graph2DView.setPaintDetailThreshold(double)
public int toViewCoordX(double x)
public int toViewCoordY(double y)
public double toWorldCoordX(int x)
public double toWorldCoordY(int y)
public void setBackgroundRenderer(BackgroundRenderer renderer)
public BackgroundRenderer getBackgroundRenderer()
public void animationPerformed(AnimationEvent e)
animationPerformed
in interface AnimationListener
public boolean isFocusTraversable()
isFocusTraversable
in class Component
public void setToolTipText(String text)
setToolTipText
in class JComponent
public void focusView(double newZoom, Point2D newCenter, boolean animated)
public boolean isAntialiasedPainting()
public void setAntialiasedPainting(boolean antialiasedPainting)
antialiasedPainting
- New value of property antialiasedPainting.public void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition)
registerKeyboardAction
in class JComponent
public void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)
registerKeyboardAction
in class JComponent
public void unregisterKeyboardAction(KeyStroke aKeyStroke)
unregisterKeyboardAction
in class JComponent
public void requestFocus()
requestFocus
in class JComponent
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |