org.jplot2d.element.impl
Class LegendImpl
- java.lang.Object
-
- org.jplot2d.element.impl.ElementImpl
-
- org.jplot2d.element.impl.ComponentImpl
-
- org.jplot2d.element.impl.LegendImpl
-
- All Implemented Interfaces:
- Element, ComponentEx, ElementEx, LegendEx, Legend, MovableComponent, PComponent
public class LegendImpl extends ComponentImpl implements LegendEx
-
-
Constructor Summary
Constructors Constructor and Description LegendImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddLegendItem(LegendItemEx item)Add the given item to this legend.voidcalcSize()Calculate size of this legend and re-layout legend items.booleancanContribute()Returnstrueif this component can contribute visible parts to plot rendering artifact when this component is visible.voidcopyFrom(ElementEx src)Copies all properties from given src to this element.voiddirectLocation(double locX, double locY)Sets the location without setting the position to Position.FREEvoiddraw(java.awt.Graphics2D graphics)Draw this component only.java.awt.geom.Rectangle2DgetBounds()Returns the paper bounds relative to its location.intgetColumns()Returns the number of columns in the legend item.HAligngetHAlign()Get the horizontal alignment.java.lang.StringgetId()Returns the id string of this elementInvokeStepgetInvokeStepFormParent()Return the invoke step to get this object from its parent.LegendItemEx[]getItems()Returns all legend items managed by this legendjava.awt.geom.Point2DgetLocation()Gets the location of this legend.PlotExgetParent()Gets the parent of this component.LegendPositiongetPosition()Gets the current position of this legend.doublegetRowSpacingFactor()Returns the row spacing factor.java.awt.geom.Dimension2DgetSize()Returns the paper size of this component.doublegetThickness()Returns the thickness of this legend.VAligngetVAlign()Get the vertical alignment.booleanisBorderVisible()Returnstrueif the legend border is visiblebooleanisEnabled()Returnstrueif this legend is enabled.voiditemContribitivityChanged(LegendItemImpl item)Called by a legend item to notify that the item's contributivity is changed.voiditemSizeChanged(LegendItemEx item)Called by a visible legend item to notify this legend that the item's size is changed.voiditemVisibilityChanged(LegendItemImpl item)Called by a legend item to notify this legend that the item's visibility is changed.voidputItemsToEnabledLegend()Put all items in this disabled legend to enabled upper legendvoidremoveLegendItem(LegendItemEx item)Remove the given item from this legend.voidsetBorderVisible(boolean visible)Sets if the legend border is visible.voidsetColumns(int columns)Sets the number of columns.voidsetEnabled(boolean enabled)Set totrueto let this legend to host items.voidsetHAlign(HAlign halign)Set the horizontal alignment.voidsetLocation(double locX, double locY)Moves this legend to a new location.voidsetLocation(java.awt.geom.Point2D loc)Moves this legend to a new location.voidsetPosition(LegendPosition position)Sets the position of this legend.voidsetRowSpacingFactor(double factor)Sets the row spacing factor.voidsetVAlign(VAlign valign)Set the vertical alignment.voidsetVisible(boolean visible)Shows or hides this component depending on the value of parameterb.voidthisEffectiveColorChanged()Called when setColor() or parentEffectiveColorChanged() change the effective color of this component.voidthisEffectiveFontChanged()Called when setFontXxx() or parentEffectiveFontChanged() change the effective font of this component.-
Methods inherited from class org.jplot2d.element.impl.ComponentImpl
addPropertyChangeListener, copyStructure, getColor, getEffectiveColor, getEffectiveFont, getEffectiveFontName, getEffectiveFontSize, getEffectiveFontStyle, getFontName, getFontScale, getFontSize, getFontStyle, getMooringMap, getPaperTransform, getSelectableBounds, getZOrder, isCacheable, isMovable, isRedrawNeeded, isSelectable, isVisible, parentEffectiveColorChanged, parentEffectiveFontChanged, removePropertyChangeListener, setCacheable, setColor, setFont, setFontName, setFontScale, setFontSize, setFontStyle, setMovable, setRedrawNeeded, setSelectable, setZOrder
-
Methods inherited from class org.jplot2d.element.impl.ElementImpl
getEnvironment, getFullId, notify, setParent, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jplot2d.element.Legend
isMovable, setMovable
-
Methods inherited from interface org.jplot2d.element.PComponent
getColor, getEffectiveFont, getFontName, getFontScale, getFontSize, getFontStyle, getPaperTransform, getSelectableBounds, getZOrder, isCacheable, isSelectable, isVisible, setCacheable, setColor, setFont, setFontName, setFontScale, setFontSize, setFontStyle, setSelectable, setZOrder
-
Methods inherited from interface org.jplot2d.element.Element
getEnvironment
-
Methods inherited from interface org.jplot2d.element.impl.ComponentEx
copyStructure, getEffectiveColor, getEffectiveFontName, getEffectiveFontSize, getEffectiveFontStyle, getMooringMap, isMovable, isRedrawNeeded, parentEffectiveColorChanged, parentEffectiveFontChanged, setMovable, setRedrawNeeded
-
-
-
-
Method Detail
-
getId
public java.lang.String getId()
Description copied from interface:ElementReturns the id string of this element
-
getInvokeStepFormParent
public InvokeStep getInvokeStepFormParent()
Description copied from interface:ElementExReturn the invoke step to get this object from its parent.- Specified by:
getInvokeStepFormParentin interfaceElementEx- Returns:
- the invoke step
-
getParent
public PlotEx getParent()
Description copied from interface:ElementGets the parent of this component.- Specified by:
getParentin interfaceElement- Specified by:
getParentin interfaceComponentEx- Specified by:
getParentin interfaceElementEx- Specified by:
getParentin interfaceLegendEx- Specified by:
getParentin interfacePComponent- Overrides:
getParentin classComponentImpl- Returns:
- the parent of this component
-
canContribute
public boolean canContribute()
Description copied from interface:ComponentExReturnstrueif this component can contribute visible parts to plot rendering artifact when this component is visible. Subcomponents are not considered.- Specified by:
canContributein interfaceComponentEx- Overrides:
canContributein classComponentImpl- Returns:
- the indicator
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:PComponentShows or hides this component depending on the value of parameterb.- Specified by:
setVisiblein interfacePComponent- Overrides:
setVisiblein classComponentImpl- Parameters:
visible- iftrue, shows this component; otherwise, hides this component- See Also:
PComponent.isVisible()
-
thisEffectiveColorChanged
public void thisEffectiveColorChanged()
Description copied from interface:ComponentExCalled when setColor() or parentEffectiveColorChanged() change the effective color of this component.- Specified by:
thisEffectiveColorChangedin interfaceComponentEx
-
thisEffectiveFontChanged
public void thisEffectiveFontChanged()
Description copied from interface:ComponentExCalled when setFontXxx() or parentEffectiveFontChanged() change the effective font of this component.- Specified by:
thisEffectiveFontChangedin interfaceComponentEx
-
getSize
public java.awt.geom.Dimension2D getSize()
Description copied from interface:PComponentReturns the paper size of this component.- Specified by:
getSizein interfacePComponent- Returns:
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Description copied from interface:PComponentReturns the paper bounds relative to its location. The units of bounds is pt (1/72 inch)- Specified by:
getBoundsin interfacePComponent- Overrides:
getBoundsin classComponentImpl- Returns:
- the paper bounds of this component.
-
getLocation
public java.awt.geom.Point2D getLocation()
Description copied from interface:LegendGets the location of this legend.- Specified by:
getLocationin interfaceLegend- Specified by:
getLocationin interfacePComponent- Returns:
- an instance of
Pointrepresenting the base point of this legend
-
setLocation
public void setLocation(java.awt.geom.Point2D loc)
Description copied from interface:LegendMoves this legend to a new location. Setting legend to a new location will change legend position toLegendPosition.FREE- Specified by:
setLocationin interfaceLegend- Specified by:
setLocationin interfaceMovableComponent- Parameters:
loc- the base point of this legend
-
setLocation
public void setLocation(double locX, double locY)Description copied from interface:LegendMoves this legend to a new location. Setting legend to a new location will change legend position toLegendPosition.FREE- Specified by:
setLocationin interfaceLegend- Specified by:
setLocationin interfaceMovableComponent- Parameters:
locX- the x-coordinate of the new locationlocY- the y-coordinate of the new location
-
directLocation
public void directLocation(double locX, double locY)Description copied from interface:LegendExSets the location without setting the position to Position.FREE- Specified by:
directLocationin interfaceLegendEx
-
getPosition
public LegendPosition getPosition()
Description copied from interface:LegendGets the current position of this legend.- Specified by:
getPositionin interfaceLegend- Returns:
- the position.
-
setPosition
public void setPosition(LegendPosition position)
Description copied from interface:LegendSets the position of this legend. Only when position isLegendPosition.FREE, the legend can be located byLegend.setLocation(Point2D),#setHAlign(),#setVAlign().- Specified by:
setPositionin interfaceLegend- Parameters:
position- the position of this legend.
-
getHAlign
public HAlign getHAlign()
Description copied from interface:LegendGet the horizontal alignment.
-
setHAlign
public void setHAlign(HAlign halign)
Description copied from interface:LegendSet the horizontal alignment. The alignment can be LEFT, CENTER, or RIGHT. eg, LEFT means the base point is on the left of this legend.Notice: This method should be called when the position is
LegendPosition.FREE, otherwise the behavior is not defined.
-
getVAlign
public VAlign getVAlign()
Description copied from interface:LegendGet the vertical alignment.
-
setVAlign
public void setVAlign(VAlign valign)
Description copied from interface:LegendSet the vertical alignment. The alignment can be TOP, MIDDLE, or BOTTOM. eg, TOP means the base point is on the top of this legend.Notice: This method should be called when the position is
LegendPosition.FREE, otherwise the behavior is not defined.
-
isEnabled
public boolean isEnabled()
Description copied from interface:LegendReturnstrueif this legend is enabled. By default, the legend is enabled.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:LegendSet totrueto let this legend to host items. Otherwise the items will be displayed in parent legend. The disabled legend will not show.- Specified by:
setEnabledin interfaceLegend
-
putItemsToEnabledLegend
public void putItemsToEnabledLegend()
Description copied from interface:LegendExPut all items in this disabled legend to enabled upper legend- Specified by:
putItemsToEnabledLegendin interfaceLegendEx
-
getColumns
public int getColumns()
Description copied from interface:LegendReturns the number of columns in the legend item.- Specified by:
getColumnsin interfaceLegend- Returns:
- the number of columns
-
setColumns
public void setColumns(int columns)
Description copied from interface:LegendSets the number of columns. This method only take effect when position isLegendPosition.FREE. Otherwise the columns is auto selected.- Specified by:
setColumnsin interfaceLegend
-
getRowSpacingFactor
public double getRowSpacingFactor()
Description copied from interface:LegendReturns the row spacing factor. The row spacing is factor * row height.- Specified by:
getRowSpacingFactorin interfaceLegend- Returns:
- the row spacing factor
-
setRowSpacingFactor
public void setRowSpacingFactor(double factor)
Description copied from interface:LegendSets the row spacing factor. The row spacing is factor * row height. The default factor is 0.125- Specified by:
setRowSpacingFactorin interfaceLegend- Parameters:
factor- the row spacing factor
-
isBorderVisible
public boolean isBorderVisible()
Description copied from interface:LegendReturnstrueif the legend border is visible- Specified by:
isBorderVisiblein interfaceLegend- Returns:
trueif the legend border is visible
-
setBorderVisible
public void setBorderVisible(boolean visible)
Description copied from interface:LegendSets if the legend border is visible. By default, the legend border is visible.- Specified by:
setBorderVisiblein interfaceLegend- Parameters:
visible- the flag to indicate if the legend border is visible
-
getItems
public LegendItemEx[] getItems()
Description copied from interface:LegendExReturns all legend items managed by this legend
-
addLegendItem
public void addLegendItem(LegendItemEx item)
Description copied from interface:LegendExAdd the given item to this legend. If this legend is disabled, the item should be added to its upper level legend. This method will set the legend property of added legend item to the actual hosting legend.- Specified by:
addLegendItemin interfaceLegendEx- Parameters:
item- the legend item to be added
-
removeLegendItem
public void removeLegendItem(LegendItemEx item)
Description copied from interface:LegendExRemove the given item from this legend. If this legend is disabled, the item should be removed from its upper level legend.- Specified by:
removeLegendItemin interfaceLegendEx- Parameters:
item- the legend item to be removed
-
itemVisibilityChanged
public void itemVisibilityChanged(LegendItemImpl item)
Description copied from interface:LegendExCalled by a legend item to notify this legend that the item's visibility is changed. An item is shown when both visibility and contributivity aretrue.- Specified by:
itemVisibilityChangedin interfaceLegendEx
-
itemContribitivityChanged
public void itemContribitivityChanged(LegendItemImpl item)
Description copied from interface:LegendExCalled by a legend item to notify that the item's contributivity is changed. An item is shown when both visibility and contributivity aretrue.- Specified by:
itemContribitivityChangedin interfaceLegendEx
-
itemSizeChanged
public void itemSizeChanged(LegendItemEx item)
Description copied from interface:LegendExCalled by a visible legend item to notify this legend that the item's size is changed.- Specified by:
itemSizeChangedin interfaceLegendEx
-
copyFrom
public void copyFrom(ElementEx src)
Description copied from interface:ElementExCopies all properties from given src to this element. Notice properties of sub-elements are not copied over.- Specified by:
copyFromin interfaceElementEx- Overrides:
copyFromin classComponentImpl- Parameters:
src- the src
-
getThickness
public double getThickness()
Description copied from interface:LegendExReturns the thickness of this legend. When position is on top or bottom, thickness is its height. When position is on left or right, thickness is its width.- Specified by:
getThicknessin interfaceLegendEx- Returns:
- the thickness of this legend
-
calcSize
public void calcSize()
Description copied from interface:LegendExCalculate size of this legend and re-layout legend items. This method is always called by plot when committing changes.
-
draw
public void draw(java.awt.Graphics2D graphics)
Description copied from interface:ComponentExDraw this component only. All its children is not drawn.- Specified by:
drawin interfaceComponentEx- Parameters:
graphics- to the Graphics2D drawing. The transformation of this component is not applied.
-
-
DMelt 3.0 © DataMelt by jWork.ORG