com.sun.electric.plugins.j3d
Class View3DWindow

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.sun.electric.plugins.j3d.View3DWindow
All Implemented Interfaces:
WindowContent, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, java.util.Observer, javax.accessibility.Accessible

public class View3DWindow
extends javax.swing.JPanel
implements WindowContent, java.awt.event.MouseMotionListener, java.awt.event.MouseListener, java.awt.event.MouseWheelListener, java.awt.event.KeyListener, java.awt.event.ActionListener, java.util.Observer

This class deals with 3D View using Java3D

Version:
0.1
Author:
Gilda Garreton
See Also:
Serialized Form

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  Cell cell
          the cell that is in the window
protected  TransformGroup objTrans
           
 
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
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Respond to an action performed, in this case change the current cell when the user clicks on an entry in the upHierarchy popup menu.
 void addArc(ArcInst ai, java.awt.geom.AffineTransform transform, TransformGroup objTrans)
          Adds given Arc to scene graph
 J3DUtils.ThreeDDemoKnot addFrame(boolean useView)
           
 java.util.Map<TransformGroup,BranchGroup> addInterpolator(java.util.List<J3DUtils.ThreeDDemoKnot> knotList)
          Method to create a path interpolator using knots defined in input list
 java.util.Map<TransformGroup,BranchGroup> addInterpolatorPerGroup(java.util.List<J3DUtils.ThreeDDemoKnot> knotList, TransformGroup grp, java.util.Map<TransformGroup,BranchGroup> interMap, boolean useView)
          Method to add interpolator per group
 void bottomScrollChanged(int e)
           
 void centerCursor()
          Method to shift the panels so that the current cursor location becomes the center.
static void create3DWindow(Cell cell, WindowFrame wf, WindowContent view2D, boolean transPerNode)
           
protected  BranchGroup createSceneGraph(Cell cell)
          Method to create main transformation group
 void fillScreen()
          Method to reset zoom/rotation/extraTrans to original place (Fill Window operation)
 boolean findNextText(boolean reverse)
          Method to find the next occurrence of a string.
 void finished()
          Method to get rid of this EditWindow.
 void focusOnHighlighted()
           
 void fullRepaint()
          Dummy functios due to text-oriented functions
 Cell getCell()
          Method to return the cell that is shown in this window.
 Highlighter getHighlighter()
          Get the Highlighter for this window
 java.awt.Point getLastMousePosition()
           
 void getObjTransform(Transform3D trans)
           
 javax.swing.JPanel getPanel()
          Method to return the top-level JPanel for this WindowContent.
 java.awt.image.BufferedImage getPrintImage(ElectricPrinter ep)
          Method to print window using offscreen canvas.
protected  double getScale()
           
 boolean initializePrinting(ElectricPrinter ep, java.awt.print.PageFormat pageFormat)
          Method to intialize for printing.
 void initTextSearch(java.lang.String search, boolean caseSensitive, boolean regExp, java.util.Set<TextUtils.WhatToSearch> whatToSearch, boolean highlightedOnly)
          Method to initialize for a new text search.
 boolean isCollision(Transform3D t3d)
           
protected  boolean isCollision(Vector3d worldCoord)
          Method to detect if give x, y location in the world collides with geometry
 void keyPressed(java.awt.event.KeyEvent evt)
           
 void keyReleased(java.awt.event.KeyEvent evt)
           
 void keyTyped(java.awt.event.KeyEvent evt)
           
 java.util.List<javax.swing.tree.MutableTreeNode> loadExplorerTrees()
           
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
           
 J3DUtils.ThreeDDemoKnot moveAndRotate(double[] values)
          Method to rotate individual groups
 void panXOrY(int direction, double[] panningAmounts, int ticks)
          Method to pan along X according to fixed amount of ticks
 void removeInterpolator(java.util.Map<TransformGroup,BranchGroup> interMap)
          Method to remove certain interpolators from scene graph
 void replaceAllText(java.lang.String replace)
          Method to replace all selected text.
 void replaceText(java.lang.String replace)
          Method to replace the text that was just selected with findNextText().
 void rightScrollChanged(int e)
           
 void saveImage(boolean movieMode)
           
 void saveMovie(java.lang.String filename)
           
 java.awt.geom.Point2D screenToDatabase(int screenX, int screenY)
          Method to convert a screen coordinate to database coordinates.
static void setAntialiasing(boolean value)
          Method to turn on/off antialiasing
 void setCell(Cell cell, VarContext context, WindowFrame.DisplayAttributes da)
           
 void setObjTransform(Transform3D trans)
           
static void setScaleFactor(double value)
          Method to change Z values in elements
 void setWindowTitle()
          Method to set the window title.
static void setZValues(Layer layer, java.lang.Double origDist, java.lang.Double origThick, java.lang.Double distance, java.lang.Double thickness)
          Method to change geometry of all nodes using this particular layer This could be an expensive function!.
 void showCoordinates(java.awt.event.MouseEvent evt)
           
 void update(java.util.Observable o, java.lang.Object arg)
          Observer method to highlight 3D nodes by clicking 2D objects
 void writeImage(ElectricPrinter ep, java.lang.String filePath)
          Method to export directly PNG file
 void zoomInContents()
          Method to zoom in by a factor of 2 plus mouse pre-defined factor
 void zoomOutContents()
          Method to zoom out by a factor of 2 plus mouse pre-defined factor
 
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, paintComponent, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.electric.tool.user.ui.WindowContent
repaint, setCursor
 

Field Detail

objTrans

protected TransformGroup objTrans

cell

protected Cell cell
the cell that is in the window

Method Detail

create3DWindow

public static void create3DWindow(Cell cell,
                                  WindowFrame wf,
                                  WindowContent view2D,
                                  boolean transPerNode)

getObjTransform

public void getObjTransform(Transform3D trans)

setObjTransform

public void setObjTransform(Transform3D trans)

createSceneGraph

protected BranchGroup createSceneGraph(Cell cell)
Method to create main transformation group

Parameters:
cell -
Returns:
BrachGroup representing the scene graph

setWindowTitle

public void setWindowTitle()
Method to set the window title.

Specified by:
setWindowTitle in interface WindowContent

getCell

public Cell getCell()
Method to return the cell that is shown in this window.

Specified by:
getCell in interface WindowContent
Returns:
the cell that is shown in this window.

finished

public void finished()
Method to get rid of this EditWindow. Called by WindowFrame when that windowFrame gets closed.

Specified by:
finished in interface WindowContent

bottomScrollChanged

public void bottomScrollChanged(int e)
Specified by:
bottomScrollChanged in interface WindowContent

rightScrollChanged

public void rightScrollChanged(int e)
Specified by:
rightScrollChanged in interface WindowContent

fullRepaint

public void fullRepaint()
Dummy functios due to text-oriented functions

Specified by:
fullRepaint in interface WindowContent

findNextText

public boolean findNextText(boolean reverse)
Description copied from interface: WindowContent
Method to find the next occurrence of a string.

Specified by:
findNextText in interface WindowContent
Parameters:
reverse - true to find in the reverse direction.
Returns:
true if something was found.

replaceText

public void replaceText(java.lang.String replace)
Description copied from interface: WindowContent
Method to replace the text that was just selected with findNextText().

Specified by:
replaceText in interface WindowContent
Parameters:
replace - the new text to replace.

getPanel

public javax.swing.JPanel getPanel()
Description copied from interface: WindowContent
Method to return the top-level JPanel for this WindowContent. Although the classes that implement this interface may also extend JPanel, it is not always the case that those classes will be the JPanel that this method returns. For example, the actual EditWindow object is below the top level, surrounded by scroll bars.

Specified by:
getPanel in interface WindowContent
Returns:
the top-level JPanel for this WindowContent.

initTextSearch

public void initTextSearch(java.lang.String search,
                           boolean caseSensitive,
                           boolean regExp,
                           java.util.Set<TextUtils.WhatToSearch> whatToSearch,
                           boolean highlightedOnly)
Description copied from interface: WindowContent
Method to initialize for a new text search.

Specified by:
initTextSearch in interface WindowContent
Parameters:
search - the string to locate.
caseSensitive - true to match only where the case is the same.
regExp - true if the search string is a regular expression.
whatToSearch - a collection of text types to consider.
highlightedOnly - true to search only in the highlighted area.

panXOrY

public void panXOrY(int direction,
                    double[] panningAmounts,
                    int ticks)
Method to pan along X according to fixed amount of ticks

Specified by:
panXOrY in interface WindowContent
Parameters:
direction -
panningAmounts -
ticks -

centerCursor

public void centerCursor()
Method to shift the panels so that the current cursor location becomes the center.

Specified by:
centerCursor in interface WindowContent

zoomOutContents

public void zoomOutContents()
Method to zoom out by a factor of 2 plus mouse pre-defined factor

Specified by:
zoomOutContents in interface WindowContent

zoomInContents

public void zoomInContents()
Method to zoom in by a factor of 2 plus mouse pre-defined factor

Specified by:
zoomInContents in interface WindowContent

fillScreen

public void fillScreen()
Method to reset zoom/rotation/extraTrans to original place (Fill Window operation)

Specified by:
fillScreen in interface WindowContent

setCell

public void setCell(Cell cell,
                    VarContext context,
                    WindowFrame.DisplayAttributes da)
Specified by:
setCell in interface WindowContent

focusOnHighlighted

public void focusOnHighlighted()
Specified by:
focusOnHighlighted in interface WindowContent

replaceAllText

public void replaceAllText(java.lang.String replace)
Description copied from interface: WindowContent
Method to replace all selected text.

Specified by:
replaceAllText in interface WindowContent
Parameters:
replace - the new text to replace everywhere.

getHighlighter

public Highlighter getHighlighter()
Description copied from interface: WindowContent
Get the Highlighter for this window

Specified by:
getHighlighter in interface WindowContent

loadExplorerTrees

public java.util.List<javax.swing.tree.MutableTreeNode> loadExplorerTrees()
Specified by:
loadExplorerTrees in interface WindowContent

addArc

public void addArc(ArcInst ai,
                   java.awt.geom.AffineTransform transform,
                   TransformGroup objTrans)
Adds given Arc to scene graph

Parameters:
ai -
objTrans -

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Observer method to highlight 3D nodes by clicking 2D objects

Specified by:
update in interface java.util.Observer
Parameters:
o -
arg -

setScaleFactor

public static void setScaleFactor(double value)
Method to change Z values in elements

Parameters:
value -

setAntialiasing

public static void setAntialiasing(boolean value)
Method to turn on/off antialiasing

Parameters:
value - true if antialiasing is set to true

setZValues

public static void setZValues(Layer layer,
                              java.lang.Double origDist,
                              java.lang.Double origThick,
                              java.lang.Double distance,
                              java.lang.Double thickness)
Method to change geometry of all nodes using this particular layer This could be an expensive function!.

Parameters:
layer -
distance -
thickness -

writeImage

public void writeImage(ElectricPrinter ep,
                       java.lang.String filePath)
Method to export directly PNG file

Specified by:
writeImage in interface WindowContent
Parameters:
ep -
filePath -

saveImage

public void saveImage(boolean movieMode)

initializePrinting

public boolean initializePrinting(ElectricPrinter ep,
                                  java.awt.print.PageFormat pageFormat)
Method to intialize for printing.

Specified by:
initializePrinting in interface WindowContent
Parameters:
ep - the ElectricPrinter object.
pageFormat - information about the print job.
Returns:
false for now.

getPrintImage

public java.awt.image.BufferedImage getPrintImage(ElectricPrinter ep)
Method to print window using offscreen canvas.

Specified by:
getPrintImage in interface WindowContent
Parameters:
ep - printable object.
Returns:
the image to print (null on error).

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Respond to an action performed, in this case change the current cell when the user clicks on an entry in the upHierarchy popup menu.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

moveAndRotate

public J3DUtils.ThreeDDemoKnot moveAndRotate(double[] values)
Method to rotate individual groups

Parameters:
values - array of values

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

showCoordinates

public void showCoordinates(java.awt.event.MouseEvent evt)

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Specified by:
keyTyped in interface java.awt.event.KeyListener

getLastMousePosition

public java.awt.Point getLastMousePosition()

screenToDatabase

public java.awt.geom.Point2D screenToDatabase(int screenX,
                                              int screenY)
Method to convert a screen coordinate to database coordinates.

Parameters:
screenX - the X coordinate (on the screen in this EditWindow).
screenY - the Y coordinate (on the screen in this EditWindow).
Returns:
the coordinate of that point in database units.

addInterpolator

public java.util.Map<TransformGroup,BranchGroup> addInterpolator(java.util.List<J3DUtils.ThreeDDemoKnot> knotList)
Method to create a path interpolator using knots defined in input list

Parameters:
knotList - list with knot data. If null, search for data attached to nodes

addInterpolatorPerGroup

public java.util.Map<TransformGroup,BranchGroup> addInterpolatorPerGroup(java.util.List<J3DUtils.ThreeDDemoKnot> knotList,
                                                                         TransformGroup grp,
                                                                         java.util.Map<TransformGroup,BranchGroup> interMap,
                                                                         boolean useView)
Method to add interpolator per group

Parameters:
knotList -
grp -
interMap -
Returns:
Map with interpolation groups

removeInterpolator

public void removeInterpolator(java.util.Map<TransformGroup,BranchGroup> interMap)
Method to remove certain interpolators from scene graph

Parameters:
interMap -

getScale

protected double getScale()

isCollision

public boolean isCollision(Transform3D t3d)

isCollision

protected boolean isCollision(Vector3d worldCoord)
Method to detect if give x, y location in the world collides with geometry

Parameters:
worldCoord -
Returns:
true if vector collides

addFrame

public J3DUtils.ThreeDDemoKnot addFrame(boolean useView)

saveMovie

public void saveMovie(java.lang.String filename)