|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bbn.openmap.omGraphics.DrawingAttributes
DrawingAttributes provides a mechanism for loading and managing different drawing attributes that may be used. Several layers need to be able to have Properties define how objects should be drawn, and the list of these drawing attributes tend to be the same. The DrawingAttributes class fishes out the applicable properties for you, creates the objects needed, and then lets you get those objects when needed.
The list of properties that the DrawingAttributes object can handle are listed below. If a property is not set, the default value will be used.
# The Edge or Line color lineColor=AARRGGBB (Hex ARGB Color, black is default) # The Fill color for 2D shapes fillColor=AARRGGBB (Hex ARGB Color, clean is default) # The Text Color for objects where any text should be different than the line color. textColor=AARRGGBB (Hex ARGB Color, black is default) # A highlight color to switch a graphic to when "selected". selectColor=AARRGGBB (Hex ARGB Color, black is default) # A file or URL that can be used for a fill pattern, in place of the fill color. fillPattern=file://file (default is N/A) # The line width of the edge of the graphic lineWidth=int (1 is default) # A pattern to use for a dashed line, reflected as a # space-separated list of numbers, which are interpreted as on dash # length, off dash length, on dash length, etc. dashPattern=10 5 3 5 (5 5 is the default if an error occurs reading the numbers, a non-dashed line is the default.) The phase for the dash pattern, dashPhase=0.0f (0 is the default) # The scale to use for certain measurements, so that fill patterns # can be scaled depending on the map scale compaired to the # baseScale. baseScale=XXXXXX (where 1:XXXXXX is the scale to use. N/A for the default). # Set whether any OMPoints that are given to the DrawingAttributes object are oval or rectangle. pointOval=false # Set the pixel radius of any OMPoint given to the DrawingAttributes object. pointRadius=2
Field Summary | |
static boolean |
alwaysSetTextToBlack
|
protected float |
baseScale
The base scale for scaling the fill pattern image. |
static java.lang.String |
baseScaleProperty
The base scale to use for the image provided for the fill pattern. |
protected BasicStrokeEditorMenu |
bse
|
static java.lang.String |
dashPatternProperty
The name of the property that holds a dashed pattern for lines. |
static java.lang.String |
dashPhaseProperty
The name of the property that holds a dashed phase for lines. |
static DrawingAttributes |
DEFAULT
A good ol' generic DrawingAttributes object for all to use. |
static float |
defaultDashLength
The defaule dash length, for opaque and transparent parts. |
static float |
defaultDashPhase
The default dash phase, which is zero. |
static java.lang.String |
defaultFillPaintString
The default fill paint. |
static java.lang.String |
defaultLinePaintString
The default line paint. |
static float |
defaultLineWidth
The default line width |
static java.lang.String |
defaultMattingPaintString
The default matting paint. |
static java.lang.String |
defaultSelectPaintString
The default fill paint. |
static java.lang.String |
FillColorCommand
Command for fill color string adjustments. |
protected java.awt.Paint |
fillPaint
The paint to fill the shapes. |
static java.lang.String |
fillPaintProperty
The name of the property that holds the fill paint of the graphics. |
protected java.awt.TexturePaint |
fillPattern
A TexturePaint pattern, if defined. |
static java.lang.String |
fillPatternProperty
The property that specifies an URL or file a image file to be used to construct the Paint object for a texture fill pattern. |
protected java.lang.String |
fPattern
|
protected I18n |
i18n
For internationalization. |
protected static int |
icon_height
|
protected static int |
icon_width
|
protected javax.swing.JButton |
lineButton
The JButton used to bring up the line menu. |
static java.lang.String |
LineColorCommand
Command for line color string adjustments. |
protected javax.swing.JMenu[] |
lineMenuAdditions
Any additional JMenu items that should be added to the line menu. |
protected java.awt.Paint |
linePaint
The paint to outline the shapes. |
static java.lang.String |
linePaintProperty
The name of the property that holds the line paint of the graphics. |
static java.lang.String |
lineWidthProperty
The name of the property that holds the lineWidth of the graphics. |
protected boolean |
matted
Whether a thin black matting line should be rendered around the OMGraphic. |
static java.lang.String |
MattedCommand
Command for adding matting. |
static java.lang.String |
mattedProperty
Set whether a thin black matting should be drawing around the OMGraphic. |
static java.lang.String |
MattingColorCommand
Command for matting color string adjustments. |
protected java.awt.Paint |
mattingPaint
The paint to use for matting. |
static java.lang.String |
mattingPaintProperty
The name of the property that holds the matting paint of the graphics, which is the wider line paint that gets set when matting is enabled. |
static int |
NONE
|
protected javax.swing.JPanel |
palette
|
protected boolean |
pointOval
The isOval setting to set on OMPoints. |
static java.lang.String |
PointOvalProperty
Property for whether OMPoints should be oval. |
protected int |
pointRadius
The pixel radius to set on OMPoints. |
static java.lang.String |
PointRadiusProperty
Property for the pixel radius of OMPoints. |
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
Support object to notify listeners when something has changed. |
protected java.lang.String |
propertyPrefix
|
static java.lang.String |
SelectColorCommand
Command for select color string adjustments. |
protected java.awt.Paint |
selectPaint
The select paint for the shapes. |
static java.lang.String |
selectPaintProperty
The name of the property that holds the select paint of the graphics, which is the line paint that gets set with the default OMGraphic.select() action. |
protected java.awt.Stroke |
stroke
The line stroke, for dashes, etc. |
protected javax.swing.JToolBar |
toolbar
|
Fields inherited from interface com.bbn.openmap.PropertyConsumer |
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty |
Constructor Summary | |
DrawingAttributes()
Create a DrawingAttributes with the default settings - clear fill paint and pattern, sold black edge line of width 1. |
|
DrawingAttributes(java.util.Properties props)
Create the DrawingAttributes and call setProperties without a prefix for the properties. |
|
DrawingAttributes(java.lang.String prefix,
java.util.Properties props)
Create the DrawingAttributes and call setProperties with a prefix for the properties. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
The DrawingAttributes method for handling ActionEvents. |
static java.awt.Color |
calculateTextColor(java.awt.Color color)
|
java.lang.Object |
clone()
Shallow clone. |
java.awt.Stroke |
cloneBasicStroke()
|
boolean |
equals(DrawingAttributes da)
|
float |
getBaseScale()
Get the base scale that the texture paint and dashes are set for. |
BasicStrokeEditorMenu |
getBasicStrokeEditor()
|
protected javax.swing.JPanel |
getColorAndLineGUI()
Gets the JToolBar that contains controls for changing the colors and line stroke. |
static DrawingAttributes |
getDefaultClone()
If you want to get a DEFAULT DrawingAttributes object that you may modify, get your own copy. |
java.awt.Paint |
getFillPaint()
Get the fill paint for the graphics created for the coverage type. |
java.awt.Paint |
getFillPaintForScale(float scale)
Get the Paint for these attributes, and scale it for the scale compaired to the base scale set if the fill Paint is a TexturePattern. |
java.awt.TexturePaint |
getFillPattern()
Get the TexturePaint set as the fill pattern. |
static java.awt.Paint |
getGradientPaintForShape(java.awt.Shape shape,
java.awt.Paint paint)
|
java.awt.Component |
getGUI()
Get the GUI components that control the DrawingAttributes. |
javax.swing.ImageIcon |
getIconForPaint(java.awt.Paint paint,
boolean fill)
|
java.lang.String |
getInitPropertiesOrder()
|
protected javax.swing.JButton |
getLineButton()
Get the JButton used to bring up the line menu. |
javax.swing.JMenu[] |
getLineMenuAdditions()
|
java.awt.Paint |
getLinePaint()
Get the line paint for the graphics created for the coverage type. |
javax.swing.JMenu |
getLineTypeMenu()
Get the menu that adjusts the line type. |
protected boolean |
getLock()
Get the lock to use a JColorChooser. |
javax.swing.ImageIcon |
getMattedIcon()
|
javax.swing.ImageIcon |
getMattingIconForPaint()
|
java.awt.Paint |
getMattingPaint()
Get the matting paint for the OMGraphics |
protected java.awt.Color |
getNewPaint(java.awt.Component source,
java.lang.String title,
java.awt.Color startingColor)
A convenience method to get a color from a JColorChooser. |
static javax.swing.ImageIcon |
getPaletteIcon(java.awt.Paint paint,
int width,
int height)
Create an ImageIcon from a java.awt.Paint. |
int |
getPointRadius()
Get the pixel radius given to OMPoint objects. |
java.util.Properties |
getProperties(java.util.Properties props)
PropertyConsumer method, to fill in a Properties object, reflecting the current values of the layer. |
java.beans.PropertyChangeSupport |
getPropertyChangeSupport()
Get the PropertyChangeSupport object to register anything that is interested in finding out when some parameter has changed. |
java.util.Properties |
getPropertyInfo(java.util.Properties list)
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. |
java.lang.String |
getPropertyPrefix()
Get the property key prefix that is being used to prepend to the property keys for Properties lookups. |
java.awt.Paint |
getSelectPaint()
Get the line paint for the graphics created for the coverage type. |
java.awt.Stroke |
getStroke()
Get the Stroke used for the lines of a graphic. |
java.awt.Stroke |
getStrokeForScale(float scale)
Get the Stroke object, scaled for comparison to the base scale. |
void |
init(java.util.Properties props)
Deprecated. use setProperties(props). |
void |
init(java.lang.String prefix,
java.util.Properties props)
Deprecated. use setProperties(prefix, props). |
boolean |
isMatted()
Return whether the OMGraphic has matting around the edge. |
boolean |
isPointOval()
Get the oval setting given to OMPoint objects. |
static int |
normalizeOn128(int value)
|
void |
propertyChange(java.beans.PropertyChangeEvent pce)
|
protected void |
releaseLock()
Release the lock on the JColorChooser. |
void |
render(java.awt.Graphics2D g,
java.awt.Shape shape)
Render the Shape into the Graphics2D object, using the mattingPaint, fillPaint, fillPattern, linePaint and stroke contained in this DrawingAttributes object. |
void |
render(java.awt.Graphics2D g,
java.awt.Shape shape,
boolean replaceColorWithGradient)
Render the Shape into the Graphics2D object, using the mattingPaint, fillPaint, fillPattern, linePaint and stroke contained in this DrawingAttributes object. |
void |
resetGUI()
Updates the color and line stroke control buttons to match the current settings. |
void |
setBaseScale(float bScale)
Set the base scale to use for the texture paint and stroke. |
void |
setFillPaint(java.awt.Paint fPaint)
Set the fill paint for the graphics created for the coverage type. |
void |
setFillPattern(java.awt.TexturePaint fPattern)
Set the fill pattern TexturePaint to be used as the fill color. |
void |
setFrom(OMGraphic graphic)
Set the DrawingAttributes parameters based on the current settings of an OMGraphic. |
void |
setLineMenuAdditions(javax.swing.JMenu[] lma)
A hook to add to the line menu brought up in the GUI for the DrawingAttributes. |
void |
setLinePaint(java.awt.Paint lPaint)
Set the edge paint for the graphics created for the coverage type. |
void |
setMatted(boolean set)
Set whether the OMGraphic should have matting around the edge. |
void |
setMattingPaint(java.awt.Paint mPaint)
Set the matting paint for the graphics created for the coverage type. |
void |
setOMGraphicAttributesForScale(OMGraphic graphic,
float scale)
Set all the attributes for the graphic that are contained within this DrawingAttributes class. |
void |
setOMGraphicEdgeAttributes(OMGraphic graphic)
Set the graphic attributes that only pertain to boundaries. |
void |
setOMGraphicEdgeAttributesForScale(OMGraphic graphic,
float scale)
Set the graphic attributes that only pertain to boundaries. |
void |
setPointOval(boolean value)
Set the oval setting given to OMPoint objects. |
void |
setPointRadius(int radius)
Set the pixel radius given to OMPoint objects. |
void |
setProperties(java.util.Properties props)
Sets the properties for the DrawingAttributes . |
void |
setProperties(java.lang.String prefix,
java.util.Properties props)
Sets the properties for the DrawingAttributes . |
void |
setPropertyChangeSupport(java.beans.PropertyChangeSupport support)
|
void |
setPropertyPrefix(java.lang.String prefix)
Set the property key prefix that should be used by the PropertyConsumer. |
void |
setSelectPaint(java.awt.Paint sPaint)
Set the selected edge paint for the graphics created for the coverage type. |
void |
setStroke(java.awt.Stroke stroke)
Set the Stroke to use for the edge of a graphic. |
void |
setTo(DrawingAttributes clone)
Shallow. |
void |
setTo(OMGraphic graphic)
Set all the attributes for the graphic that are contained within this DrawingAttributes class. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String linePaintProperty
public static final java.lang.String fillPaintProperty
public static final java.lang.String selectPaintProperty
public static final java.lang.String mattingPaintProperty
public static final java.lang.String fillPatternProperty
public static final java.lang.String lineWidthProperty
public static final java.lang.String dashPatternProperty
public static final java.lang.String dashPhaseProperty
public static final java.lang.String baseScaleProperty
public static final java.lang.String mattedProperty
public static final java.lang.String PointOvalProperty
public static final java.lang.String PointRadiusProperty
public static final int NONE
public static final java.lang.String defaultLinePaintString
public static final java.lang.String defaultFillPaintString
public static final java.lang.String defaultSelectPaintString
public static final java.lang.String defaultMattingPaintString
public static final float defaultLineWidth
public static final float defaultDashPhase
public static final float defaultDashLength
protected java.awt.Paint linePaint
protected java.awt.Paint selectPaint
protected java.awt.Paint fillPaint
protected java.awt.Paint mattingPaint
protected java.awt.TexturePaint fillPattern
protected transient java.awt.Stroke stroke
protected float baseScale
protected boolean matted
protected java.lang.String propertyPrefix
protected java.lang.String fPattern
protected boolean pointOval
protected int pointRadius
public static final DrawingAttributes DEFAULT
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected I18n i18n
public static final java.lang.String LineColorCommand
public static final java.lang.String FillColorCommand
public static final java.lang.String SelectColorCommand
public static final java.lang.String MattingColorCommand
public static final java.lang.String MattedCommand
protected static final int icon_width
protected static final int icon_height
public static boolean alwaysSetTextToBlack
protected transient BasicStrokeEditorMenu bse
protected javax.swing.JButton lineButton
protected javax.swing.JMenu[] lineMenuAdditions
protected javax.swing.JPanel palette
protected javax.swing.JToolBar toolbar
Constructor Detail |
public DrawingAttributes()
public DrawingAttributes(java.util.Properties props)
props
- the Properties to look in.public DrawingAttributes(java.lang.String prefix, java.util.Properties props)
prefix
- the prefix marker to use for a property, like
prefix.propertyName. The period is added in this
function.props
- the Properties to look in.Method Detail |
public java.lang.Object clone()
clone
in class java.lang.Object
public java.awt.Stroke cloneBasicStroke()
public void setTo(DrawingAttributes clone)
public boolean equals(DrawingAttributes da)
public static DrawingAttributes getDefaultClone()
public void init(java.util.Properties props)
props
- the Properties to look in.public void init(java.lang.String prefix, java.util.Properties props)
prefix
- the prefix marker to use for a property, like
prefix.propertyName. The period is added in this
function.props
- the Properties to look in.public void setStroke(java.awt.Stroke stroke)
public java.awt.Stroke getStroke()
public java.awt.Stroke getStrokeForScale(float scale)
scale
- scale to compare to the base scale.public java.awt.Paint getFillPaintForScale(float scale)
scale
- scale to compare to the base scale.
public void setLinePaint(java.awt.Paint lPaint)
lPaint
- the paint.public java.awt.Paint getLinePaint()
public void setSelectPaint(java.awt.Paint sPaint)
sPaint
- the paint.public java.awt.Paint getSelectPaint()
public void setFillPaint(java.awt.Paint fPaint)
fPaint
- the paint.public java.awt.Paint getFillPaint()
public void setMattingPaint(java.awt.Paint mPaint)
mPaint
- the paint.public java.awt.Paint getMattingPaint()
public void setFillPattern(java.awt.TexturePaint fPattern)
fPattern
- the TexturePaint to set.public java.awt.TexturePaint getFillPattern()
public void setBaseScale(float bScale)
bScale
- the base scale to use - 1:bScale.public float getBaseScale()
public boolean isMatted()
public void setMatted(boolean set)
public void setPointRadius(int radius)
public int getPointRadius()
public void setPointOval(boolean value)
public boolean isPointOval()
public void setFrom(OMGraphic graphic)
public void setTo(OMGraphic graphic)
If the fillPattern is set to a TexturePaint, and the fillPaint is null or clear, then the fillPattern will be set as the fill paint. Otherwise, the fillPaint will be set in the OMGraphic, and the fillPattern will be set too. If the OMGraphic.textureMask is != null, then it will get painted on top of the fillPaint. Makes for effects if the fillPattern has some transparent spots.
graphic
- OMGraphic.public void setOMGraphicEdgeAttributes(OMGraphic graphic)
graphic
- OMGraphicpublic void setOMGraphicAttributesForScale(OMGraphic graphic, float scale)
graphic
- OMGraphic.scale
- scale to compare to the base scale.public void setOMGraphicEdgeAttributesForScale(OMGraphic graphic, float scale)
graphic
- OMGraphic.scale
- scale to compare to the base scale.protected boolean getLock()
protected void releaseLock()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
protected java.awt.Color getNewPaint(java.awt.Component source, java.lang.String title, java.awt.Color startingColor)
source
- the source component for the JColorChooser.title
- the String to label the JColorChooser window.startingColor
- the color to give to the JColorChooser to
start with. Returned if the cancel button is pressed.
public java.awt.Component getGUI()
protected javax.swing.JPanel getColorAndLineGUI()
protected javax.swing.JButton getLineButton()
public javax.swing.JMenu getLineTypeMenu()
public void setLineMenuAdditions(javax.swing.JMenu[] lma)
public javax.swing.JMenu[] getLineMenuAdditions()
public void resetGUI()
public static javax.swing.ImageIcon getPaletteIcon(java.awt.Paint paint, int width, int height)
paint
- java.awt.Paintwidth
- icon pixel widthheight
- icon pixel heightpublic java.beans.PropertyChangeSupport getPropertyChangeSupport()
public void setPropertyChangeSupport(java.beans.PropertyChangeSupport support)
public static java.awt.Color calculateTextColor(java.awt.Color color)
public static int normalizeOn128(int value)
public void setProperties(java.util.Properties props)
DrawingAttributes
.
This particular method assumes that the marker name is not
needed, because all of the contents of this Properties object
are to be used for this object, and scoping the properties with
a prefix is unnecessary.
setProperties
in interface PropertyConsumer
props
- the Properties
object.public BasicStrokeEditorMenu getBasicStrokeEditor()
public void setProperties(java.lang.String prefix, java.util.Properties props)
DrawingAttributes
.
Part of the PropertyConsumer interface. DrawingAttributess
which override this method should do something like:
public void setProperties(String prefix, Properties props) {
super.setProperties(prefix, props);
// do local stuff
}
If the addToBeanContext property is not defined, it is set to
false here.
setProperties
in interface PropertyConsumer
prefix
- the token to prefix the property namesprops
- the Properties
objectpublic java.util.Properties getProperties(java.util.Properties props)
getProperties
in interface PropertyConsumer
props
- a Properties object to load the PropertyConsumer
properties into. If props equals null, then a new
Properties object should be created.
public java.util.Properties getPropertyInfo(java.util.Properties list)
getPropertyInfo
in interface PropertyConsumer
list
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.
public java.lang.String getInitPropertiesOrder()
public void setPropertyPrefix(java.lang.String prefix)
setPropertyPrefix
in interface PropertyConsumer
prefix
- the prefix String.public java.lang.String getPropertyPrefix()
getPropertyPrefix
in interface PropertyConsumer
public void propertyChange(java.beans.PropertyChangeEvent pce)
propertyChange
in interface java.beans.PropertyChangeListener
public java.lang.String toString()
toString
in class java.lang.Object
public void render(java.awt.Graphics2D g, java.awt.Shape shape)
public void render(java.awt.Graphics2D g, java.awt.Shape shape, boolean replaceColorWithGradient)
g
- java.awt.Graphics2D object to render intoshape
- java.awt.Shape to drawreplaceColorWithGradient
- flag to specify replacement of
fill and edge colors with a GradientPaint to give a
light to dark look. You can set the Paints in the
DrawingAttributes object with GradientPaints if you want
more control over the GradientPaint, but this will let
the DrawingAttributes object take a shot at creating one
for a Color that fits the shape given.public static java.awt.Paint getGradientPaintForShape(java.awt.Shape shape, java.awt.Paint paint)
public javax.swing.ImageIcon getMattingIconForPaint()
public javax.swing.ImageIcon getIconForPaint(java.awt.Paint paint, boolean fill)
public javax.swing.ImageIcon getMattedIcon()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |