- java.lang.Object
-
- com.flexganttfx.view.graphics.renderer.RendererBase
-
- Direct Known Subclasses:
LinkRenderer
,Renderer
,SystemLayer
public abstract class RendererBase extends Object
The base class of all renderers used by FlexGanttFX.
-
-
Constructor Summary
Constructors Constructor Description RendererBase(GraphicsBase<?> graphics, String name)
Constructs a new renderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleProperty
alphaProperty()
protected void
disableRedrawAfterPropertyChange()
Disables automatic redrawing of the graphics area when one of the observed properties changes.BooleanProperty
enabledProperty()
protected void
enableRedrawAfterPropertyChange()
Enabled automatic redrawing of the graphics area when one of the observed properties changes.double
getAlpha()
GraphicsBase<?>
getGraphics()
protected double
getLocation(Instant time, Canvas canvas)
Calculates the x coordinate for the given time.String
getName()
protected Instant
getTimeAt(double location)
Calculates the time at the given x coordinate.boolean
isEnabled()
boolean
isSnapToPixel()
protected void
redrawObservable(Observable observable)
Registers the given observable as something that requires a redraw of the graphics area.void
setAlpha(double alpha)
void
setEnabled(boolean enabled)
void
setSnapToPixel(boolean snap)
double
snapPositionX(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the horizontal direction, else returns the same value.double
snapPositionY(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the vertical direction, else returns the same value.double
snapSizeX(double value)
If this renderer's snapToPixel property is true, returns a value ceiled to the nearest pixel in the horizontal direction, else returns the same value.double
snapSizeY(double value)
If this renderer's snapToPixel property is true, returns a value ceiled to the nearest pixel in the vertical direction, else returns the same value.double
snapSpaceX(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the horizontal direction, else returns the same value.double
snapSpaceY(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the vertical direction, else returns the same value.BooleanProperty
snapToPixelProperty()
-
-
-
Constructor Detail
-
RendererBase
public RendererBase(GraphicsBase<?> graphics, String name)
Constructs a new renderer.- Parameters:
graphics
- the graphics control where the renderer will be usedname
- the name of the renderer (useful for tooling)
-
-
Method Detail
-
snapSpaceX
public double snapSpaceX(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the horizontal direction, else returns the same value.- Parameters:
value
- the space value to be snapped- Returns:
- value rounded to nearest pixel
-
snapSpaceY
public double snapSpaceY(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the vertical direction, else returns the same value.- Parameters:
value
- the space value to be snapped- Returns:
- value rounded to nearest pixel
-
snapSizeX
public double snapSizeX(double value)
If this renderer's snapToPixel property is true, returns a value ceiled to the nearest pixel in the horizontal direction, else returns the same value.- Parameters:
value
- the size value to be snapped- Returns:
- value ceiled to nearest pixel
-
snapSizeY
public double snapSizeY(double value)
If this renderer's snapToPixel property is true, returns a value ceiled to the nearest pixel in the vertical direction, else returns the same value.- Parameters:
value
- the size value to be snapped- Returns:
- value ceiled to nearest pixel
-
snapPositionX
public double snapPositionX(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the horizontal direction, else returns the same value.- Parameters:
value
- the position value to be snapped- Returns:
- value rounded to nearest pixel
-
snapPositionY
public double snapPositionY(double value)
If this renderer's snapToPixel property is true, returns a value rounded to the nearest pixel in the vertical direction, else returns the same value.- Parameters:
value
- the position value to be snapped- Returns:
- value rounded to nearest pixel
-
disableRedrawAfterPropertyChange
protected final void disableRedrawAfterPropertyChange()
Disables automatic redrawing of the graphics area when one of the observed properties changes. Useful for not going into infinite loops.
-
enableRedrawAfterPropertyChange
protected final void enableRedrawAfterPropertyChange()
Enabled automatic redrawing of the graphics area when one of the observed properties changes. Useful for not going into infinite loops.
-
redrawObservable
protected void redrawObservable(Observable observable)
Registers the given observable as something that requires a redraw of the graphics area. E.g.: the stroke color has changed.- Parameters:
observable
- the observable to monitor for changes
-
getName
public final String getName()
-
getGraphics
public final GraphicsBase<?> getGraphics()
-
getLocation
protected final double getLocation(Instant time, Canvas canvas)
Calculates the x coordinate for the given time. This method only returns valid results when the renderers is used in a layout with horizontal orientation. It will not work inAgendaLayout
.- Parameters:
time
- the time for which to calculate the x coordinate- Returns:
- the location of the given time point
- Since:
- 1.0
- See Also:
TimelineModel.calculateLocationForTime(Instant)
-
getTimeAt
protected final Instant getTimeAt(double location)
Calculates the time at the given x coordinate. This method only returns valid results when the renderer is used in a layout with horizontal orientation. It will not work inAgendaLayout
.- Parameters:
location
- the location for which to return the time- Returns:
- the time at the given x coordinate
- Since:
- 1.0
- See Also:
TimelineModel.calculateTimeForLocation(double)
-
enabledProperty
public final BooleanProperty enabledProperty()
-
isEnabled
public final boolean isEnabled()
-
setEnabled
public final void setEnabled(boolean enabled)
-
snapToPixelProperty
public final BooleanProperty snapToPixelProperty()
-
setSnapToPixel
public final void setSnapToPixel(boolean snap)
-
isSnapToPixel
public final boolean isSnapToPixel()
-
alphaProperty
public final DoubleProperty alphaProperty()
-
setAlpha
public final void setAlpha(double alpha)
-
getAlpha
public final double getAlpha()
-
-