|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbibliothek.gui.dock.dockable.AbstractDockable
bibliothek.gui.dock.station.AbstractDockableStation
bibliothek.gui.dock.StackDockStation
public class StackDockStation
On this station, only one of many children is visible. The other children
are hidden behind the visible child. There are some buttons where the
user can choose which child is visible. This station behaves like
a JTabbedPane
.
This station tries to register a DockTitleFactory
to its
DockController
with the key TITLE_ID
.
Nested Class Summary | |
---|---|
protected class |
StackDockStation.Background
This panel is used as base of the station. |
Field Summary | |
---|---|
static PropertyKey<StackDockComponentFactory> |
COMPONENT_FACTORY
Key used to read the current StackDockComponentFactory |
static String |
TITLE_ID
The id of the titlefactory which is used by this station |
Fields inherited from class bibliothek.gui.dock.station.AbstractDockableStation |
---|
listeners |
Constructor Summary | |
---|---|
|
StackDockStation()
Constructs a new StackDockStation |
|
StackDockStation(DockTheme theme)
Constructs a new station and sets the theme. |
protected |
StackDockStation(DockTheme theme,
boolean init)
Creates a new station. |
Method Summary | ||
---|---|---|
void |
add(Dockable dockable,
int index)
Adds a child to this station at the location index . |
|
protected void |
add(Dockable dockable,
int index,
boolean fire)
Adds a child to this station at the location index . |
|
void |
addMouseInputListener(MouseInputListener listener)
Adds a MouseInputListener to the component of this Dockable. |
|
protected void |
callDockUiUpdateTheme()
Calls the method DockUI .DockUI.updateTheme(DockStation, DockFactory)
with this as the first argument, and an appropriate factory
as the second argument. |
|
boolean |
canDrag(Dockable dockable)
Tells whether dockable can be removed from this station or not. |
|
boolean |
canReplace(Dockable old,
Dockable next)
Tells whether its possible to replace the child old
with next where next is not a child of this station. |
|
protected StackDockStation.Background |
createBackground()
Creates the panel onto which this station will lay its children. |
|
protected StackDockComponent |
createStackDockComponent()
Creates the StackDockComponent which will be shown on
this station if the station has more then one child.This method is called directly by the constructor. |
|
void |
drag(Dockable dockable)
Removes a child from this station. |
|
void |
draw()
Informs this station that the information gathered by prepareDrop or
prepareMove should
be painted somehow onto this station.The station should use the StationPaint of its theme
to draw. |
|
void |
drop()
Adds the Dockable of the last run of
prepareDrop to this station. |
|
void |
drop(Dockable dockable)
Adds dockable to this station. |
|
boolean |
drop(Dockable dockable,
DockableProperty property)
Tries to add dockable to this station such that the location
given by property is matched. |
|
boolean |
drop(Dockable dockable,
StackDockProperty property)
Adds a new child to this station, and tries to match the property
as good as possible. |
|
protected bibliothek.gui.dock.StackDockStation.Insert |
exactTabIndexAt(int x,
int y)
Gets the gap which is selected when the mouse is at x/y. |
|
void |
forget()
Tells this station that a possible drop or move on this station was canceled. |
|
Component |
getComponent()
Gets the Component which represents this Dockable. |
|
DisplayerFactoryWrapper |
getDisplayerFactory()
Gets a DisplayerFactory which is used to create new
DockableDisplayer for this station. |
|
DisplayerCollection |
getDisplayers()
Gets the set of displayers used on this station. |
|
Dockable |
getDockable(int index)
Gets the index'th child of this station. |
|
int |
getDockableCount()
Gets the number of children. |
|
DockableProperty |
getDockableProperty(Dockable dockable)
Gets precise information about the location of a child of this station. |
|
String |
getFactoryID()
Gets the unique name of the DockFactory which can read
and write elements of this type. |
|
Dockable |
getFrontDockable()
Gets the favorite child of this station. |
|
StationPaintWrapper |
getPaint()
Gets a StationPaint which is used to paint some lines onto
this station. |
|
StackDockComponent |
getStackComponent()
Gets the currently used StackDockComponent |
|
StackDockComponentFactory |
getStackComponentFactory()
Gets the factory which is used to create a StackDockComponent . |
|
int |
indexOf(Dockable dockable)
Gets the index of a child. |
|
protected void |
init()
Initializes the fields of this object, has to be called exactly once. |
|
protected void |
insertionLine(Rectangle left,
Rectangle right,
Point a,
Point b,
boolean leftImportant)
When dropping or moving a Dockable , a line has to be painted
between two tabs. |
|
|
isInOverrideZone(int x,
int y,
D invoker,
Dockable drop)
If the controller asks a station if a child could be dropped or moved, the controller assumes that no other station has interest in this event. |
|
boolean |
isStationVisible()
Tells whether this station is visible or not. |
|
boolean |
isVisible(Dockable dockable)
Tells whether the child dockable is visible or not. |
|
void |
move()
Moves a child of this station to a new location according to the information gathered by prepareMove . |
|
void |
move(Dockable dockable,
DockableProperty property)
Tries to move the child dockable in such a way, that
DockStation.getDockableProperty(Dockable) would return a
DockableProperty that equals property .There is no need to give a guarantee that the move successes, and clients should always be prepared for the possibility that this DockStation
does nothing at all. |
|
boolean |
prepareDrop(int x,
int y,
int titleX,
int titleY,
boolean checkOverrideZone,
Dockable dockable)
Prepares this station to get the new child dockable . |
|
boolean |
prepareMove(int x,
int y,
int titleX,
int titleY,
boolean checkOverrideZone,
Dockable dockable)
Prepares the station that one of its children is moved from one location to another location. |
|
void |
remove(int index)
Removes the child of location index . |
|
void |
removeMouseInputListener(MouseInputListener listener)
Removes a listener that was earlier added to this Dockable. |
|
void |
replace(Dockable old,
Dockable next)
Replaces the child old by next which is
not yet a child of this station. |
|
void |
setController(DockController controller)
Sets the controller in whose realm this Dockable is. |
|
void |
setDockParent(DockStation station)
Sets the parent property. |
|
void |
setFrontDockable(Dockable dockable)
Sets the most important child. |
|
void |
setStackComponent(StackDockComponent stackComponent)
Sets the StackDockComponent which should be used by this
station. |
|
void |
setStackComponentFactory(StackDockComponentFactory factory)
Sets the factory which will be used to create a StackDockComponent
for this station. |
|
protected bibliothek.gui.dock.StackDockStation.Insert |
tabIndexAt(int x,
int y)
Tells which gap (between tabs) is chosen if the mouse has the coordinates x/y. |
Methods inherited from class bibliothek.gui.dock.station.AbstractDockableStation |
---|
accept, addDockStationListener, asDockStation, canCompare, changed, compare, getDirectActionOffers, getDockTitle, getIndirectActionOffers, getStationBounds, getTheme, removeDockStationListener, updateTheme |
Methods inherited from class bibliothek.gui.dock.dockable.AbstractDockable |
---|
accept, accept, addDockableListener, addDockHierarchyListener, asDockable, bind, fireTitleBound, fireTitleIconChanged, fireTitleTextChanged, fireTitleUnbound, getController, getDockParent, getGlobalActionOffers, getLocalActionOffers, getTitleIcon, getTitleText, listBoundTitles, removeDockableListener, removeDockHierarchyListener, setActionOffers, setTitleIcon, setTitleText, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface bibliothek.gui.DockStation |
---|
getController |
Methods inherited from interface bibliothek.gui.dock.DockElement |
---|
asDockable |
Field Detail |
---|
public static final String TITLE_ID
public static final PropertyKey<StackDockComponentFactory> COMPONENT_FACTORY
StackDockComponentFactory
Constructor Detail |
---|
public StackDockStation()
public StackDockStation(DockTheme theme)
theme
- the theme of the station, may be null
protected StackDockStation(DockTheme theme, boolean init)
theme
- the theme of this station, can be null
init
- true
if the fields of this object should
be initialized, false
otherwise. If false
,
then the subclass has to call init()
exactly once.Method Detail |
---|
protected void init()
protected StackDockStation.Background createBackground()
protected StackDockComponent createStackDockComponent()
StackDockComponent
which will be shown on
this station if the station has more then one child.
public void setStackComponent(StackDockComponent stackComponent)
StackDockComponent
which should be used by this
station. The component is shown when this station has more then
one child. Note that the stackComponent
depends also
on the property COMPONENT_FACTORY
, and will be automatically
exchanged if that property changes. Clients should use
setStackComponentFactory(StackDockComponentFactory)
if they
want to exchange the component permanently.
stackComponent
- the new component
IllegalArgumentException
- if stackComponent
is null
public StackDockComponent getStackComponent()
StackDockComponent
setStackComponent(StackDockComponent)
public void setStackComponentFactory(StackDockComponentFactory factory)
StackDockComponent
for this station.
factory
- the new factory, can be null
if the default-factory
should be usedpublic StackDockComponentFactory getStackComponentFactory()
StackDockComponent
.
This method returns null
if no factory was set through
setStackComponentFactory(StackDockComponentFactory)
.
null
protected void callDockUiUpdateTheme() throws IOException
AbstractDockableStation
DockUI
.DockUI.updateTheme(DockStation, DockFactory)
with this
as the first argument, and an appropriate factory
as the second argument.
callDockUiUpdateTheme
in class AbstractDockableStation
IOException
- if the DockUI throws an exceptionpublic void setDockParent(DockStation station)
Dockable
station
.DockHierarchyEvent
.DockHierarchyObserver
, invoke
DockHierarchyObserver.update()
after the
property has changed, and do not fire a DockHierarchyEvent
here.
setDockParent
in interface Dockable
setDockParent
in class AbstractDockable
station
- the parent, may be null
if this
Dockable is not visible at all.public void setController(DockController controller)
Dockable
null
means that this Dockable
is not managed by a controller.DockHierarchyListener
s about the change.DockHierarchyObserver
, invoke
DockHierarchyObserver.controllerChanged(DockController)
setController
in interface Dockable
setController
in interface DockStation
setController
in class AbstractDockable
controller
- the owner, may be null
public StationPaintWrapper getPaint()
StationPaint
which is used to paint some lines onto
this station. Use a delegate
to exchange the paint.
public DisplayerFactoryWrapper getDisplayerFactory()
DisplayerFactory
which is used to create new
DockableDisplayer
for this station. Use a
delegate
to exchange the factory.
public DisplayerCollection getDisplayers()
displayers
used on this station.
public boolean isStationVisible()
DockStation
JFrame
is not visible if the frame is minimized.
isStationVisible
in interface DockStation
isStationVisible
in class AbstractDockableStation
public boolean isVisible(Dockable dockable)
DockStation
dockable
is visible or not. Visible
means that the component
of dockable
can be seen by the user. The result must be false
if
this station is not visible.
isVisible
in interface DockStation
isVisible
in class AbstractDockableStation
dockable
- the child whose visibility-state is questioned
dockable
is visible or notDockStation.isStationVisible()
public int getDockableCount()
DockStation
public Dockable getDockable(int index)
DockStation
index
- a value between 0 (incl.) and DockStation.getDockableCount()
(excl.).
public DockableProperty getDockableProperty(Dockable dockable)
DockStation
DockStation.drop(Dockable, DockableProperty)
.
dockable
- the child whose location is demanded
DockUtilities.getPropertyChain(DockStation, Dockable)
public Dockable getFrontDockable()
DockStation
null
indicates that there are no children
at all, or that there is no favorite child (all children are equal important).DockController.setFocusedDockable(Dockable, boolean)
which will then call DockStation.setFrontDockable(Dockable)
. Note that the
DockController itself listens to the DockTitles, and maybe the station
doesn't need a logic to decide which child is important.
null
public void setFrontDockable(Dockable dockable)
DockStation
DockStation.getFrontDockable()
how stations can change
this property.
dockable
- the new favorite child, can be null
DockStation.getFrontDockable()
public int indexOf(Dockable dockable)
dockable
- the child which is searched
dockable
or -1 if it was not foundpublic boolean prepareDrop(int x, int y, int titleX, int titleY, boolean checkOverrideZone, Dockable dockable)
DockStation
dockable
. The
station has to store a possible location of the child, and should draw
some indicators where the child will be put. The station can refuse
dockable
, in this case nothing has to be painted, and
this method returns false
.false
if this station is dockable,
checkOverrideZone
is true
and the mouse is in
the override-zone
of the parent. However, that condition is just "good manners" and may
be broken.DockStation.accept(Dockable)
and Dockable.accept(DockStation)
or Dockable.accept(DockStation, Dockable)
to ensure that the desired
drop-location is valid.DockAcceptance
of its controller
(see DockController.getAcceptance()
) to ensure that the drop/location is valid.mouseX/mouseY
is the location
of the mouse, titleX/titleY
is the location of the dragged
title. The second point may be interesting if the title of a dropped
child should have the same coordinates as the image of the dragged title.dockable
is a child of this
station. In such a case prepareMove
is invoked.
x
- the x-coordinate of the mouse on the screeny
- the y-coordinate of the mouse on the screentitleX
- the x-location of the dragged title or mouseX
if no
title is draggedtitleY
- the y-location of the dragged title or mouseY
if no
title is draggedcheckOverrideZone
- whether this station has to check if the mouse
is in the override-zone of its parentdockable
- the element which will be dropped
true
if dockable
can be added at the
current location, false
otherwise.public void drop()
DockStation
Dockable
of the last run of
prepareDrop
to this station.
This method is only called if the new child and this station accepted
each other, prepareDrop
returned true
and
the new child is not yet a child of this station.
public void drop(Dockable dockable)
DockStation
dockable
to this station. The station can decide
by its own where to put dockable
.
dockable
- a new childpublic boolean drop(Dockable dockable, DockableProperty property)
DockStation
dockable
to this station such that the location
given by property
is matched. If property
has a successor
and points to
another station, just call the drop
-method of this
child-station. Note that property
can be of any type and
contain invalid information.
dockable
- the new childproperty
- the location of the child, may be invalid data
true
if property
could be read
and dockable
was dropped, false
otherwise.public boolean drop(Dockable dockable, StackDockProperty property)
property
as good as possible.
dockable
- the new childproperty
- the preferred location of the child
true
if the child could be added, false
if the child couldn't be addedpublic boolean prepareMove(int x, int y, int titleX, int titleY, boolean checkOverrideZone, Dockable dockable)
DockStation
prepareDrop
for detailed information about the behavior of this method. The only
difference between this method and prepareDrop
is, that
dockable
is a child of this station.
x
- the x-coordinate of the mouse on the screeny
- the y-coordinate of the mouse on the screentitleX
- the x-location of the dragged title or mouseX
if no
title is draggedtitleY
- the y-location of the dragged title or mouseY
if no
title is draggedcheckOverrideZone
- whether this station has to check if the
mouse is in the override-zone of its parentdockable
- the element which will be moved
true
if dockable
can be added at the
current location, false
otherwise.public void move()
DockStation
prepareMove
.
public void move(Dockable dockable, DockableProperty property)
DockStation
dockable
in such a way, that
DockStation.getDockableProperty(Dockable)
would return a
DockableProperty
that equals property
.DockStation
does nothing at all.
dockable
- a child of this stationproperty
- the preferred position of dockable
protected bibliothek.gui.dock.StackDockStation.Insert tabIndexAt(int x, int y)
x
- x-coordinate in the system of this stationy
- y-coordinate in the system of this station
protected bibliothek.gui.dock.StackDockStation.Insert exactTabIndexAt(int x, int y)
x
- x-coordinate in the system of this stationy
- y-coordinate in the system of this station
null
if no tab is
under x/ypublic void draw()
DockStation
prepareDrop
or
prepareMove
should
be painted somehow onto this station.StationPaint
of its theme
to draw.
public void forget()
DockStation
prepareDrop
or prepareMove
DockStation.draw()
, than the station can throw away these markings too.
public <D extends Dockable & DockStation> boolean isInOverrideZone(int x, int y, D invoker, Dockable drop)
DockStation
true
.true
.
D
- the type of invoker
x
- the x-coordinate of the mouse on the screeny
- the y-coordinate of the mouse on the screeninvoker
- a child of this station which invoked the methoddrop
- a Dockable
which might become a child
true
if the location of the mouse is of special
interestpublic boolean canDrag(Dockable dockable)
DockStation
dockable
can be removed from this station or not.
This method assumes that dockable
is a child of
this station, if not, then the behavior of this method is unspecified.
dockable
- a child of this station
true
if dockable
can be draggedpublic void drag(Dockable dockable)
DockStation
DockStation.canDrag(Dockable)
returned false
.
dockable
- the child to removepublic boolean canReplace(Dockable old, Dockable next)
DockStation
old
with next
where next is not a child of this station.
old
- a child of this stationnext
- the replacement of next
.
true
if the replacement is possiblepublic void replace(Dockable old, Dockable next)
DockStation
old
by next
which is
not yet a child of this station. This method should not be
called if canReplace
returned
false
.
old
- a childnext
- the replacement of next
public void add(Dockable dockable, int index)
index
.
dockable
- the new childindex
- the preferred location of the new childprotected void add(Dockable dockable, int index, boolean fire)
index
.
dockable
- the new childindex
- the preferred location of the new childfire
- if true
the method should fire events for
adding a new Dockable
, otherwise the method will run silentlypublic void remove(int index)
index
.
index
- the location of the child which will be removedpublic Component getComponent()
Dockable
Component
which represents this Dockable. Note that
the component should be a
focus cycle root
public void addMouseInputListener(MouseInputListener listener)
Dockable
MouseInputListener
to the component of this Dockable.
A Dockable has to decide by itself which Components
should be observer, but generally all free areas should be covered.
It's also possible just to ignore the listener, but that's not the
preferred behavior.
addMouseInputListener
in interface Dockable
addMouseInputListener
in class AbstractDockable
listener
- the mouse listenerpublic void removeMouseInputListener(MouseInputListener listener)
Dockable
removeMouseInputListener
in interface Dockable
removeMouseInputListener
in class AbstractDockable
listener
- The listener to removepublic String getFactoryID()
DockElement
DockFactory
which can read
and write elements of this type.
protected void insertionLine(Rectangle left, Rectangle right, Point a, Point b, boolean leftImportant)
Dockable
, a line has to be painted
between two tabs. This method determines the exact location of that line.
left
- the bounds of the tab left to the line, might be null
if
leftImportant
is false
.right
- the bounds of the tab right to the line, might be null
if
leftImportant
is true
.a
- the first point of the line, should be used as output of this methodb
- the second point of the line, should be used as output of this methodleftImportant
- true
if the mouse is over the left tab, false
if the mouse is over the right tab.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |