public abstract class DasDevicePosition extends java.lang.Object implements Editable, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected DasCanvas |
canvas |
protected javax.swing.event.EventListenerList |
listenerList |
protected DasDevicePosition |
parent |
static java.lang.String |
PROP_DMAXIMUM |
static java.lang.String |
PROP_DMINIMUM |
static java.lang.String |
PROP_EMMAXIMUM |
static java.lang.String |
PROP_EMMINIMUM |
static java.lang.String |
PROP_MAXIMUM |
static java.lang.String |
PROP_MAXLAYOUT |
static java.lang.String |
PROP_MINIMUM |
static java.lang.String |
PROP_MINLAYOUT |
static java.lang.String |
PROP_PARENT_DEVICE_POSITION_DAS_NAME |
static java.lang.String |
PROP_PTMAXIMUM |
static java.lang.String |
PROP_PTMINIMUM |
Modifier | Constructor and Description |
---|---|
protected |
DasDevicePosition(DasCanvas canvas,
boolean isWidth,
DasDevicePosition parent,
double minimum,
double maximum,
double emMinimum,
double emMaximum,
int ptMinimum,
int ptMaximum)
create the DasDevicePosition.
|
|
DasDevicePosition(DasCanvas parent,
double minimum,
double maximum,
boolean width) |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
void |
addUpdateListener(DasUpdateListener l)
add an update listener
|
boolean |
contains(int x)
returns true if ( getDMinimum() <= x ) && ( x <= getDMaximum() );
|
protected void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue) |
protected void |
firePropertyChange(java.lang.String propertyName,
double oldValue,
double newValue) |
protected void |
firePropertyChange(java.lang.String propertyName,
float oldValue,
float newValue) |
protected void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue) |
protected void |
firePropertyChange(java.lang.String propertyName,
long oldValue,
long newValue) |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue) |
protected void |
fireUpdate()
fire an update to all listeners.
|
static java.lang.String |
formatFormatStr(double[] arr)
Deprecated.
see formatLayoutStr( double[] arr )
|
static java.lang.String |
formatLayoutStr(DasDevicePosition pos)
formats the row or column position into a string like 100%+1em,100%+2em.
|
static java.lang.String |
formatLayoutStr(DasDevicePosition pos,
boolean min)
formats the row or column position into a string like 100%-5em+4pt.
|
static java.lang.String |
formatLayoutStr(double[] arr)
formats the three position specifiers efficiently.
|
protected DasCanvas |
getCanvas() |
java.lang.String |
getDasName()
get the name associated with this object.
|
protected int |
getDeviceSize()
return the size in pixels (or points)
|
int |
getDMaximum()
returns the pixel position of the maximum of the Row/Column.
|
int |
getDMiddle()
returns pixel position (device position) of the the middle of the row or column
|
int |
getDMinimum()
returns the pixel position of the minimum of the Row/Column.
|
double |
getEmMaximum()
return the em offset that controls the position of the bottom/right boundary.
|
double |
getEmMinimum()
return the em offset that controls the position of the top/left boundary.
|
int |
getEmSize()
returns the em size for the canvas.
|
double |
getMaximum()
return the normal position control of the bottom/right.
|
java.lang.String |
getMaxLayout() |
double |
getMinimum()
return the normal position control of the top/left.
|
java.lang.String |
getMinLayout() |
DasCanvas |
getParent()
return the parent canvas.
|
protected java.lang.String |
getParentDasName()
return the name of the parent which this is attached to.
|
DasDevicePosition |
getParentDevicePosition()
return the parent, or null.
|
int |
getPtMaximum()
return the points offset that controls the position of the bottom/right boundary.
|
int |
getPtMinimum()
return the points offset that controls the position of the top/left boundary.
|
boolean |
isValueIsAdjusting()
return true if the value is currently adjusting because a
mutator lock is out.
|
protected MutatorLock |
mutatorLock()
get a lock for this object, used to mutate a number of properties
as one atomic operation.
|
static double[] |
parseFormatStr(java.lang.String s)
Deprecated.
use parseLayoutStr.
|
static void |
parseLayoutStr(DasDevicePosition pos,
java.lang.String spec)
parses the layout string, which contains both the minimum and maximum
positions, and configures the row or column.
|
static double[] |
parseLayoutStr(java.lang.String s)
parse position strings like "100%-5em+4pt" into [ npos, emoffset, pt_offset ].
|
static double |
parseLayoutStr(java.lang.String s,
double em,
int widthHeight,
double fail)
parse the format string into a pixel count.
|
void |
removeListeners()
remove the listeners so that the DasRow or DasColumn can be garbage collected.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
void |
removeUpdateListener(DasUpdateListener l)
remove an update listener
|
protected void |
revalidate()
recalculates dMinimum and dMaximum based on the new values, and
checks for correctness.
|
void |
setDasName(java.lang.String name)
set the name associated with this object.
|
void |
setDMaximum(int maximum)
set the new pixel position of the bottom/right boundary.
|
void |
setDMinimum(int minimum)
set the new pixel position of the top/left boundary.
|
void |
setDPosition(int minimum,
int maximum)
set the new pixel location of both the min and max in one operation.
|
void |
setEmMaximum(double emMaximum)
set the em offset that controls the position of the bottom/right boundary.
|
void |
setEmMinimum(double emMinimum)
set the em offset that controls the position of the top/left boundary.
|
void |
setMax(double norm,
double em,
int pt)
set all three as one atomic operation
|
void |
setMaximum(double maximum)
set the normal position of the minimum of the row or column.
|
void |
setMaxLayout(java.lang.String maxLayout) |
void |
setMin(double norm,
double em,
int pt)
set all three as one atomic operation
|
void |
setMinimum(double minimum)
set the normal position of the minimum of the row or column.
|
void |
setMinLayout(java.lang.String minLayout) |
void |
setParent(DasCanvas parent)
set the parent canvas.
|
protected void |
setParentDevicePosition(DasDevicePosition newParent)
return the parent, or null.
|
void |
setPtMaximum(int ptMaximum)
set the pt offset that controls the position of the bottom/right boundary.
|
void |
setPtMinimum(int ptMinimum)
set the points offset that controls the position of the top/left boundary.
|
static java.awt.Rectangle |
toRectangle(DasRow row,
DasColumn column)
convenience method for creating a rectangle from a row and column.
|
java.lang.String |
toString()
return a human-readable string representing the object for debugging.
|
public static final java.lang.String PROP_DMAXIMUM
public static final java.lang.String PROP_DMINIMUM
public static final java.lang.String PROP_EMMAXIMUM
public static final java.lang.String PROP_EMMINIMUM
public static final java.lang.String PROP_MAXIMUM
public static final java.lang.String PROP_MINIMUM
public static final java.lang.String PROP_PTMAXIMUM
public static final java.lang.String PROP_PTMINIMUM
public static final java.lang.String PROP_PARENT_DEVICE_POSITION_DAS_NAME
protected transient DasCanvas canvas
protected transient DasDevicePosition parent
protected javax.swing.event.EventListenerList listenerList
public static final java.lang.String PROP_MAXLAYOUT
public static final java.lang.String PROP_MINLAYOUT
protected DasDevicePosition(DasCanvas canvas, boolean isWidth, DasDevicePosition parent, double minimum, double maximum, double emMinimum, double emMaximum, int ptMinimum, int ptMaximum)
canvas
- the canvas to which the position refers.isWidth
- true if the DasDevicePosition is a column not a row.parent
- null or the parent to which this position is relative.minimum
- normal position with respect to the canvas or parent if non-null.maximum
- normal position with respect to the canvas or parent if non-null.emMinimum
- em offset from the minimum position, in canvas font heights.emMaximum
- em offset from the maximum position, in canvas font heights.ptMinimum
- point offset from the minimum position, note points are the same as pixels.ptMaximum
- point offset from the maximum position, note points are the same as pixels.public DasDevicePosition(DasCanvas parent, double minimum, double maximum, boolean width)
public void removeListeners()
public static double parseLayoutStr(java.lang.String s, double em, int widthHeight, double fail)
s
- The string, like "5em+3pt"em
- the em height of the font,widthHeight
- the width or height of the dimension.fail
- the value to return if the parsing fails.public static double[] parseFormatStr(java.lang.String s) throws java.text.ParseException
s
- java.text.ParseException
public static double[] parseLayoutStr(java.lang.String s) throws java.text.ParseException
s
- string containing the position string.java.text.ParseException
formatFormatStr
public static java.lang.String formatFormatStr(double[] arr)
arr
- three-element array [ npos, emoffset, pt_offset ].parseFormatStr(java.lang.String)
,
which contains repeated code.
public static java.lang.String formatLayoutStr(double[] arr)
arr
- three-element array [ npos (0.0-1.0), emoffset, pt_offset ].parseFormatStr(java.lang.String)
,
which contains repeated code.
public static void parseLayoutStr(DasDevicePosition pos, java.lang.String spec) throws java.text.ParseException
pos
- row or column to assign values.spec
- string like "0%+2em,100%-5em+4pt"java.text.ParseException
- when the string cannot be parsed.public static java.lang.String formatLayoutStr(DasDevicePosition pos)
pos
- the row or columnwhich contains repeated code.
public static java.lang.String formatLayoutStr(DasDevicePosition pos, boolean min)
pos
- the row or columnmin
- true if the minimum boundary is to be formatted, false if the maximum boundary is to be formatted.which contains repeated code.
protected DasCanvas getCanvas()
public void setDasName(java.lang.String name) throws DasNameException
name
- the name associated with this objectDasNameException
public java.lang.String getDasName()
protected java.lang.String getParentDasName()
public int getEmSize()
protected final void revalidate()
public int getDMinimum()
public int getDMaximum()
public double getMinimum()
public double getMaximum()
public void setDPosition(int minimum, int maximum)
minimum
- the top or leftmaximum
- the bottom or rightpublic void setMaximum(double maximum)
maximum
- normal (0-1) positionpublic void setDMaximum(int maximum)
maximum
- new pixel maximumpublic void setMinimum(double minimum)
minimum
- normal (0-1) positionpublic void setDMinimum(int minimum)
minimum
- new pixel minimumpublic DasCanvas getParent()
public void setParent(DasCanvas parent)
parent
- canvas.protected MutatorLock mutatorLock()
public void addUpdateListener(DasUpdateListener l)
l
- update listenerpublic void removeUpdateListener(DasUpdateListener l)
l
- update listenerprotected void fireUpdate()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
protected void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
protected void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
protected void firePropertyChange(java.lang.String propertyName, long oldValue, long newValue)
protected void firePropertyChange(java.lang.String propertyName, float oldValue, float newValue)
protected void firePropertyChange(java.lang.String propertyName, double oldValue, double newValue)
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
protected int getDeviceSize()
public static java.awt.Rectangle toRectangle(DasRow row, DasColumn column)
row
- row describing the top and bottom of the box.column
- column describing the left and right sides of the box.public java.lang.String toString()
toString
in class java.lang.Object
public boolean contains(int x)
x
- the pixel positionpublic int getDMiddle()
public double getEmMinimum()
public void setEmMinimum(double emMinimum)
emMinimum
- the em offset.public double getEmMaximum()
public void setEmMaximum(double emMaximum)
emMaximum
- the em offset.public int getPtMinimum()
public void setPtMinimum(int ptMinimum)
ptMinimum
- the points offsetpublic int getPtMaximum()
public void setPtMaximum(int ptMaximum)
ptMaximum
- the em offset.public void setMin(double norm, double em, int pt)
norm
- normal position from 0 to 1.em
- em offset from the normal position.pt
- points offset from the normal position.public void setMax(double norm, double em, int pt)
norm
- normal position from 0 to 1.em
- em offset from the normal position.pt
- points offset from the normal position.public java.lang.String getMaxLayout()
public void setMaxLayout(java.lang.String maxLayout)
public java.lang.String getMinLayout()
public void setMinLayout(java.lang.String minLayout)
public DasDevicePosition getParentDevicePosition()
protected void setParentDevicePosition(DasDevicePosition newParent)
newParent
- the new parent, or null for the canvas itself.public boolean isValueIsAdjusting()