com.eliad.model.defaults
Class DefaultRulerModel

java.lang.Object
  |
  +--com.eliad.model.AbstractGenericModel
        |
        +--com.eliad.model.AbstractRulerModel
              |
              +--com.eliad.model.defaults.BasicRulerModel
                    |
                    +--com.eliad.model.defaults.DefaultRulerModel

public class DefaultRulerModel
extends BasicRulerModel

A full implementation of the RulerModel interface. It implements BasicRulerModel.setPreferredSize(int, int), BasicRulerModel.setMinSize(int, int) BasicRulerModel.setMaxSize(int, int).

Version:
1.0 04/08/00
Author:
Patrick Mérissert-Coffinières, Stephan Szymkowicz
See Also:
RulerModel, RulerConstants, Intervals, Serialized Form

Fields inherited from class com.eliad.model.AbstractGenericModel
listeners_
 
Constructor Summary
DefaultRulerModel(Intervals intervals, int orientation)
          A constructor based on an Intervals instance, that will provide implementation for the most important methods of the AbstractRulerModel API.
DefaultRulerModel(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)
           
protected  void doRemoveEntries(int start, int length)
           
protected  int doSetMaxSize(int index, int size)
          Sets the maximum size of a specific entry.
protected  int doSetMinSize(int index, int size)
          Sets the minimum size of a specific entry.
protected  int doSetPreferredSize(int index, int size)
          Sets the preferred size of a specific entry.
 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 getPreferredSize(int i)
          Returns the preferred size of a specific entry.
 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
 void setFixedSize(int size)
           
 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 index, boolean flag)
          Set the visible property of an item.
 
Methods inherited from class com.eliad.model.defaults.BasicRulerModel
fireRulerModelChanged, fireRulerSizeChanged, fireRulerVisibilityChanged, getAutoResizeMode, getCount, getDefaultSize, getDraggingDistance, getFirstDraggingItem, getHiddenCount, getIndex, getLastDraggingItem, getMargin, getOrientation, getPosition, getScrollableBlockIncrement, getScrollableUnitIncrement, getSize, getSizes, getTotalSize, getVisibleCount, hasFixedSize, isResizable, isVisible, moveItems, resetDragging, setActiveRange, setAutoResizeMode, setDraggingDistance, setFirstDraggingItem, setLastDraggingItem, setMargin, setMaxSize, setMinSize, setPreferredSize, setResizable, setSize, setSizes, sizeToFit
 
Methods inherited from class com.eliad.model.AbstractRulerModel
addRulerModelListener, fireRulerBeforeItemsMoved, fireRulerDataChanged, fireRulerDraggingChanged, fireRulerItemsDeleted, fireRulerItemsInserted, fireRulerItemsMoved, fireRulerMarginChanged, fireRulerMaxSizeChanged, fireRulerMinSizeChanged, fireRulerPreferredSizeChanged, fireRulerResizableChanged, fireRulerSizesChanged, fireRulerStructureChanged, gridDataChanged, gridModelChanged, gridStructureChanged, insertEntries, insertEntries, propagateDataChange, propagateModelChange, propagateStructureChange, propertyChange, removeEntries, removeRulerModelListener
 
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

DefaultRulerModel

public DefaultRulerModel(Intervals intervals,
                         int orientation)
A constructor based on an Intervals instance, that will provide implementation for the most important methods of the AbstractRulerModel API.
Parameters:
intervals - The underlying Intervals object.
orientation - Whether this ruler is horizontal or vertical.

DefaultRulerModel

public DefaultRulerModel(int numEntries,
                         int size,
                         int orientation)
A constructor that uses a default Intervals implementation.
Parameters:
numEntries - The initial number of items.
size - The initial uniform size of all items.
orientation - Whether this ruler is horizontal or vertical.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
A specific implementation of clone.
Overrides:
clone in class BasicRulerModel

getPreferredSize

public int getPreferredSize(int i)
Returns the preferred size of a specific entry.
Parameters:
i - the index of the entry.
Returns:
the preferred size of the entry
Preconditions:
i >= 0 && i < getCount()
Postconditions:
return >= 0
Overrides:
getPreferredSize in class BasicRulerModel
See Also:
Intervals.getIndex(int)

doSetPreferredSize

protected int doSetPreferredSize(int index,
                                 int size)
Sets the preferred size of a specific entry. Does the actual implementation-specific job.
Parameters:
index - the index of the entry.
size - the preferred size of the entry
Returns:
The size actually set as preferred, or -1 if no change was made.
Preconditions:
index >= 0 && index < getCount()
size >= getMinSize(index) && size <= getMaxSize(index)
Overrides:
doSetPreferredSize in class BasicRulerModel

getTotalPreferredSize

public int getTotalPreferredSize()
Returns the total preferred size of the items in the most optimized way
Returns:
the total preferred size of the items
Postconditions:
return > 0
Overrides:
getTotalPreferredSize in class BasicRulerModel

setFixedSize

public void setFixedSize(int size)
Overrides:
setFixedSize in class BasicRulerModel

getMinSize

public int getMinSize(int index)
Returns the minimum size of a specific entry.
Parameters:
index - the index of the entry.
Returns:
the minimum size of the entry
Preconditions:
index >= 0 && index < getCount()
Postconditions:
return >= 0
Overrides:
getMinSize in class BasicRulerModel
See Also:
Intervals.getIndex(int)

doSetMinSize

protected int doSetMinSize(int index,
                           int size)
Sets the minimum size of a specific entry. Does the actual implementation-specific job.
Parameters:
index - the index of the entry.
size - the minimum size of the entry
Returns:
The size actually set as minimum, or -1 if no change was made.
Preconditions:
index >= 0 && index < getCount()
size >= getMinSize(index) && size <= getMaxSize(index)
Overrides:
doSetMinSize in class BasicRulerModel

setUniformMinSize

public void setUniformMinSize(int minSize)
Sets a uniform minimum size for all entries. Forgets about any specific setMinSize calls and then calls the superclass implementation.
Parameters:
minSize - the uniform minimum size
Throws:
java.lang.IllegalArgumentException -  
Preconditions:
minSize > 0
Overrides:
setUniformMinSize in class BasicRulerModel

getTotalMinSize

public int getTotalMinSize()
Returns the total minimum size of the items in the most optimized way
Returns:
the total minimum size of the items
Postconditions:
return > 0
Overrides:
getTotalMinSize in class BasicRulerModel

getMaxSize

public int getMaxSize(int index)
Returns the maximum size of a specific entry.
Parameters:
index - the index of the entry.
Returns:
the maximum size of the entry
Preconditions:
index >= 0 && index < getCount()
Postconditions:
return >= 0
Overrides:
getMaxSize in class BasicRulerModel
See Also:
Intervals.getIndex(int)

doSetMaxSize

protected int doSetMaxSize(int index,
                           int size)
Sets the maximum size of a specific entry. Does the actual implementation-specific job.
Parameters:
index - the index of the entry.
size - the maximum size of the entry
Returns:
The size actually set as maximum, or -1 if no change was made.
Preconditions:
index >= 0 && index < getCount()
size >= getMinSize(index) && size <= getMaxSize(index)
Overrides:
doSetMaxSize in class BasicRulerModel

setUniformMaxSize

public void setUniformMaxSize(int maxSize)
Sets a uniform maximum size for all entries. Forgets about any specific setMaxSize calls and then calls the superclass implementation.
Parameters:
maxSize - the uniform maximum size
Throws:
java.lang.IllegalArgumentException -  
Preconditions:
maxSize > 0
Overrides:
setUniformMaxSize in class BasicRulerModel

getTotalMaxSize

public int getTotalMaxSize()
Returns the total maximum size of the items in the most optimized way
Returns:
the total maximum size of the items
Postconditions:
return > 0
Overrides:
getTotalMaxSize in class BasicRulerModel

setVisible

public void setVisible(int index,
                       boolean flag)
Set the visible property of an item. Overloaded because the totalXXX properties have specific caches here, and visibility changes the impact upon them.
Parameters:
index - the index where we want to set the visible property
flag - the visible property for the index
Preconditions:
index >= 0 && index < getCount()
Overrides:
setVisible in class BasicRulerModel

doInsertEntries

protected void doInsertEntries(int start,
                               int length,
                               int value,
                               boolean visible)
Overrides:
doInsertEntries in class BasicRulerModel

doRemoveEntries

protected void doRemoveEntries(int start,
                               int length)
Overrides:
doRemoveEntries in class BasicRulerModel