|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--com.eliad.model.AbstractGenericModel
|
+--com.eliad.model.AbstractRulerModel
|
+--com.eliad.model.defaults.BasicRulerModel
A concrete implementation of the RulerModel interface based on the AbstractRulerModel
helper class. The setPreferredSize(int, int), setMinSize(int, int)
setMaxSize(int, int) methods are implemented as wrappers (providing general consistency) over protected methods
doSetPreferredSize(int, int), doSetMinSize(int, int), and doSetMaxSize(int, int), but those are implemented as
no-ops.
getPreferredSize(int) is implemented here to return the same result as getSize(int),
while getMinSize(int), getMaxSize(int) return fixed values.
getTotalPreferredSize(), getTotalMinSize(), and getTotalMaxSize() are implemented
efficiently by taking advantage of this.
The subclass DefaultRulerModel fully implements the API,
and is the one used by the JSmartGrid constructors.
Subclasses that would like to provide their own implementation should normally redefine:
doSetPreferredSize(int, int)doSetMinSize(int, int)doSetMaxSize(int, int)getPreferredSize(int)getMinSize(int)getMaxSize(int)getTotalPreferredSize()getTotalMinSize()getTotalMaxSize()setUniformMinSize(int)setUniformMaxSize(int)totalXXX properties,
it may have to redefine other methods such as setVisible(int, boolean).
Also the resizable indexed property
is always true.
RulerModel,
RulerConstants,
Intervals, Serialized Form| Fields inherited from class com.eliad.model.AbstractGenericModel |
listeners_ |
| Constructor Summary | |
BasicRulerModel(Intervals intervals,
int orientation)
A constructor based on an Intervals instance,
that will provide implementation for the most important methods of the
AbstractRulerModel API. |
|
BasicRulerModel(int numEntries,
int size,
int orientation)
A constructor that uses a default Intervals implementation. |
|
| Method Summary | |
java.lang.Object |
clone()
A specific implementation of clone. |
protected void |
doInsertEntries(int start,
int length,
int value,
boolean visible)
Adds a continuous group of entries to this RuleModel.
|
protected void |
doRemoveEntries(int start,
int length)
Removes a continuous group of entries from this RulerModel. |
protected int |
doSetMaxSize(int index,
int maxSize)
Sets the maximum size of a specific entry. |
protected int |
doSetMinSize(int index,
int minSize)
Sets the minimum size of a specific entry. |
protected int |
doSetPreferredSize(int index,
int size)
Sets the preferred size of a specific entry. |
void |
fireRulerModelChanged()
The entire model have changed. this is a direct synchronization. |
void |
fireRulerSizeChanged(int index,
int old,
int size)
Forwards a "size changed" notification event to all RulerModelListeners that registered
themselves as listeners for this ruler presentation model.
|
void |
fireRulerVisibilityChanged(int index,
int size)
Forwards a "visibility changed" notification event to all RulerModelListeners that registered
themselves as listeners for this ruler presentation model.
|
int |
getAutoResizeMode()
Returns the resizing mode of the ruler. |
int |
getCount()
Returns the number of entries in this RulerMode object.
|
int |
getDefaultSize()
Returns the default size for new entries. |
int |
getDraggingDistance()
Returns the distance the "dragged" items are from their normal position. |
int |
getFirstDraggingItem()
Returns the first of a continuous range of items that has been "dragged" out of its normal position. |
protected int |
getHiddenCount()
Returns the number of invisible items |
int |
getIndex(int position)
Returns the index of the entry that corresponds to the specified position. |
int |
getLastDraggingItem()
Returns the first of a continuous range of items that has been "dragged" out of its normal position. |
int |
getMargin()
returns the global margin value |
int |
getMaxSize(int index)
Returns the maximum size of a specific entry. |
int |
getMinSize(int index)
Returns the minimum size of a specific entry. |
int |
getOrientation()
Returns the orientation of the ruler. |
int |
getPosition(int index)
Returns the start position for the specified entry. |
int |
getPreferredSize(int index)
Returns the preferred size of a specific entry. |
int |
getScrollableBlockIncrement(int start,
int length,
int direction)
Returns the scroll increment (in pixels) that completely exposes one new "page". |
int |
getScrollableUnitIncrement(int start,
int length,
int direction)
Returns the scroll increment (in pixels) that completely exposes one new item. |
int |
getSize(int index)
Returns the size of the specified entry. |
int[] |
getSizes()
Returns the array of sizes for all entries. |
int |
getTotalMaxSize()
Returns the total maximum size of the items in the most optimized way. |
int |
getTotalMinSize()
Returns the total minimum size of the items in the most optimized way. |
int |
getTotalPreferredSize()
Returns the total preferred size of the items in the most optimized way Since for the default implementation getSize(i) == getPreferredSize(i) getTotalPreferredSize simply returns
getTotalSize. |
int |
getTotalSize()
Returns the total size of the items in the most optimized way possible. |
protected int |
getVisibleCount()
Returns the number of visible items |
boolean |
hasFixedSize()
Tests whether this ruler has constant size for all items. |
boolean |
isResizable(int index)
Returns the resizable attribute for a specific item. |
boolean |
isVisible(int index)
Tests whether a given item is visible or not. |
void |
moveItems(int from,
int count,
int to)
|
void |
resetDragging()
Resets all dragging parameters. |
void |
setActiveRange(int start,
int length)
Meant for the manager about the area of interest, where subsequent queries should be answered very efficiently. |
void |
setAutoResizeMode(int mode)
Sets the resizing mode of the ruler. |
void |
setDraggingDistance(int d)
Sets the distance the "dragged" items have been from their normal position. |
void |
setFirstDraggingItem(int index)
Sets the first of a continuous range of items that has been "dragged" out of its normal position. |
void |
setFixedSize(int size)
Gives a given constant size to all the items of the ruler. |
void |
setLastDraggingItem(int index)
Sets the last of a continuous range of items that should be considered "dragged" out of its normal position. |
void |
setMargin(int m)
Sets the global margin value |
int |
setMaxSize(int index,
int maxSize)
Sets the maximum size of a specific entry. |
int |
setMinSize(int index,
int minSize)
Sets the minimum size of a specific entry. |
int |
setPreferredSize(int index,
int size)
Sets the preferred size of a specific entry. |
void |
setResizable(int index,
boolean flag)
Sets whether or not to programatically change the resizable attribute for a specific item. |
void |
setSize(int index,
int size)
Sets the size of the specified entry. |
void |
setSizes(int[] sizes)
Sets the sizes for all entries from an array |
void |
setUniformMaxSize(int maxSize)
Sets a uniform maximum size for all entries. |
void |
setUniformMinSize(int minSize)
Sets a uniform minimum size for all entries. |
void |
setVisible(int i,
boolean flag)
|
void |
sizeToFit(int totalSize)
|
| Methods inherited from class com.eliad.model.AbstractGenericModel |
getListenerCount,
getListeners |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public BasicRulerModel(Intervals intervals,
int orientation)
Intervals instance,
that will provide implementation for the most important methods of the
AbstractRulerModel API.intervals - the underlying Intervals object.orientation - whether this ruler is horizontal or vertical.
public BasicRulerModel(int numEntries,
int size,
int orientation)
Intervals implementation.numEntries - the initial number of items.size - the initial uniform size of all items.orientation - whether this ruler is horizontal or vertical.| Method Detail |
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone.public int[] getSizes()
public void setSizes(int[] sizes)
public void fireRulerModelChanged()
This class needs to enhance the AbstractRulerModel
implementation to handle the cache. Subclasses that would need
to do the same for a similar purpose should start by calling
the superclass method.
public int getOrientation()
RulerConstants.HORIZONTAL || return == RulerConstants.VERTICAL
public int getScrollableUnitIncrement(int start,
int length,
int direction)
This method is called each time the user requests a unit scroll.
start - the start of the view area visible within the viewportlength - the length of the view area visible within the viewportdirection - less than zero to scroll up/left,
greater than zero for down/rightScrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
public int getScrollableBlockIncrement(int start,
int length,
int direction)
This method is called each time the user requests a page scroll.
start - the start of the view area visible within the viewportlength - the length of the view area visible within the viewportdirection - less than zero to scroll up/left,
greater than zero for down/rightScrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)public int getAutoResizeMode()
public void setAutoResizeMode(int mode)
mode - the resize mode.
May be one of the following values:public int getPreferredSize(int index)
index - the index of the entry.Intervals.getIndex(int)
protected int doSetPreferredSize(int index,
int size)
index - the index of the entry.size - the preferred size of the entry
public int setPreferredSize(int index,
int size)
index - the index of the entry.size - the preferred size of the entryIntervals.getIndex(int)public int getMinSize(int index)
index - the index of the entry.
protected int doSetMinSize(int index,
int minSize)
index - the index of the entry.minSize - the minimum size of the entry
public int setMinSize(int index,
int minSize)
index - the index of the entry.minSize - the preferred size of the entrypublic void setUniformMinSize(int minSize)
setMinSize may use this
as a default value, with specific values memorized in some store
where they hide the default. In this case they must override this method
as emptying the store before calling the base implementation.minSize - the uniform minimum sizepublic int getMaxSize(int index)
index - the index of the entry.
protected int doSetMaxSize(int index,
int maxSize)
index - the index of the entry.maxSize - the maximum size of the entry
public int setMaxSize(int index,
int maxSize)
index - the index of the entry. Should be non-negative.maxSize - the preferred size of the entrypublic void setUniformMaxSize(int maxSize)
setMaxSize may use this
as a default value, with specific values memorized in some store
where they hide the default. In this case they must override this method
as emptying the store before calling the base implementation.maxSize - the uniform maximum sizepublic boolean isResizable(int index)
index - the index of the item
public void setResizable(int index,
boolean flag)
index - the index of the itemflag - whether the user will be allowed to resize this item,
subject, of course, to the overall resizing strategy,
and to the minimum and maximum size constraintspublic int getMargin()
public void setMargin(int m)
m - the number of empty pixels between any two items
this will be subtracted from the item sizes, but smaller than the
least of the minimum sizes, though we do not verify it.public int getTotalSize()
public int getTotalMinSize()
getMinSize(i) is constantgetTotalMinSizesimply returns this constant times the count
public int getTotalPreferredSize()
getSize(i) == getPreferredSize(i)getTotalPreferredSizesimply returnsgetTotalSize.
public int getTotalMaxSize()
getMaxSize(i) is constant and equal to Integer.MAX_VALUE;getTotalMaxSizesimply returns this same constant
public int getDefaultSize()
Intervals wrapped object.public int getCount()
RulerMode object.
The base class just delegates to the Intervals wrapped object.
We are assuming here that it never needs to be optimized by the manager.
public void setActiveRange(int start,
int length)
start - the start of the range where we want subsequent queries
to be efficientlength - the length of the range where we want subsequent queries
to be efficientpublic final int getIndex(int position)
position - the position of the entryIntervals.getIndex(int)public final int getPosition(int index)
index - the index of the entry whose position is desiredIntervals.getPosition(int)protected int getHiddenCount()
protected int getVisibleCount()
public boolean isVisible(int index)
getSize
on them will return 0.
public void setVisible(int i,
boolean flag)
public void fireRulerVisibilityChanged(int index,
int size)
RulerModelListeners that registered
themselves as listeners for this ruler presentation model.
This class needs to enhance the AbstractRulerModel
implementation to handle the cache. Subclasses that would need
to do the same for a similar purpose should start by calling
the superclass method.
index - the index of the item concerned by the change.
-1 if many items are concernedAbstractRulerModel.addRulerModelListener(com.eliad.model.RulerModelListener),
RulerModelEventpublic int getSize(int index)
index - the index corresponding to the entry
public void setSize(int index,
int size)
index - the index corresponding to the entrysize - the size of the entry
public void fireRulerSizeChanged(int index,
int old,
int size)
RulerModelListeners that registered
themselves as listeners for this ruler presentation model.
This class needs to enhance the AbstractRulerModel
implementation to handle the cache. Subclasses that would need
to do the same for a similar purpose should start by calling
the superclass method.
index - the index of the item concerned by the change.
-1 if many items are concerned, and old
and value will be meaningless.old - the previous valuevalue - the new valueAbstractRulerModel.addRulerModelListener(com.eliad.model.RulerModelListener),
RulerModelEventpublic void setFixedSize(int size)
public boolean hasFixedSize()
public int getFirstDraggingItem()
public int getLastDraggingItem()
public int getDraggingDistance()
public void setFirstDraggingItem(int index)
index - the index of the first dragged itempublic void setLastDraggingItem(int index)
index - the index of the last dragged itempublic void setDraggingDistance(int d)
d - the number of size units (presumably pixels) between the actual
position of the dragged items and their normal position, such as that
given by getPosition.
public void moveItems(int from,
int count,
int to)
throws java.beans.PropertyVetoException
public void resetDragging()
public void sizeToFit(int totalSize)
protected void doInsertEntries(int start,
int length,
int value,
boolean visible)
RuleModel.
Implementation idiosynchrasy: Inserting entry(ies)
betweem two hidden entries creates hidden entries!start - the index to be assigned to the first entry
in the grouplength - the number of entries in the groupvalue - the size to be assigned to each new entryvisible - whether the new entries are initially visible
protected void doRemoveEntries(int start,
int length)
RulerModel.start - the index of the first entry to be removedlength - the number of entries to be removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||