|
|||||||||
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
optics.graphics.Diagram2DPanel
public class Diagram2DPanel
Class to implement a DiagramPanel, being an extended JPanel with internal Mouse control allowing for interactive zooming.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected java.awt.geom.Rectangle2D |
bounds
|
protected Diagram2D |
diagram
The Diagram2D displayed on the Panel. |
protected boolean |
drag
|
protected java.awt.Point |
endDrag
|
protected boolean |
inZoomMode
|
protected java.awt.Point |
startDrag
|
protected boolean |
startDragSet
|
protected java.awt.geom.AffineTransform |
transform
|
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 | |
---|---|
Diagram2DPanel()
Form a blank Diagram2DPanel containg a blank
Diagram3D to which components can be added. |
|
Diagram2DPanel(Diagram2D d)
Form a Diagram2DPanel containing a prespecified Diagram2D . |
Method Summary | |
---|---|
void |
add(Diagram2DComponent obj)
Method to add Component to the Diagram. |
void |
add(LensSystem lens)
Method to add an LensSystem to the DiagramPanel |
void |
clear()
Method to clear the DiagramPanel |
java.awt.image.BufferedImage |
exportImage(java.awt.image.BufferedImage im)
Method to export the pabel as a spefified BufferenedImage
with size and type specified by the image characteristics |
Diagram2D |
getDiagram2D()
Method to get the Diagram object |
java.awt.image.BufferedImage |
getImage(int w,
int h)
Method to get to Diagram2DPanel as a coloured BuffererImage
of type INT_RGB . |
void |
mouseClicked(java.awt.event.MouseEvent e)
Void mouseClicked event, implement Button 3 resetting to full bounds. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Void mouseDragged event (only for drag with botton 1), which will highlight the dragged area in light grey. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Void mouseEntered, does nothing. |
void |
mouseExited(java.awt.event.MouseEvent e)
Void mouseExited, does nothing. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Void mouseMoved method, does nothing |
void |
mousePressed(java.awt.event.MouseEvent e)
Void mousePressed event, implement button 1 staring drag area. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Void mouseReleased event, implement sbutton 1 being relased after a drag. |
void |
paintComponent(java.awt.Graphics g)
Overload method to repaint the JPanel |
void |
resetBounds()
Internal method to reset the bounds to to be slightly large than the diagram bounds. |
void |
setDiagram(Diagram2D d)
Method to set/reset the displayed Diagram. |
void |
setFontSize(double h)
Method to set the fontsize (defaults to 16pt) |
void |
setPenWidth(double w)
Method to set the default penwidth (defaults to 1.0) |
boolean |
writeImage(int w,
int h,
java.io.File output)
Method to write the the Diagram to a file as a image with type specified by filename suffix |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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 |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, 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, transferFocusBackward, transferFocusDownCycle, 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, 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, hide, imageUpdate, 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, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Diagram2D diagram
protected java.awt.geom.Rectangle2D bounds
protected java.awt.geom.AffineTransform transform
protected java.awt.Point startDrag
protected boolean startDragSet
protected java.awt.Point endDrag
protected boolean drag
protected boolean inZoomMode
Constructor Detail |
---|
public Diagram2DPanel(Diagram2D d)
Diagram2D
. The underlying JPanel
has default flow layout.
d
- the diagram to display.public Diagram2DPanel()
Diagram2DPanel
containg a blank
Diagram3D
to which components can be added.
Method Detail |
---|
public void setDiagram(Diagram2D d)
d
- the Diagram2D to be displayed.public void add(Diagram2DComponent obj)
Note button 3 cancel zoom mode and reset defaults bounds.
obj
- the DiagramObjectpublic void add(LensSystem lens)
LensSystem
to the DiagramPanel
lens
- the LensSystem.public Diagram2D getDiagram2D()
Diagram
object
Diagram2D
the panel Diagrampublic void clear()
public void setPenWidth(double w)
w
- the penwidthpublic void setFontSize(double h)
h
- the fontsizepublic void resetBounds()
public boolean writeImage(int w, int h, java.io.File output)
w
- image widthh
- image heightoutput
- the File to be written to
boolean
true if successful, false for failure.public java.awt.image.BufferedImage exportImage(java.awt.image.BufferedImage im)
BufferenedImage
with size and type specified by the image characteristics
im
- the BufferedImage
BufferedImage
which will be the specifed
BufferedImage with the figure painted.public java.awt.image.BufferedImage getImage(int w, int h)
Diagram2DPanel
as a coloured BuffererImage
of type INT_RGB
.
w
- image widthh
- image height
BufferedImage
image of the panelpublic void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- the mouse event.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- the mouse evenpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- the mouse eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- the mourse eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- the mourse eventpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- the mouse event.public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- the mouse event
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |