|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deegree_impl.graphics.legend.LegendElement_Impl
The implements the basic legend element. a legend element may has a label that can be set to eight positions relative to the legend graphic. A LegendElement can be activated or deactivated. It depends on the using application what effect this behavior will have.
LegendElements can be collected in a LegendElementCollection which also is a LegendElement to group elements or to create more complex elements.
Each LegendElement is able to paint itself as BufferedImage
Field Summary | |
protected boolean |
active
|
protected java.awt.image.BufferedImage |
bi
|
protected int |
bufferBetweenLegendAndLabel
|
protected int |
height
|
protected java.lang.String |
label
|
protected int |
labelPosition
|
protected double |
orientation
|
protected java.util.ArrayList |
ruleslist
|
protected int |
width
|
Fields inherited from interface org.deegree.graphics.legend.LegendElement |
LP_BOTTOMCENTER, LP_BOTTOMLEFT, LP_BOTTOMRIGHT, LP_LEFT, LP_NOLABEL, LP_RIGHT, LP_TOPCENTER, LP_TOPLEFT, LP_TOPRIGHT |
Constructor Summary | |
(package private) |
LegendElement_Impl()
empty constructor |
(package private) |
LegendElement_Impl(java.awt.image.BufferedImage legendImage)
|
(package private) |
LegendElement_Impl(Rule[] rules,
java.lang.String label,
double orientation,
int labelPosition,
boolean active,
int width,
int height)
constructor |
Method Summary | |
void |
addRule(Rule rule)
adds a rule to the ArrayList ruleslist |
protected int[] |
calculateFontMetrics(java.lang.String label)
calculates the FontMetrics of the LegendLabel in pixels. |
private java.awt.image.BufferedImage |
calculateImage(int labelposition,
int labelwidth,
int ascent,
int descent,
int legendwidth,
int legendheight,
int buffer)
calculates the width and height of the resulting LegendSymbol depending on the LabelPlacement |
protected void |
drawLineStringLegend(java.awt.Graphics2D g,
LineSymbolizer ls,
int width,
int height)
draws a legendsymbol, if the SLD defines a line |
protected void |
drawPointLegend(java.awt.Graphics g,
PointSymbolizer c,
int width,
int height)
draws a legendsymbol, if the SLD defines a point |
protected void |
drawPolygonLegend(java.awt.Graphics2D g,
PolygonSymbolizer ps,
int width,
int height)
draws a legendsymbol, if the SLD defines a polygon |
java.awt.image.BufferedImage |
exportAsImage()
exports the LegendElement as BufferedImage |
private java.awt.BasicStroke |
getBasicStroke(Stroke sldstroke)
constructs a java.awt.BasicStroke for painting a LineString legend symbol. |
int |
getBufferBetweenLegendAndLabel()
returns the buffer place between the legend symbol and the legend label in pixels |
int |
getHeight()
gets the height of the LegendSymbol (in pixels) |
java.lang.String |
getLabel()
returns the label set to LegendElement. |
double |
getLabelOrientation()
returns the current orientation of the label of the LegendElement in radians. |
int |
getLabelPlacement()
returns the placement of the label relative to the legend symbol. |
Rule[] |
getRules()
gets the Rules as an array |
int |
getWidth()
gets the width of the LegendSymbol (in pixels) |
boolean |
isActive()
gets the activtion-status of the label |
void |
setActive(boolean active)
activates or deactivates the label |
void |
setBufferBetweenLegendAndLabel(int i)
|
private java.awt.Graphics2D |
setColor(java.awt.Graphics2D g2,
java.awt.Color color,
double opacity)
sets the color including an opacity |
void |
setHeight(int height)
sets the height of the LegendSymbol (in pixels) |
void |
setLabel(java.lang.String label)
sets the label of the LegendElement |
void |
setLabelOrientation(double orientation)
sets the orientation of the label of the LegendElement. |
void |
setLabelPlacement(int labelPosition)
sets the placement of the label relative to the legend symbol. |
void |
setRules(Rule[] rules)
sets the rules |
void |
setWidth(int width)
sets the width of the LegendSymbol (in pixels) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.ArrayList ruleslist
protected java.lang.String label
protected double orientation
protected int labelPosition
protected boolean active
protected int width
protected int height
protected int bufferBetweenLegendAndLabel
protected java.awt.image.BufferedImage bi
Constructor Detail |
LegendElement_Impl()
LegendElement_Impl(java.awt.image.BufferedImage legendImage)
LegendElement_Impl(Rule[] rules, java.lang.String label, double orientation, int labelPosition, boolean active, int width, int height)
rules
- the different rules from the SLDlabel
- the label beneath the legend symbolorientation
- the rotation of the text in the legendlabelPosition
- the position of the text according to the symbolactive
- whether the legendsymbol is active or notwidth
- the requested width of the legend symbolheight
- the requested height of the legend symbolMethod Detail |
public Rule[] getRules()
public void addRule(Rule rule)
rule
- a sld rulepublic void setRules(Rule[] rules)
rules
- an array of sld rulespublic void setLabel(java.lang.String label)
setLabel
in interface LegendElement
label
- label of the LegendElementpublic java.lang.String getLabel()
getLabel
in interface LegendElement
public void setLabelOrientation(double orientation)
setLabelOrientation
in interface LegendElement
orientation
- public double getLabelOrientation()
getLabelOrientation
in interface LegendElement
public void setLabelPlacement(int labelPosition)
+---+---+---+ | 1 | 0 | 2 | +---+---+---+ | 4 |LEG| 3 | +---+---+---+ | 7 | 5 | 6 | +---+---+---+An implementation of the interface may not supoort all positions.
setLabelPlacement
in interface LegendElement
labelPosition
- public int getLabelPlacement()
getLabelPlacement
in interface LegendElement
public void setActive(boolean active)
setActive
in interface LegendElement
active
- public boolean isActive()
public void setWidth(int width)
public int getWidth()
public void setHeight(int height)
public int getHeight()
public int getBufferBetweenLegendAndLabel()
public void setBufferBetweenLegendAndLabel(int i)
i
- the buffer as integer in pixelsgetBufferBetweenLegendAndLabel()
protected void drawPointLegend(java.awt.Graphics g, PointSymbolizer c, int width, int height) throws LegendException
g
- the graphics contextc
- the PointSymbolizer representing the drawable pointwidth
- the requested width of the symbolheight
- the requested height of the symbol
LegendException
- is thrown, if the parsing of the sld failes.protected void drawLineStringLegend(java.awt.Graphics2D g, LineSymbolizer ls, int width, int height) throws LegendException
g
- the graphics contextls
- the LineSymbolizer representing the drawable linewidth
- the requested width of the symbolheight
- the requested height of the symbol
LegendException
- is thrown, if the parsing of the sld failes.protected void drawPolygonLegend(java.awt.Graphics2D g, PolygonSymbolizer ps, int width, int height) throws LegendException
g
- the graphics contextps
- the PolygonSymbolizer representing the drawable polygonwidth
- the requested width of the symbolheight
- the requested height of the symbol
LegendException
- if the parsing of the sld failes.private java.awt.Graphics2D setColor(java.awt.Graphics2D g2, java.awt.Color color, double opacity)
g2
- the graphics contect as Graphics2Dcolor
- the requested color of the legend symbolopacity
- the requested opacity of the legend symbol
private java.awt.BasicStroke getBasicStroke(Stroke sldstroke) throws LegendException
sldstroke
- the deegree sld stroke
LegendException
- if the sld cannot be processedprotected int[] calculateFontMetrics(java.lang.String label)
label
- the label of the LegendElement
private java.awt.image.BufferedImage calculateImage(int labelposition, int labelwidth, int ascent, int descent, int legendwidth, int legendheight, int buffer)
public java.awt.image.BufferedImage exportAsImage() throws LegendException
exportAsImage
in interface LegendElement
LegendException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |