|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ucar.unidata.ui.colortable.ColorTableCanvas
public class ColorTableCanvas
This class provides the guts of the color table editor. The actual ColorTableCanvas is a JPanel that draws the color bar in the editor. This class also provides the gui components that are wrapped the canvas itself.
| Nested Class Summary | |
|---|---|
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 |
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static Cursor |
normalCursor
The normal cursor_ |
static Cursor |
paintCursor
_more_ |
static String |
PROP_CANCEL
Name of property for the property event listener when cancel was pressed |
static String |
PROP_CLOSE
Name of property for the property event listener when window was closed |
static String |
PROP_COLORTABLE
Name of property for the property event listener when color table has changed |
static String |
PROP_RANGE
Name of property for the property event listener when range has changed |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
ColorTableCanvas()
Create me |
|
ColorTableCanvas(ColorTableEditor editor,
ColorTable table)
Create me |
|
| Method Summary | |
|---|---|
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(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(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(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(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 |
Rectangle |
getColorBox()
Get the bounding box of the color box |
Rectangle |
getColorBox(Rectangle bounds)
Get the bounding box of the color box |
JPanel |
getContents()
Get the main GUI contents. |
ColorTable |
getCurrentColorTable()
Get the currently edited CT |
static Icon |
getIcon(ColorTable ct)
Create and return an ImageIcon that represents this color table. |
static Icon |
getIcon(ColorTable ct,
int width,
int height)
_more_ |
static Image |
getImage(ColorTable ct,
int width,
int height)
|
Cursor |
getPaintCursor()
Get the paint brush cursor |
boolean |
imageUpdate(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,
Color lowerColor,
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,
Color lowerColor,
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,
Color lowerColor,
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(MouseEvent event)
Is the mouse in the color box |
boolean |
isStandAlone()
Do we have listeners |
void |
keyPressed(KeyEvent e)
Catch the key pressed event |
void |
keyReleased(KeyEvent e)
Noop |
void |
keyTyped(KeyEvent e)
Noop |
void |
lockUnlockBreakpoint(ColorTable.Breakpoint bp)
change the lock status on the BP |
void |
mouseClicked(MouseEvent event)
Catch the event |
void |
mouseDragged(MouseEvent event)
The mouse was dragged |
void |
mouseEntered(MouseEvent e)
Noop |
void |
mouseExited(MouseEvent e)
Noop |
void |
mouseMoved(MouseEvent e)
Noop |
void |
mousePressed(MouseEvent event)
Mouse was pressed |
void |
mouseReleased(MouseEvent event)
Catch the event |
void |
newInterpolate(int colorSpace,
int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
|
void |
oldInterpolate(int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
|
void |
paint(Graphics g)
Paint |
void |
paintColors(Graphics g)
Paint the color box |
static void |
paintColors(Graphics g,
Rectangle box,
List<Color> colorList,
boolean doLines,
boolean doCheckerboard,
boolean doTransparency,
List<Float> scales)
|
static void |
paintColors(Graphics g,
Rectangle box,
List<Color> colorList,
boolean doLines,
boolean doCheckerboard,
List<Float> scales)
Paint the color box |
void |
paintInner(Graphics g)
Really paint |
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(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(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(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 |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_COLORTABLE
public static final String PROP_RANGE
public static final String PROP_CANCEL
public static final String PROP_CLOSE
public static final Cursor normalCursor
public static Cursor paintCursor
| Constructor Detail |
|---|
public ColorTableCanvas()
public ColorTableCanvas(ColorTableEditor editor,
ColorTable table)
editor - The editor I am part oftable - The color table to edit| Method Detail |
|---|
public void init(ColorTable newTable)
newTable - The color table to editpublic void setColorTable(ColorTable newTable)
newTable - The new tablepublic JPanel getContents()
public void setTransparency()
public void setName(String name)
setName in class Componentname - The nameprotected void setMinMax()
protected void setRange(double min,
double max)
min - Range minmax - Range maxpublic void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener in class Containerlistener - 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 add
public void removeColor(boolean start,
int cnt)
start - At start or endcnt - How many to removepublic void keyPressed(KeyEvent e)
keyPressed in interface KeyListenere - The eventpublic void keyReleased(KeyEvent e)
keyReleased in interface KeyListenere - The eventpublic void keyTyped(KeyEvent e)
keyTyped in interface KeyListenere - The eventpublic void mouseMoved(MouseEvent e)
mouseMoved in interface MouseMotionListenere - The eventpublic void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenere - The eventpublic void mouseExited(MouseEvent e)
mouseExited in interface MouseListenere - The eventpublic Cursor getPaintCursor()
public void checkCursor(MouseEvent e)
e - eventpublic boolean isInBox(MouseEvent event)
event - event
public boolean reallyInBox(MouseEvent event)
public void mousePressed(MouseEvent event)
mousePressed in interface MouseListenerevent - The eventpublic void mouseDragged(MouseEvent event)
mouseDragged in interface MouseMotionListenerevent - The eventpublic void mouseReleased(MouseEvent event)
mouseReleased in interface MouseListenerevent - The eventpublic void mouseClicked(MouseEvent event)
mouseClicked in interface MouseListenerevent - 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(Color c)
c - The colorpublic int boxWidth()
public double xToPercent(int x)
x - X location
public int percentToX(double percent)
percent - Percent along color box
public double percentToValue(double percent)
percent - Percent along the color box
public 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 breakpoint
public void interpolate(int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
lowerColorIndex - Where to startupperColorIndex - Where to endlowerColor - The lower colorupperColor - The upper color
public void newInterpolate(int colorSpace,
int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
public void oldInterpolate(int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
public void interpolateTrans(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
from - starting breakpointto - ending breakpoint
public void interpolateTrans(int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
lowerColorIndex - Where to startupperColorIndex - Where to endlowerColor - The lower colorupperColor - The upper color
public void interpolateBrightness(ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
from - starting breakpointto - ending breakpoint
public void interpolateBrightness(int lowerColorIndex,
int upperColorIndex,
Color lowerColor,
Color upperColor)
lowerColorIndex - Where to startupperColorIndex - Where to endlowerColor - The lower colorupperColor - The upper colorpublic void fillLeft()
public void fillRight()
public void fill(Color color,
ColorTable.Breakpoint from,
ColorTable.Breakpoint to)
color - The fill colorfrom - The lower endto - The upper endpublic void fillAll()
public void fillFromTo(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 BP
public 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 Rectangle getColorBox()
public Rectangle getColorBox(Rectangle bounds)
bounds - The bounds around the color box
public int percentToColorIndex(double percent)
percent - Percent along the color box
public Color percentToColor(double percent)
percent - Along color box
public void paintColors(Graphics g)
g - The graphics
public static void paintColors(Graphics g,
Rectangle box,
List<Color> colorList,
boolean doLines,
boolean doCheckerboard,
List<Float> scales)
g - The graphicsbox - _more_colorList - _more_doLines - _more_doCheckerboard - _more_scales - _more_
public static void paintColors(Graphics g,
Rectangle box,
List<Color> colorList,
boolean doLines,
boolean doCheckerboard,
boolean doTransparency,
List<Float> scales)
public void repaint()
repaint in class Componentpublic void paint(Graphics g)
paint in class JComponentg - The graphicspublic void paintInner(Graphics g)
g - The graphics
public boolean imageUpdate(Image img,
int flags,
int x,
int y,
int width,
int height)
imageUpdate in interface ImageObserverimageUpdate in class Componentimg - the imageflags - flagsx - x positiony - y positionwidth - widthheight - height
public static Icon getIcon(ColorTable ct)
ct - The CT
public static Icon getIcon(ColorTable ct,
int width,
int height)
ct - _more_width - _more_height - _more_
public static Image getImage(ColorTable ct,
int width,
int height)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||