|
||||||||||
| 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.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
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 |
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. |
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 |
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 |
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 |
paint(Graphics g)
Paint |
void |
paintColors(Graphics g)
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 |
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
| 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)