Class LimitControlPanel
- All Implemented Interfaces:
InputObject
,Limits
,Tieable
,ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
A LimitControlPanel can also contain a number of standard buttons, such as buttons for zooming the coordinates in and out. The buttons are specfied using constants defined in this class. It is possible to obtain standard buttons so that they can be displayed outside the LimitControlPanel. Furthermore, it is also possible to add other components to the panel, using the addRange(), addComponent(), and addComponentPair() methods. (The standard add() method from the Component class is overridded to call addComponent().) Any VariableInput added to the LimitControl Panel will appear with its name as a label, just above the input box.
Ordinarily, all the components are just stacked up vertically. However, if you set the useTwoColumnsIfPossible property to true, then they will be in two columns, unless the width of the Panel is too small for two columns. Pairs of items added with addRange() or addComponentPair() will appear on the same row. An item added with addComponent() will appear on a row by itself. As for the standard buttons, the following pairs will appear together, IF they are added at the same time: SET_LIMITS and EQUALUIZE; ZOOM_IN and ZOOM_OUT; SAVE and RESTORE.
A LimitControlPanel can have an error reporter, which is used to report any errors that are found in the input boxes for xmin, xmax, ymin, ymax (or other VariableInputs added with addRange()). Except for these input boxes, other coponents are NOT checked for errors.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
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
FieldsModifier and TypeFieldDescriptionstatic final int
A constant that can be used in the addButton() method to add all possible buttons to the LimitControlPanel.protected int
Set of installed buttons.protected CoordinateRect
The first CoordinateRect tied to this LimitControlPanel.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.protected ErrorReporter
For reporting errors in user input.protected Vector
Vector of components and component pairs that have been added to this panel, including at least the xmin, xmax, ymin, ymax input boxes.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.protected long
This is increased when the user changes the limits.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.protected Tie
A Tie holding this panel and the CoordinateRects that it controls.protected boolean
Use two columns for display, if possible.protected VariableInput
The input boxes for the x- and y-value ranges.protected VariableInput
The input boxes for the x- and y-value ranges.protected VariableInput
The input boxes for the x- and y-value ranges.protected VariableInput
The input boxes for the x- and y-value ranges.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.static final int
A constant that can be used in the addButton() method to add a button to the LimitControlPanel.Fields inherited from class java.awt.Component
accessibleContext, 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
ConstructorsConstructorDescriptionCreate a LimitControlPanel containing input boxes labeled "xmin", "xmax", "ymin", "ymax" and a SET_LIMITS button.LimitControlPanel
(int buttonsToAdd, boolean useTwoColumnsIfPossible) Create a LimitControlPanel containing input boxes labeled "xmin", "xmax", "ymin", "ymax" and whatever buttons are in the set specified by the first parameter.LimitControlPanel
(String xminName, String xmaxName, String yminName, String ymaxName, int buttonsToAdd, boolean useTwoColumnsIfPossible) Create a LimitControlPanel containing input boxes labeled with the given names and containing whatever buttons are in the set buttonsToAdd. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Handle a click on one of the standard buttons.Redefine this method from the Component class to make it a synonym for addComponent(c);void
addButtons
(int buttonSet) Add the buttons in buttonSet to the panel, if they are not already there.void
Add a component to the panel.void
addComponentPair
(Component c1, Component c2) Add two components to the panel.void
addCoords
(CoordinateRect coords) Add a CoordinateRect to be controlled by this LimitControlPanel.void
addCoords
(DisplayCanvas canvas) Add the first CoordinateRect from the canvas to be controlled by this LimitControlPanel.void
addRange
(VariableInput v1, VariableInput v2) Add two VariableInputs to the panel.void
Check the input boxes in this panel.getButton
(int buttonCode) Get a Button corresponding to one of the six button types defined by the constants SET_LIMITS, EQUALIZE, ZOOM_IN, ZOOM_OUT, SAVE, and RESTORE in this class.Get the ErrorReporter that is used to report errors in the user's input.double[]
Get the values in the xmin, xmax, ymin, and ymax input boxes.Compute the preferred size of this panel.long
Part of the Tieable interface, and not meant to be called directly.boolean
Get the value of the "useTwoColumnsIfPossible" property of this panel.void
Method required by CheckInput interface.void
Draw the input box labels.void
Recompute component locations when the panel is resized.void
Set the ErrorReporter that is used to report errors in the user's input.void
setLimits
(double[] limits) Set the values in the xmin, xmax, ymin, and ymax input boxes.void
setUseTwoColumnsIfPossible
(boolean two) Set to true if you want the components to be shown in two columns (provided the panel is wide enough).void
Part of the Tieable interface, and not meant to be called directly.Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
SET_LIMITS
public static final int SET_LIMITSA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will set the limits using the values in the input boxes. (This is also done when the user presses return in one of the boxes.)- See Also:
-
EQUALIZE
public static final int EQUALIZEA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will equalize the scales on the axes (of the first CoordinateRect that was added to this panel).- See Also:
-
ZOOM_IN
public static final int ZOOM_INA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will zoom in on the center of the coordinate rect.- See Also:
-
ZOOM_OUT
public static final int ZOOM_OUTA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will zoom out from the center of the coordinate rect.- See Also:
-
SAVE
public static final int SAVEA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will save the current limits, so they can be restored later with the restore button.- See Also:
-
RESTORE
public static final int RESTOREA constant that can be used in the addButton() method to add a button to the LimitControlPanel. This represents a button that will restore previously saved coordinates. The coords are those that were saved with the save button, or if none were saved in that way, then the original coordinates that the CoordinateRect had when it was created.- See Also:
-
ALL_BUTTONS
public static final int ALL_BUTTONSA constant that can be used in the addButton() method to add all possible buttons to the LimitControlPanel.- See Also:
-
buttons
protected int buttonsSet of installed buttons. -
twoColumn
protected boolean twoColumnUse two columns for display, if possible. -
xmin
The input boxes for the x- and y-value ranges. -
xmax
The input boxes for the x- and y-value ranges. -
ymin
The input boxes for the x- and y-value ranges. -
ymax
The input boxes for the x- and y-value ranges. -
serialNumber
protected long serialNumberThis is increased when the user changes the limits. (The -1 will make this LimitControlPanel get its limits from the first CoordinateRect that is added to it.) This variable is used to implement syncronization of limits with the limits on CoordinateRects. -
syncWith
A Tie holding this panel and the CoordinateRects that it controls. -
errorReporter
For reporting errors in user input. -
coords
The first CoordinateRect tied to this LimitControlPanel. -
items
Vector of components and component pairs that have been added to this panel, including at least the xmin, xmax, ymin, ymax input boxes.
-
-
Constructor Details
-
LimitControlPanel
public LimitControlPanel()Create a LimitControlPanel containing input boxes labeled "xmin", "xmax", "ymin", "ymax" and a SET_LIMITS button. The components are shown in a single column. -
LimitControlPanel
public LimitControlPanel(int buttonsToAdd, boolean useTwoColumnsIfPossible) Create a LimitControlPanel containing input boxes labeled "xmin", "xmax", "ymin", "ymax" and whatever buttons are in the set specified by the first parameter.- Parameters:
buttonsToAdd
- The set of buttons to be added to the panel. Can consist of one or more of the constants SET_LIMITS, EQUALIZE, ZOOM_IN, ZOOM_OUT, SAVE, and RESTORE, or'ed together.useTwoColumnsIfPossible
- If this is true, then the components in the panel will be arranged into two columns instead of one (assuming that there is room).
-
LimitControlPanel
public LimitControlPanel(String xminName, String xmaxName, String yminName, String ymaxName, int buttonsToAdd, boolean useTwoColumnsIfPossible) Create a LimitControlPanel containing input boxes labeled with the given names and containing whatever buttons are in the set buttonsToAdd. buttonsToAdd should be formed by or-ing together constants such as SET_LIMITS from this class. The last parameter specifies whether to show the components in two columns.- Parameters:
xminName
- Name to be used as a label for the xmin input box.xmaxName
- Name to be used as a label for the xmax input box.yminName
- Name to be used as a label for the ymin input box.xmaxName
- Name to be used as a label for the ymax input box.buttonsToAdd
- The set of buttons to be added to the panel. Can consist of one or more of the constants SET_LIMITS, EQUALIZE, ZOOM_IN, ZOOM_OUT, SAVE, and RESTORE, or'ed together.useTwoColumnsIfPossible
- If this is true, then the components in the panel will be arranged into two columns instead of one (assuming that there is room).
-
-
Method Details
-
addCoords
Add a CoordinateRect to be controlled by this LimitControlPanel. When the user changes the limits in this LimitControlPanel, the limits are also changed on the CoordinateRect to match. If the limits on the CoordinateRect change for some other reason, then the limits in the panel are changed to match. If multiple CoordinateRects are added, the limits on all the CoordinateRects will be synchronized with each other and with the limits in the panel. -
addCoords
Add the first CoordinateRect from the canvas to be controlled by this LimitControlPanel. (Just calls addCoords(canvas.getCoordinateRect()).) -
setErrorReporter
Set the ErrorReporter that is used to report errors in the user's input. Note that only the input boxes for xmin, xmax, ymin, and ymax and any VariableInputs added with the addRange() method are checked. -
getErrorReporter
Get the ErrorReporter that is used to report errors in the user's input. Note that only the input boxes for xmin, xmax, ymin, and ymax and any VariableInputs added with the addRange() method are checked. -
setUseTwoColumnsIfPossible
public void setUseTwoColumnsIfPossible(boolean two) Set to true if you want the components to be shown in two columns (provided the panel is wide enough). -
getUseTwoColumnsIfPossible
public boolean getUseTwoColumnsIfPossible()Get the value of the "useTwoColumnsIfPossible" property of this panel. -
addComponent
Add a component to the panel. If two-column format is used, it will be shown on a line by itself. Note that the component shouldn't be too wide, or it will make the Panel stretch. This component is NOT checked for input errors. If it is an input object or a computable, it should be added to a Controller. For an input object, some Controller should be set up to be notified when the value changes. (You have to do this by hand, even if you use JCMPanels!!) -
addComponentPair
Add two components to the panel. If two-column format is used, they will be shown on the same row. Note that the components shouldn't be too wide, or they will make the Panel stretch. These components are NOT checked for input errors. If they are input objects or computables, they should be added to another Controller. For an input object, some Controller should be set up to be notified when the value changes. (You have to do this by hand, even if you use JCMPanels!!) -
addRange
Add two VariableInputs to the panel. These ARE checked for input when the user presses return or clicks the SET_LIMITS button. Furthermore, it is checked that the value in the second input box is greater than the value in the first, and an error is reported if it is not. This method is used to add the xmin, xmax, ymin, and ymax boxes. It could possibly be used to add tmin and tmax boxes for the limits on the parameter of a parametric curve, for example. -
addButtons
public void addButtons(int buttonSet) Add the buttons in buttonSet to the panel, if they are not already there. buttonSet should be formed by or-ing together some of the constants SET_LIMITS, ZOOM_IN, etc. -
getButton
Get a Button corresponding to one of the six button types defined by the constants SET_LIMITS, EQUALIZE, ZOOM_IN, ZOOM_OUT, SAVE, and RESTORE in this class. The button can be added to a different panel, but it will still affect this LimitControlPanel in the usual way. It is possible to change the name of the button, and it will still work correctly. Each call to this method creates a new button, even if multiple buttons of the same type are created.- Parameters:
buttonCode
- one of the constants from this class (SET_LIMITS, EQUALIZE, etc.) specifying one of the types of button for controlling limits. If the parameter is not one of these constants, and IllegalArgumentException will be thrown.
-
add
Redefine this method from the Component class to make it a synonym for addComponent(c); -
notifyControllerOnChange
Method required by CheckInput interface. In this class, it does nothing because responses to inputs are handled by the LimitControlPanel itself.- Specified by:
notifyControllerOnChange
in interfaceInputObject
-
checkInput
public void checkInput()Check the input boxes in this panel. This is generally not meant to be called from outside this class, except by a Controller.- Specified by:
checkInput
in interfaceInputObject
-
getSerialNumber
public long getSerialNumber()Part of the Tieable interface, and not meant to be called directly.- Specified by:
getSerialNumber
in interfaceTieable
-
sync
Part of the Tieable interface, and not meant to be called directly. -
getLimits
public double[] getLimits()Get the values in the xmin, xmax, ymin, and ymax input boxes. Note that this can throw a JCMError. -
setLimits
public void setLimits(double[] limits) Set the values in the xmin, xmax, ymin, and ymax input boxes. -
actionPerformed
Handle a click on one of the standard buttons. Not meant to be called directly.- Specified by:
actionPerformed
in interfaceActionListener
-
paint
Draw the input box labels. Not meant to be called directly. -
getPreferredSize
Compute the preferred size of this panel. Not meant to be called directly.- Overrides:
getPreferredSize
in classContainer
-
processComponentEvent
Recompute component locations when the panel is resized. Not meant to be called directly.- Overrides:
processComponentEvent
in classComponent
-