sgtplot
Class ColorKey
- java.lang.Object
-
- sgtplot.ColorKey
-
- All Implemented Interfaces:
- java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener, DataKey, LayerChild, Selectable
public class ColorKey extends java.lang.Object implements java.lang.Cloneable, DataKey, java.beans.PropertyChangeListener
TheColorKeyclass provides a graphical depiction of the relationship between aColorMapand user values. A singleColorKeycan be attached to aLayer. AColorMapis associated with the Key and therefor with a specific transformation and optionally aSGTDataobject.
-
-
Field Summary
Fields Modifier and Type Field and Description static intBOTTOMAlign to bottom of key.static intCENTERAlign to center of key.static intHORIZONTALOrient key horizontally.static intLEFTAlign to left of key.static intMIDDLEAlign to middle of key.static intNO_BORDERDo not draw a border.static intPLAIN_LINEUse plain line border.static intRAISEDUse raised border.static intRIGHTAlign to right of key.static intTOPAlign to top of key.static intVERTICALOrient key vertically.
-
Constructor Summary
Constructors Constructor and Description ColorKey()DefaultColorKeyconstructor.ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign)ColorKey(Rectangle2D.Double pr, int valign, int halign)ColorKeyconstructor that include location, size, and alignment information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddGraph(CartesianRenderer rend, SGLabel label)Add a GridCartesianRenderer and label to the ColorKey.LayerChildcopy()Create a copy ofColorKey.voiddraw(org.freehep.graphics2d.VectorGraphics g)Draw the ColorKey.intgetBorderStyle()Get border style.java.awt.RectanglegetBounds()Gets the bounding rectangle in device coordinates.Rectangle2D.DoublegetBoundsP()Get the bounding rectangle for the key in physical coordinates.ColorMapgetColorMap()Get color map.intgetHAlign()Get horizontal alignmentjava.lang.StringgetId()GetColorKeyidentifierLayergetLayer()Returns the layer the ColorKey is attached.AbstractPanegetPane()Get the parent pane.RulergetRuler()Get theRulerassociated with the key.SGLabelgetTitle()Get the key's title.intgetVAlign()Get vertical alignmentbooleanisSelectable()Tests the selectable property.booleanisSelected()Returns true if theselectedproperty is set.booleanisVisible()Check if ColorKey is visible.voidmodified(java.lang.String mess)For internal sgtplot use.voidpropertyChange(java.beans.PropertyChangeEvent evt)voidsetAlign(int vert, int horz)Set color key alignment.voidsetBorderStyle(int style)Set border style.voidsetBounds(int x, int y, int width, int height)Change the selected objects bounding rectangle in device coordinates.voidsetBounds(java.awt.Rectangle r)Change the selected objects bounding rectangle in device coordinates.voidsetBoundsP(Rectangle2D.Double r)Set the bounds of the key in physical coordinates.voidsetColorMap(ColorMap cm)Set color map.voidsetColumns(int col)Set columns.voidsetHAlign(int horz)Set horizontal alignmentvoidsetId(java.lang.String id)Set ColorKey identifier.voidsetLayer(Layer l)Set parentLayer.voidsetLineLengthP(double len)Set line lenght.voidsetLocationP(Point2D.Double loc)Set location of key in physical coordinates.voidsetOrientation(int orient)Set orientation.voidsetScaleP(double scaleMin, double scaleMax)voidsetSelectable(boolean select)Sets the selectable property.voidsetSelected(boolean sel)Sets theselectedproperty.voidsetSizeP(Dimension2D d)Set the size of the key in physical coordinates.voidsetTitle(SGLabel title)Set the title of the key.voidsetVAlign(int vert)Set vertical alignmentvoidsetVisible(boolean visible)Set visibility state for ColorKey.java.lang.StringtoString()Get a string representation of the key.
-
-
-
Field Detail
-
PLAIN_LINE
public static final int PLAIN_LINE
Use plain line border.- See Also:
- Constant Field Values
-
RAISED
public static final int RAISED
Use raised border.- See Also:
- Constant Field Values
-
NO_BORDER
public static final int NO_BORDER
Do not draw a border.- See Also:
- Constant Field Values
-
TOP
public static final int TOP
Align to top of key.- See Also:
- Constant Field Values
-
MIDDLE
public static final int MIDDLE
Align to middle of key.- See Also:
- Constant Field Values
-
BOTTOM
public static final int BOTTOM
Align to bottom of key.- See Also:
- Constant Field Values
-
LEFT
public static final int LEFT
Align to left of key.- See Also:
- Constant Field Values
-
CENTER
public static final int CENTER
Align to center of key.- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
Align to right of key.- See Also:
- Constant Field Values
-
HORIZONTAL
public static final int HORIZONTAL
Orient key horizontally.- See Also:
- Constant Field Values
-
VERTICAL
public static final int VERTICAL
Orient key vertically.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColorKey
public ColorKey()
DefaultColorKeyconstructor. The location and size must be specified before theColorKeyis attached to a layer!
-
ColorKey
public ColorKey(Rectangle2D.Double pr, int valign, int halign)
ColorKeyconstructor that include location, size, and alignment information. Default orientation isHORIZONTAL.- Parameters:
pr- a Rectangle2D object that includes location and sizevalign- vertical alignmenthalign- horizontal alignment
-
ColorKey
public ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign)
- Since:
- 3.0
-
-
Method Detail
-
copy
public LayerChild copy()
Create a copy ofColorKey.- Specified by:
copyin interfaceLayerChild- Returns:
- a copy of the key
-
setSelected
public void setSelected(boolean sel)
Sets theselectedproperty.- Specified by:
setSelectedin interfaceSelectable- Parameters:
sel- true if selected, false if not.- Since:
- 2.0
-
isSelected
public boolean isSelected()
Returns true if theselectedproperty is set.- Specified by:
isSelectedin interfaceSelectable- Returns:
- true is selected, false if not.
-
setSelectable
public void setSelectable(boolean select)
Sets the selectable property.- Specified by:
setSelectablein interfaceSelectable- Parameters:
select- if true object is selectable- Since:
- 2.0
-
isSelectable
public boolean isSelectable()
Tests the selectable property.- Specified by:
isSelectablein interfaceSelectable- Returns:
- true if selectable
- Since:
- 2.0
-
setId
public void setId(java.lang.String id)
Set ColorKey identifier.- Specified by:
setIdin interfaceLayerChild- Parameters:
id- key identifier
-
setScaleP
public void setScaleP(double scaleMin, double scaleMax)
-
getId
public java.lang.String getId()
GetColorKeyidentifier- Specified by:
getIdin interfaceLayerChild- Returns:
- identifier
-
setLayer
public void setLayer(Layer l)
Set parentLayer. Method should not be called directly, called when theLayer.addChildmethod is called.- Specified by:
setLayerin interfaceLayerChild- Parameters:
l- parent layer
-
getLayer
public Layer getLayer()
Returns the layer the ColorKey is attached.- Specified by:
getLayerin interfaceLayerChild- Returns:
- The parent layer.
- See Also:
Layer
-
getPane
public AbstractPane getPane()
Get the parent pane.- Specified by:
getPanein interfaceLayerChild- Since:
- 2.0
-
modified
public void modified(java.lang.String mess)
For internal sgtplot use.- Specified by:
modifiedin interfaceLayerChild- Since:
- 2.0
-
setColorMap
public void setColorMap(ColorMap cm)
Set color map.- Parameters:
cm- color map
-
addGraph
public void addGraph(CartesianRenderer rend, SGLabel label) throws java.lang.IllegalArgumentException
Add a GridCartesianRenderer and label to the ColorKey.
-
getColorMap
public ColorMap getColorMap()
Get color map.- Returns:
- color map
-
setBorderStyle
public void setBorderStyle(int style)
Set border style.- Specified by:
setBorderStylein interfaceDataKey- Parameters:
style- border style- See Also:
PLAIN_LINE,RAISED,NO_BORDER
-
getBorderStyle
public int getBorderStyle()
Get border style.- Returns:
- border style
-
setAlign
public void setAlign(int vert, int horz)Set color key alignment.
-
setOrientation
public void setOrientation(int orient)
Set orientation.- Parameters:
orient- key orientation
-
setVAlign
public void setVAlign(int vert)
Set vertical alignment
-
setHAlign
public void setHAlign(int horz)
Set horizontal alignment
-
getVAlign
public int getVAlign()
Get vertical alignment- Returns:
- vertical alignment
-
getHAlign
public int getHAlign()
Get horizontal alignment- Returns:
- horizontal alignment
-
setLocationP
public void setLocationP(Point2D.Double loc)
Set location of key in physical coordinates.- Specified by:
setLocationPin interfaceDataKey- Parameters:
loc- key location
-
setSizeP
public void setSizeP(Dimension2D d)
Set the size of the key in physical coordinates.- Parameters:
d- size of key
-
setBoundsP
public void setBoundsP(Rectangle2D.Double r)
Set the bounds of the key in physical coordinates.- Specified by:
setBoundsPin interfaceDataKey- Parameters:
r- bounding rectangle
-
getBoundsP
public Rectangle2D.Double getBoundsP()
Get the bounding rectangle for the key in physical coordinates.- Returns:
- bounding rectangle
-
getBounds
public java.awt.Rectangle getBounds()
Gets the bounding rectangle in device coordinates.- Specified by:
getBoundsin interfaceSelectable- Returns:
- bounding rectangle
-
setBounds
public void setBounds(java.awt.Rectangle r)
Change the selected objects bounding rectangle in device coordinates. The object will move to the new bounding rectangle.- Parameters:
r- new bounding rectangle
-
setBounds
public void setBounds(int x, int y, int width, int height)Change the selected objects bounding rectangle in device coordinates. The object will move to the new bounding rectangle.- Parameters:
x- horizontal location, positive righty- vertical location, positive downwidth- horizontal sizeheight- vertical size
-
setTitle
public void setTitle(SGLabel title)
Set the title of the key.- Parameters:
title- key title
-
getTitle
public SGLabel getTitle()
Get the key's title.- Returns:
- the title
-
getRuler
public Ruler getRuler()
Get theRulerassociated with the key.- Returns:
- the ruler
-
draw
public void draw(org.freehep.graphics2d.VectorGraphics g)
Draw the ColorKey. This method should not be directly called.- Specified by:
drawin interfaceLayerChild- Parameters:
g- Graphics context- See Also:
Pane.draw(org.freehep.graphics2d.VectorGraphics, java.lang.String)
-
toString
public java.lang.String toString()
Get a string representation of the key.- Specified by:
toStringin interfaceLayerChild- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation
-
isVisible
public boolean isVisible()
Check if ColorKey is visible.- Specified by:
isVisiblein interfaceLayerChild- Returns:
- true if visible
- Since:
- 2.0
-
setVisible
public void setVisible(boolean visible)
Set visibility state for ColorKey.- Specified by:
setVisiblein interfaceLayerChild- Parameters:
visible- visible if true- Since:
- 2.0
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
setColumns
public void setColumns(int col)
Set columns. Unimplmented.- Specified by:
setColumnsin interfaceDataKey- Parameters:
col-- Since:
- 3.0
-
setLineLengthP
public void setLineLengthP(double len)
Set line lenght. Unimplemented.- Specified by:
setLineLengthPin interfaceDataKey- Since:
- 3.0
-
-
DMelt 3.0 © DataMelt by jWork.ORG