public class ColorTableCanvas
extends javax.swing.JPanel
implements java.awt.event.MouseMotionListener, java.awt.event.MouseListener, java.awt.event.KeyListener
Modifier and Type | Class and Description |
---|---|
static class |
ColorTableCanvas.CanvasCommand
Class CanvasCommand takes a snapshot of the state of the canvas
|
static class |
ColorTableCanvas.ColorListCommand
Class ColorListCommand
|
static class |
ColorTableCanvas.ColorTableCommand
Class ColorTableCommand is used when the CT is changed and we can undo it using
this class
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.awt.Cursor |
normalCursor
The normal cursor_
|
static java.awt.Cursor |
paintCursor
_more_
|
static java.lang.String |
PROP_CANCEL
Name of property for the property event listener when cancel was pressed
|
static java.lang.String |
PROP_CLOSE
Name of property for the property event listener when window was closed
|
static java.lang.String |
PROP_COLORTABLE
Name of property for the property event listener when color table has changed
|
static java.lang.String |
PROP_RANGE
Name of property for the property event listener when range has changed
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ColorTableCanvas()
Create me
|
ColorTableCanvas(ColorTableEditor editor,
ColorTable table)
Create me
|
Modifier and Type | Method and Description |
---|---|
void |
addBreakpointAtData()
Add a new breakpoint, prompting the user at what data value it shoudl be placed
|
void |
addBreakpointAtData(ColorTable.Breakpoint bp)
Add a new breakpoint the given index.
|
void |
addBreakpointBeginning()
Add BP at the start
|
void |
addBreakpointEnd()
Add BP at the end
|
void |
addColor(boolean start,
int cnt)
Add cnt number of color slots
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add the listener
|
int |
boxWidth()
What is the width of the color box
|
void |
brightAll()
Set the transparency between the 2 BPs
|
void |
brightLeft()
Set the transparency to the left of the current BP
|
void |
brightRight()
Set the transparency to the right of the current BP
|
void |
checkCursor(java.awt.event.MouseEvent e)
set the cursor
|
void |
colorsChanged()
The colors have changed.
|
void |
debug()
Debug println
|
void |
doApply()
Send the table and range changed events
|
void |
doCancel()
Cancel and send the cancel event
|
void |
doClose()
Send the close event
|
void |
fill(java.awt.Color color,
ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Fill with the given color between the 2 BPs.
|
void |
fillAll()
Fill with the given color between the 2 BPs.
|
void |
fillFromTo(java.awt.Color color,
int lowerIndex,
int upperIndex)
Fill with the given color between the 2 indices.
|
void |
fillLeft()
Fill to the left of the selected BP
|
void |
fillRight()
Fill to the right of the selected BP
|
java.awt.Rectangle |
getColorBox()
Get the bounding box of the color box
|
java.awt.Rectangle |
getColorBox(java.awt.Rectangle bounds)
Get the bounding box of the color box
|
javax.swing.JPanel |
getContents()
Get the main GUI contents.
|
ColorTable |
getCurrentColorTable()
Get the currently edited CT
|
static javax.swing.Icon |
getIcon(ColorTable ct)
Create and return an ImageIcon that represents this color table.
|
static javax.swing.Icon |
getIcon(ColorTable ct,
int width,
int height)
_more_
|
static java.awt.Image |
getImage(ColorTable ct,
int width,
int height) |
static java.awt.Image |
getImage(ColorTable ct,
int width,
int height,
boolean includeAlpha) |
java.awt.Cursor |
getPaintCursor()
Get the paint brush cursor
|
boolean |
imageUpdate(java.awt.Image img,
int flags,
int x,
int y,
int width,
int height)
Image update method
|
void |
init(ColorTable newTable)
Init me
|
void |
insertBreakpoint(double percent)
Insert a new BP at percent along the line
|
void |
interpolate(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Do a linear interpolation of the colors in the range defined
by the given breakpoints.
|
void |
interpolate(int lowerColorIndex,
int upperColorIndex,
java.awt.Color lowerColor,
java.awt.Color upperColor)
Do a linear interpolation between the given colors
|
void |
interpolateAll()
Interpolate color from end to end
|
void |
interpolateBrightness(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Do a linear interpolation of the colors in the range defined
by the given breakpoints.
|
void |
interpolateBrightness(int lowerColorIndex,
int upperColorIndex,
java.awt.Color lowerColor,
java.awt.Color upperColor)
Do a linear interpolation of transparency between the given colors
|
void |
interpolateBrightnessAll()
Interpolate transparency from end to end
|
void |
interpolateBrightnessLeft()
Interpolate transparency left
|
void |
interpolateBrightnessRight()
Interpolate transparency right
|
void |
interpolateLeft()
Interpolate color left
|
void |
interpolateRight()
Interpolate color right
|
void |
interpolateTrans(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Do a linear interpolation of the colors in the range defined
by the given breakpoints.
|
void |
interpolateTrans(int lowerColorIndex,
int upperColorIndex,
java.awt.Color lowerColor,
java.awt.Color upperColor)
Do a linear interpolation of transparency between the given colors
|
void |
interpolateTransAll()
Interpolate transparency from end to end
|
void |
interpolateTransLeft()
Interpolate transparency left
|
void |
interpolateTransRight()
Interpolate transparency right
|
void |
invert()
invert the color table
|
boolean |
isInBox(java.awt.event.MouseEvent event)
Is the mouse in the color box
|
boolean |
isStandAlone()
Do we have listeners
|
void |
keyPressed(java.awt.event.KeyEvent e)
Catch the key pressed event
|
void |
keyReleased(java.awt.event.KeyEvent e)
Noop
|
void |
keyTyped(java.awt.event.KeyEvent e)
Noop
|
void |
lockUnlockBreakpoint(ColorTable.Breakpoint bp)
change the lock status on the BP
|
void |
mouseClicked(java.awt.event.MouseEvent event)
Catch the event
|
void |
mouseDragged(java.awt.event.MouseEvent event)
The mouse was dragged
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Noop
|
void |
mouseExited(java.awt.event.MouseEvent e)
Noop
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Noop
|
void |
mousePressed(java.awt.event.MouseEvent event)
Mouse was pressed
|
void |
mouseReleased(java.awt.event.MouseEvent event)
Catch the event
|
void |
newInterpolate(int colorSpace,
int lowerColorIndex,
int upperColorIndex,
java.awt.Color lowerColor,
java.awt.Color upperColor) |
void |
oldInterpolate(int lowerColorIndex,
int upperColorIndex,
java.awt.Color lowerColor,
java.awt.Color upperColor) |
void |
paint(java.awt.Graphics g)
Paint
|
void |
paintColors(java.awt.Graphics g)
Paint the color box
|
static void |
paintColors(java.awt.Graphics g,
java.awt.Rectangle box,
java.util.List<java.awt.Color> colorList,
boolean doLines,
boolean doCheckerboard,
boolean doTransparency,
java.util.List<java.lang.Float> scales) |
static void |
paintColors(java.awt.Graphics g,
java.awt.Rectangle box,
java.util.List<java.awt.Color> colorList,
boolean doLines,
boolean doCheckerboard,
java.util.List<java.lang.Float> scales)
Paint the color box
|
void |
paintInner(java.awt.Graphics g)
Really paint
|
java.awt.Color |
percentToColor(double percent)
Map the percent along the color box to the color
|
int |
percentToColorIndex(double percent)
Map percent along the color box to the index in the color list
|
double |
percentToValue(double percent)
Get the value of the point percent along the color box
|
int |
percentToX(double percent)
Map percent along color box to x location
|
void |
rangeChanged()
Propagate the range changed event
|
boolean |
reallyInBox(java.awt.event.MouseEvent event) |
void |
removeBreakpoint()
Remove the currently selected BP
|
void |
removeColor(boolean start,
int cnt)
Remove cnt number of color slots
|
void |
repaint()
Repaint
|
void |
replicate()
replicate
|
void |
setBrightness(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Set the transparency between the 2 BPs
|
void |
setBrightnessFromTo(int lowerIndex,
int upperIndex)
Set the transparency between the 2 indices
|
void |
setColor(java.awt.Color c)
Set the color at the current BP
|
void |
setColorTable(ColorTable newTable)
GOt a new colortable
|
protected void |
setMinMax()
Set the range from the text fields
|
void |
setName(java.lang.String name)
Set the name of the CT
|
void |
setPropagateChanges(boolean v)
Should we propagate changes
|
protected void |
setRange(double min,
double max)
Set the range
|
void |
setTransparency()
Set the transparency on the currently selected breakpoint
|
void |
setTransparency(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
Set the transparency between the 2 BPs
|
void |
setTransparencyFromTo(int lowerIndex,
int upperIndex)
Set the transparency between the 2 indices
|
void |
tableChanged()
Propagate the table changed event
|
void |
tableChanged(boolean force)
Propagate the table changed event
|
void |
transAll()
Set the transparency between the 2 BPs
|
void |
transLeft()
Set the transparency to the left of the current BP
|
void |
transRight()
Set the transparency to the right of the current BP
|
double |
xToPercent(int x)
Map x location to percent along color box
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String PROP_COLORTABLE
public static final java.lang.String PROP_RANGE
public static final java.lang.String PROP_CANCEL
public static final java.lang.String PROP_CLOSE
public static final java.awt.Cursor normalCursor
public static java.awt.Cursor paintCursor
public ColorTableCanvas()
public ColorTableCanvas(ColorTableEditor editor, ColorTable table)
editor
- The editor I am part oftable
- The color table to editpublic void init(ColorTable newTable)
newTable
- The color table to editpublic void setColorTable(ColorTable newTable)
newTable
- The new tablepublic javax.swing.JPanel getContents()
public void setTransparency()
public void setName(java.lang.String name)
setName
in class java.awt.Component
name
- The nameprotected void setMinMax()
protected void setRange(double min, double max)
min
- Range minmax
- Range maxpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in class java.awt.Container
listener
- The listenerpublic boolean isStandAlone()
public ColorTable getCurrentColorTable()
public void doClose()
public void doApply()
public void doCancel()
public void tableChanged()
public void tableChanged(boolean force)
force
- If true then send the change no matter whatpublic void rangeChanged()
public void setPropagateChanges(boolean v)
v
- The flagpublic void colorsChanged()
public void addColor(boolean start, int cnt)
start
- At start or endcnt
- How many to addpublic void removeColor(boolean start, int cnt)
start
- At start or endcnt
- How many to removepublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
e
- The eventpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
e
- The eventpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
e
- The eventpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- The eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- The eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- The eventpublic java.awt.Cursor getPaintCursor()
public void checkCursor(java.awt.event.MouseEvent e)
e
- eventpublic boolean isInBox(java.awt.event.MouseEvent event)
event
- eventpublic boolean reallyInBox(java.awt.event.MouseEvent event)
public void mousePressed(java.awt.event.MouseEvent event)
mousePressed
in interface java.awt.event.MouseListener
event
- The eventpublic void mouseDragged(java.awt.event.MouseEvent event)
mouseDragged
in interface java.awt.event.MouseMotionListener
event
- The eventpublic void mouseReleased(java.awt.event.MouseEvent event)
mouseReleased
in interface java.awt.event.MouseListener
event
- The eventpublic void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked
in interface java.awt.event.MouseListener
event
- The eventpublic void addBreakpointAtData()
public void addBreakpointAtData(ColorTable.Breakpoint bp)
bp
- the sample breakpointpublic void insertBreakpoint(double percent)
percent
- Where to insertpublic void debug()
public void removeBreakpoint()
public void lockUnlockBreakpoint(ColorTable.Breakpoint bp)
bp
- the breakpoint to lock/unlockpublic void addBreakpointBeginning()
public void addBreakpointEnd()
public void setColor(java.awt.Color c)
c
- The colorpublic int boxWidth()
public double xToPercent(int x)
x
- X locationpublic int percentToX(double percent)
percent
- Percent along color boxpublic double percentToValue(double percent)
percent
- Percent along the color boxpublic void interpolateAll()
public void interpolateLeft()
public void interpolateRight()
public void interpolateTransAll()
public void interpolateTransLeft()
public void interpolateTransRight()
public void interpolateBrightnessAll()
public void interpolateBrightnessLeft()
public void interpolateBrightnessRight()
public void replicate()
public void invert()
public void interpolate(ColorTable.Breakpoint from, ColorTable.Breakpoint to)
from
- starting breakpointto
- ending breakpointpublic void interpolate(int lowerColorIndex, int upperColorIndex, java.awt.Color lowerColor, java.awt.Color upperColor)
lowerColorIndex
- Where to startupperColorIndex
- Where to endlowerColor
- The lower colorupperColor
- The upper colorpublic void newInterpolate(int colorSpace, int lowerColorIndex, int upperColorIndex, java.awt.Color lowerColor, java.awt.Color upperColor)
public void oldInterpolate(int lowerColorIndex, int upperColorIndex, java.awt.Color lowerColor, java.awt.Color upperColor)
public void interpolateTrans(ColorTable.Breakpoint from, ColorTable.Breakpoint to)
from
- starting breakpointto
- ending breakpointpublic void interpolateTrans(int lowerColorIndex, int upperColorIndex, java.awt.Color lowerColor, java.awt.Color upperColor)
lowerColorIndex
- Where to startupperColorIndex
- Where to endlowerColor
- The lower colorupperColor
- The upper colorpublic void interpolateBrightness(ColorTable.Breakpoint from, ColorTable.Breakpoint to)
from
- starting breakpointto
- ending breakpointpublic void interpolateBrightness(int lowerColorIndex, int upperColorIndex, java.awt.Color lowerColor, java.awt.Color upperColor)
lowerColorIndex
- Where to startupperColorIndex
- Where to endlowerColor
- The lower colorupperColor
- The upper colorpublic void fillLeft()
public void fillRight()
public void fill(java.awt.Color color, ColorTable.Breakpoint from, ColorTable.Breakpoint to)
color
- The fill colorfrom
- The lower endto
- The upper endpublic void fillAll()
public void fillFromTo(java.awt.Color color, int lowerIndex, int upperIndex)
color
- The fill colorlowerIndex
- The lower indexupperIndex
- The upper indexpublic void transLeft()
public void transRight()
public void transAll()
public void setTransparency(ColorTable.Breakpoint from, ColorTable.Breakpoint to)
from
- The lower BPto
- The upper BPpublic void setTransparencyFromTo(int lowerIndex, int upperIndex)
lowerIndex
- The lower indexupperIndex
- The upper indexpublic void brightLeft()
public void brightRight()
public void setBrightness(ColorTable.Breakpoint from, ColorTable.Breakpoint to)
from
- The lower BPto
- The upper BPpublic void brightAll()
public void setBrightnessFromTo(int lowerIndex, int upperIndex)
lowerIndex
- The lower indexupperIndex
- The upper indexpublic java.awt.Rectangle getColorBox()
public java.awt.Rectangle getColorBox(java.awt.Rectangle bounds)
bounds
- The bounds around the color boxpublic int percentToColorIndex(double percent)
percent
- Percent along the color boxpublic java.awt.Color percentToColor(double percent)
percent
- Along color boxpublic void paintColors(java.awt.Graphics g)
g
- The graphicspublic static void paintColors(java.awt.Graphics g, java.awt.Rectangle box, java.util.List<java.awt.Color> colorList, boolean doLines, boolean doCheckerboard, java.util.List<java.lang.Float> scales)
g
- The graphicsbox
- _more_colorList
- _more_doLines
- _more_doCheckerboard
- _more_scales
- _more_public static void paintColors(java.awt.Graphics g, java.awt.Rectangle box, java.util.List<java.awt.Color> colorList, boolean doLines, boolean doCheckerboard, boolean doTransparency, java.util.List<java.lang.Float> scales)
public void repaint()
repaint
in class java.awt.Component
public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
g
- The graphicspublic void paintInner(java.awt.Graphics g)
g
- The graphicspublic boolean imageUpdate(java.awt.Image img, int flags, int x, int y, int width, int height)
imageUpdate
in interface java.awt.image.ImageObserver
imageUpdate
in class java.awt.Component
img
- the imageflags
- flagsx
- x positiony
- y positionwidth
- widthheight
- heightpublic static javax.swing.Icon getIcon(ColorTable ct)
ct
- The CTpublic static javax.swing.Icon getIcon(ColorTable ct, int width, int height)
ct
- _more_width
- _more_height
- _more_public static java.awt.Image getImage(ColorTable ct, int width, int height)
public static java.awt.Image getImage(ColorTable ct, int width, int height, boolean includeAlpha)