Package org.eclipse.gef.fx.swt.controls

# Class FXAdvancedLinearGradientPicker

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.gef.fx.swt.controls.FXAdvancedLinearGradientPicker

All Implemented Interfaces:
  `Drawable`

public class FXAdvancedLinearGradientPicker extends Composite
A picker for multi-stop `LinearGradient`s.

## Property Summary

Properties
Type
Property
Description
`Property<LinearGradient>`
`advancedLinearGradient`
Returns a writable `Property` for the advanced gradient.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ADVANCED_LINEAR_GRADIENT_PROPERTY`
Property name used in change events related to `advancedLinearGradientProperty()`

### Fields inherited from class org.eclipse.swt.widgets.Control

`view`

## Constructor Summary

Constructors
Constructor
Description
`FXAdvancedLinearGradientPicker(Composite parent, Color color1, Color color2, Color color3)`
Constructs a new `FXAdvancedLinearGradientPicker`.

## Method Summary

Modifier and Type
Method
Description
`Property<LinearGradient>`
`advancedLinearGradientProperty()`
Returns a writable `Property` for the advanced gradient.
`static LinearGradient`
`createAdvancedLinearGradient(Color c1, Color c2, Color c3)`
Creates an "advanced" linear color gradient with 3 stops from the given colors.
`protected void`
`createStop(double offset)`
Creates a new spot for the given offset.
`LinearGradient`
`getAdvancedLinearGradient()`
Returns the currently selected advanced gradient.
`protected double`
`getNextOffset(int stopIndex)`
Computes the maximum offset for the given stop index.
`protected double`
`getPrevOffset(int stopIndex)`
Computes the minimum offset for the given stop index.
`protected List<Stop>`
`getStops()`
Returns a list of the `Stop`s of the currently selected advanced gradient.
`static boolean`
`isAdvancedLinearGradient(Paint paint)`
Returns `true` if the given `Paint` is considered to be an "advanced" gradient.
`protected void`
`removeStop(int index)`
Removes the spot specified by the given index.
`void`
`setAdvancedGradient(LinearGradient advancedLinearGradient)`
Sets the gradient managed by this gradient picker to the given value.
`protected void`
`updateDirectionLine()`
Updates the direction line to display the current direction (specified by directionX and directionY).
`protected void`
`updateGradient(List<Stop> newStops)`
Changes the currently selected advanced gradient to a new linear gradient that is constructed from the given list of `Stop`s.
`protected void`
`updateStop(int index, double offset, Color color)`
Sets the offset and color of the spot specified by the given index to the given values.

### Methods inherited from class org.eclipse.swt.widgets.Composite

`changed, checkSubclass, computeSize, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, redraw, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString`

### Methods inherited from class org.eclipse.swt.widgets.Scrollable

`computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar`

### Methods inherited from class org.eclipse.swt.widgets.Control

`addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update`

### Methods inherited from class org.eclipse.swt.widgets.Widget

`addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.swt.graphics.Drawable

`isAutoScalable`

## Property Details

### advancedLinearGradient

public Property<LinearGradient> advancedLinearGradientProperty
Returns a writable `Property` for the advanced gradient.

See Also:
  - `getAdvancedLinearGradient()`

## Field Details

### ADVANCED_LINEAR_GRADIENT_PROPERTY

public static final String ADVANCED_LINEAR_GRADIENT_PROPERTY
Property name used in change events related to `advancedLinearGradientProperty()`

See Also:
  - Constant Field Values

## Constructor Details

### FXAdvancedLinearGradientPicker

public FXAdvancedLinearGradientPicker(Composite parent, Color color1, Color color2, Color color3)
Constructs a new `FXAdvancedLinearGradientPicker`.

Parameters:
  `parent` - The parent `Composite`.
  `color1` - The first color of the initial three-stop `LinearGradient`.
  `color2` - The second color of the initial three-stop `LinearGradient`.
  `color3` - The third color of the initial three-stop `LinearGradient`.

## Method Details

### createAdvancedLinearGradient

public static LinearGradient createAdvancedLinearGradient(Color c1, Color c2, Color c3)
Creates an "advanced" linear color gradient with 3 stops from the given colors.

Parameters:
  `c1` - The start color.
  `c2` - The middle color (t = 0.5).
  `c3` - The end color.
Returns:
  An "advanced" `LinearGradient` from the given colors.

### isAdvancedLinearGradient

public static boolean isAdvancedLinearGradient(Paint paint)
Returns `true` if the given `Paint` is considered to be an "advanced" gradient. Otherwise returns `false`. An advanced gradient can either be a linear gradient with at least 3 stops, or any radial gradient.

Parameters:
  `paint` - The `Paint` in question.
Returns:
  `true` if the given `Paint` is considered to be an "advanced" gradient, othwerise `false`.

### advancedLinearGradientProperty

public Property<LinearGradient> advancedLinearGradientProperty()
Returns a writable `Property` for the advanced gradient.

See Also:
  - `getAdvancedLinearGradient()`

### createStop

protected void createStop(double offset)
Creates a new spot for the given offset.

Parameters:
  `offset` - The offset for the new spot.

### getAdvancedLinearGradient

public LinearGradient getAdvancedLinearGradient()
Returns the currently selected advanced gradient.

Returns:
  The currently selected advanced gradient.

### getNextOffset

protected double getNextOffset(int stopIndex)
Computes the maximum offset for the given stop index.

Parameters:
  `stopIndex` - The index of the stop for which to compute the next offset.
Returns:
  The maximum offset for the given stop index.

### getPrevOffset

protected double getPrevOffset(int stopIndex)
Computes the minimum offset for the given stop index.

Parameters:
  `stopIndex` - The index of the stop for which to compute the previous offset.
Returns:
  The minimum offset for the given stop index.

### getStops

protected List<Stop> getStops()
Returns a list of the `Stop`s of the currently selected advanced gradient.

Returns:
  A list of the `Stop`s of the currently selected advanced gradient.

### removeStop

protected void removeStop(int index)
Removes the spot specified by the given index.

Parameters:
  `index` - The spot index.

### setAdvancedGradient

public void setAdvancedGradient(LinearGradient advancedLinearGradient)
Sets the gradient managed by this gradient picker to the given value. Does also update the UI so that the new gradient can be manipulated.

Parameters:
  `advancedLinearGradient` - The new gradient.

### updateDirectionLine

protected void updateDirectionLine()
Updates the direction line to display the current direction (specified by directionX and directionY).

### updateGradient

protected void updateGradient(List<Stop> newStops)
Changes the currently selected advanced gradient to a new linear gradient that is constructed from the given list of `Stop`s.

Parameters:
  `newStops` - The list of `Stop`s from which the newly selected advanced gradient is constructed.

### updateStop

protected void updateStop(int index, double offset, Color color)
Sets the offset and color of the spot specified by the given index to the given values.

Parameters:
  `index` - The index of the spot.
  `offset` - The new offset for that spot.
  `color` - The new color for that spot.