|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel GridView.DrawingCanvas
public class DrawingCanvas
Class for drawing stuff onto a canvas (widget). This class is responsible for drawing stuff onto the screen. It uses mouse motion for several kinds of visual input, eg angle of viewing etc. The drawing area represented by this class is shown within the main viewer window.
This class draws over a buffered image, and just copies over the buffer to the screen at the time of rendering. This buffering makes the rendering more efficient (no redraw necessary for actions that do not change the picture). For platforms that support hardware acceleration, image rendering makes use of that feature.
DrawingCanvasInterface
,
Viewer
,
Serialized FormNested Class Summary | |
---|---|
static class |
DrawingCanvas.DrawType
WIREFRAME: wireframe model SURFACE: surface model with edges SURFACE_ONLY: Only surface, no edges CRINKLE_CUT: Cut the object. |
static class |
DrawingCanvas.ViewType
|
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 | |
---|---|
private boolean |
bDrawingCutLine
|
private boolean |
bDrawingROIRect
|
private boolean |
bDrawingRuler
|
private float[] |
dPlane
dPlane[0], dPlane[1], dPlane[2], dPlane[4] are used to define the cut plane as follows: dPlane[0]*x + dPlane[1]*y + dPlane[2]*z + dPlane[3] = 0;. |
static int |
INSETS
Insets for actual drawing area within the canvas. |
private float[] |
mAxisCosine
|
private java.awt.Color |
mBgColor
Background color. |
private java.awt.image.BufferedImage |
mBufImg
Buffered image |
private Controller |
mController
|
private float[] |
mCuttingPlane
Cutting plane. |
(package private) DrawingCanvas.DrawType |
mDrawType
|
protected int |
mMouseX
X coordinate (in screen coordinates of mouse pressed event. |
private int |
mMouseY
Y coordinate (in screen coordinates of mouse pressed event. |
private int |
mNewMouseX
|
private int |
mNewMouseY
|
private OutputPanel |
mOutPanel
Output panel for logging messages / errors. |
private java.awt.Color |
mRulerColor
Ruler color. |
private Viewer |
mViewer
Instance of the containing viewer. |
(package private) DrawingCanvas.ViewType |
mViewType
|
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 | |
---|---|
DrawingCanvas(Viewer vw,
int width,
int height,
Controller cont)
Class constructor. |
Method Summary | |
---|---|
private void |
Draw(java.awt.Graphics g)
Draw the scene on provided graphics instance. |
private void |
DrawAxonometricView(java.awt.Graphics g)
Draw Axonometric view taking into account the current parameter settings. |
private void |
DrawCameraImage(DrawingCanvas canvas,
java.awt.Graphics g,
float[] camera_coor,
float[] center_proj,
boolean onlySurface,
boolean onlyWireframe)
|
private void |
DrawOnePtPerspectiveView(java.awt.Graphics g)
|
private void |
DrawPerspectiveView(java.awt.Graphics g,
float[] camera_coor,
float[] center_proj)
Modifies the transformation matrix to account for one point perspective projection. |
private void |
DrawROIRectangle(java.awt.Graphics g)
Draw a rectangular region of interest (ROI) on supplied graphics instance. |
private void |
DrawRuler(java.awt.Graphics g)
Draw the final ruler with measurement and arrowhead. |
private void |
DrawRulerOutline(java.awt.Graphics g)
Draw the ruler outline over supplied graphics instance. |
private void |
DrawThreePtPerspectiveView(java.awt.Graphics g)
|
private void |
DrawTwoPtPerspectiveView(java.awt.Graphics g)
|
java.awt.Color |
GetBackgroundColor()
Find the current background color. |
Controller |
GetController()
|
float[] |
GetCutPlane()
|
DrawingCanvas.DrawType |
GetDrawType()
|
java.awt.Graphics |
GetImageGraphics()
Get the Graphics2d instance associated with buffered image. |
int |
GetMinOfWidthHeight()
Get minimum of screen width and height. |
int |
GetMouseX()
|
int |
GetMouseY()
|
int |
GetNewMouseX()
|
int |
GetNewMouseY()
|
java.awt.Dimension |
getPreferredSize()
|
java.awt.Color |
GetRulerColor()
|
Viewer |
GetViewer()
|
DrawingCanvas.ViewType |
GetViewType()
|
boolean |
IsSpecularShading()
|
float |
LightIntensity()
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Handler for mouseClicked event.. |
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Handler for mouseMoved event. |
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
protected void |
paintComponent(java.awt.Graphics g)
Method called by Java for repainting. |
void |
RegenerateImage()
Paint the buffered image again, after possibly resizing it. |
private void |
ResizeBufferedImage()
Resize the buffered image to drawing canvas size. |
void |
SaveScreenShot(java.io.File file,
java.lang.String extension)
|
void |
SetBackgroundColor(java.awt.Color newColor)
Set the color to specified color. |
void |
SetCuttingPlane(float[] plane)
Set the cutting plane. |
void |
SetDrawType(DrawingCanvas.DrawType dtyp)
Sets the type of drawing (e.g wireframe, surface, crinkle cut). Redraws the image if new selection differs from the old one. |
void |
SetOutputPanel(OutputPanel outPanel)
Record the output panel instance, so that error info etc can be dumped onto the panel. |
void |
SetRulerColor(java.awt.Color col)
|
void |
SetViewType(DrawingCanvas.ViewType vtyp)
Sets the type of view. |
int |
SpecularExponent()
|
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, 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 |
---|
public static final int INSETS
private Viewer mViewer
private Controller mController
private OutputPanel mOutPanel
DrawingCanvas.ViewType mViewType
DrawingCanvas.DrawType mDrawType
private float[] dPlane
protected int mMouseX
private int mMouseY
private int mNewMouseX
private int mNewMouseY
private java.awt.image.BufferedImage mBufImg
private java.awt.Color mBgColor
private java.awt.Color mRulerColor
private float[] mCuttingPlane
private float[] mAxisCosine
private boolean bDrawingROIRect
private boolean bDrawingRuler
private boolean bDrawingCutLine
Constructor Detail |
---|
public DrawingCanvas(Viewer vw, int width, int height, Controller cont)
vw
- Viewer instance that displays the drawing canvas.width
- Canvas width (in pixels). This is the initial width,
it can change later in response to resizing window, etc.height
- Canvas height (in pixels).cont
- Controller instance.Method Detail |
---|
public float LightIntensity()
LightIntensity
in interface DrawingCanvasInterface
public int SpecularExponent()
SpecularExponent
in interface DrawingCanvasInterface
public boolean IsSpecularShading()
IsSpecularShading
in interface DrawingCanvasInterface
public void SetBackgroundColor(java.awt.Color newColor)
newColor
- New background color.mBgColor
public java.awt.Color GetBackgroundColor()
public void SetRulerColor(java.awt.Color col)
public java.awt.Color GetRulerColor()
public void SetOutputPanel(OutputPanel outPanel)
outPanel
- Instance of OutputPanel used on the main viewer.OutputPanel
private void DrawROIRectangle(java.awt.Graphics g)
g
- Graphics instance.private void DrawRulerOutline(java.awt.Graphics g)
g
- Graphics instanceprivate void DrawRuler(java.awt.Graphics g)
g
- Graphics instanceprotected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- Graphics instance (passed by Java framework).public void SetCuttingPlane(float[] plane)
plane
- An array with four elements defining the plane as:
plane[0]*X + plane[1]*Y + plane[2]*Z + plane[3] = 0public void SetViewType(DrawingCanvas.ViewType vtyp)
vtyp
- View type (Select from one of perspective views or
axonometric view, for the perspective view option, there are
one-point, two-point and three-point based perspective options).DrawingCanvas.ViewType
public DrawingCanvas.ViewType GetViewType()
public void SetDrawType(DrawingCanvas.DrawType dtyp)
dtyp
- Draw type (Select from one of wireframe, surface drawing,
or crinkle cut).DrawingCanvas.DrawType
public DrawingCanvas.DrawType GetDrawType()
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- MouseEvent corresponding to mouse movementpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- MouseEvent corresponding to mouse movementpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public int GetMinOfWidthHeight()
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
private void ResizeBufferedImage()
public java.awt.Graphics GetImageGraphics()
public void RegenerateImage()
private void Draw(java.awt.Graphics g)
g
- Graphics instance where painting needs to be done.private void DrawOnePtPerspectiveView(java.awt.Graphics g)
private void DrawTwoPtPerspectiveView(java.awt.Graphics g)
private void DrawThreePtPerspectiveView(java.awt.Graphics g)
private void DrawAxonometricView(java.awt.Graphics g)
g
- Graphics instance.private void DrawPerspectiveView(java.awt.Graphics g, float[] camera_coor, float[] center_proj)
g
- Grpahics instance.GeomDataManager.mTransMatrix
private void DrawCameraImage(DrawingCanvas canvas, java.awt.Graphics g, float[] camera_coor, float[] center_proj, boolean onlySurface, boolean onlyWireframe)
public void SaveScreenShot(java.io.File file, java.lang.String extension)
public Viewer GetViewer()
public Controller GetController()
public float[] GetCutPlane()
public int GetMouseX()
public int GetMouseY()
public int GetNewMouseX()
public int GetNewMouseY()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |