Class Convex3DGraph
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
jaba.graphs.JabaGraph
jaba.graphs.Convex3DGraph
- All Implemented Interfaces:
ComponentListener, MouseListener, MouseMotionListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
public class Convex3DGraph
extends JabaGraph
implements ComponentListener, MouseListener, MouseMotionListener, MouseWheelListener
This is a panel which draws the Convex Hull diagram, given the pre-computed
set of faces.
- Author:
- Andrea Zoppi, Sebastiano Spicuglia
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumMouse action modes.protected static classKeeps points coordinates both as world coords and as projected screen coords.Nested classes/interfaces inherited from class JabaGraph
JabaGraph.PlotPopupMenuNested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HullVertex[]protected HashSet<HullVertex> protected floatprotected Vector4protected Vector4protected Vector4protected Vector4protected Vector4protected Vector4protected static final Colorprotected Vector4protected static final floatprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected Matrix4protected static final Fontprotected Vector4protected floatprotected floatprotected HullEdge[]protected HullFace[]protected Convex3DGraph.PointData[]protected HashSet<Convex3DGraph.PointData> protected HullEdge[]protected HullFace[]protected Convex3DGraph.PointData[]protected HashSet<Convex3DGraph.PointData> protected JabaControllerprotected floatprotected Pointprotected Pointprotected booleanprotected Convex3DGraph.MouseModeprotected booleanprotected Pointprotected Vector4protected ScreenProjectorprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected static final longprotected Convex3DGraph.PointData[]protected Convex3DGraph.PointData[]protected Convex3DGraph.PointData[]protected Convex3DGraph.PointData[]protected HashSet<Convex3DGraph.PointData> protected static final floatprotected HullEdge[]protected HullFace[]protected Convex3DGraph.PointData[]protected HashSet<Convex3DGraph.PointData> protected floatFields inherited from class JabaGraph
popup, zoomStartPointFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static floatclamp(float min, float value, float max) Keeps a value within bounds.voidvoidvoidvoidprotected voidprotected voiddrawAxes(Graphics2D g, boolean visible) protected voiddrawBorderString(Graphics2D g, String s, int x, int y, Color textColor, Color borderColor) protected voiddrawEdge(Graphics2D g, Convex3DGraph.PointData p1, Convex3DGraph.PointData p2, HullEdge edge, boolean visible) protected voiddrawFace(Graphics2D g, Convex3DGraph.PointData p1, Convex3DGraph.PointData p2, Convex3DGraph.PointData p3, HullFace face) protected voiddrawGrids(Graphics2D g, float size, int numSegments, boolean xEnable, boolean yEnable, boolean zEnable) protected voiddrawVertex(Graphics2D g, Convex3DGraph.PointData p, boolean visible, boolean onHull) protected static StringfloatString(float value, int decimals) Formats a floating point value with the specified number of decimals.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanfloatprotected voidprotected voidincrementFaceCounter(HullFace face) voidmouseClicked(MouseEvent evt) voidmouseDragged(MouseEvent evt) voidmouseEntered(MouseEvent evt) voidmouseExited(MouseEvent evt) voidmouseMoved(MouseEvent evt) voidmousePressed(MouseEvent evt) voidmouseReleased(MouseEvent evt) voidvoidprotected intprintMatrix4(Graphics2D g, Matrix4 m, int x, int y, String name) Prints matrix coefficients in a human-readable manner.protected voidPrints useful internal data, such as rotation angles and transform matrices.voidselectStation(String name) voidsetEnableCoplanarEdges(boolean enableCoplanarEdges) voidsetEnableCustomZoom(boolean enableCustomZoom) voidsetEnableDebugEdges(boolean enableDebugEdges) voidsetEnableDebugInfo(boolean enableDebugInfo) voidsetEnableHiddenEdges(boolean enableHiddenEdges) voidsetEnableHiddenFaces(boolean enableHiddenFaces) voidsetEnableHullVerticesLabels(boolean enableHullVerticesLabels) voidsetEnableInternalVertices(boolean enableInternalVertices) voidsetEnableTransparentFaces(boolean enableTransparentFaces) voidsetEnableVisibleEdges(boolean enableVisibleEdges) voidsetEnableVisibleFaces(boolean enableVisibleFaces) voidsetZoomFactor(float zoomFactor) protected voidsplitByVisibility(Vector4 forward) Check if the face is visible or not.voidProjects 3D points onto the screen and repaints the diagram.Methods inherited from class JabaGraph
adjustMousePoint, adjustMousePoint, adjustMousePoint2, rightClick, translateX, translateY, zoomMethods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateMethods inherited from class 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, validateTreeMethods inherited from class 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
FONT
-
serialVersionUID
protected static final long serialVersionUID- See Also:
-
prj
-
BGCOLOR
-
mainWin
-
enableCustomZoom
protected boolean enableCustomZoom -
enableDebugInfo
protected boolean enableDebugInfo -
enableDebugEdges
protected boolean enableDebugEdges -
enableCoplanarEdges
protected boolean enableCoplanarEdges -
enableInternalVertices
protected boolean enableInternalVertices -
enableVisibleEdges
protected boolean enableVisibleEdges -
enableHiddenEdges
protected boolean enableHiddenEdges -
enableVisibleFaces
protected boolean enableVisibleFaces -
enableHiddenFaces
protected boolean enableHiddenFaces -
enableHullVerticesLabels
protected boolean enableHullVerticesLabels -
enableTransparentFaces
protected boolean enableTransparentFaces -
axisPrjX
-
axisPrjY
-
axisPrjZ
-
axisLabelX
-
axisLabelY
-
axisLabelZ
-
originPrj
-
forward
-
screenW
protected float screenW -
screenH
protected float screenH -
halfW
protected float halfW -
halfH
protected float halfH -
aspect
protected float aspect -
rotY
protected float rotY -
rotX
protected float rotX -
rotYdelta
protected float rotYdelta -
rotXdelta
protected float rotXdelta -
zoomFactor
protected float zoomFactor -
mouseLeft
protected boolean mouseLeft -
mouseRight
protected boolean mouseRight -
mouseStart
-
mouseEnd
-
mouseDelta
-
mouseMode
-
VISIBILITY_EPSILON
protected static final float VISIBILITY_EPSILON- See Also:
-
COPLANAR_EPSILON
protected static final float COPLANAR_EPSILON- See Also:
-
allVerticesSet
-
allVerticesArray
-
faces
-
hullEdgesSet
-
hullVerticesSet
-
visibleFacesSet
-
visibleEdgesSet
-
visibleVerticesSet
-
verticesInsideSet
-
hullEdgesArray
-
hullVerticesArray
-
hullFacesArray
-
visibleFacesArray
-
visibleEdgesArray
-
visibleVerticesArray
-
verticesInsideArray
-
sortedVisibleVertices
-
sortedHiddenVertices
-
sortedVerticesInside
-
maxVertexDistance
protected float maxVertexDistance -
centroid
-
eyeRT
-
-
Constructor Details
-
Convex3DGraph
-
-
Method Details
-
getEnableDebugInfo
public boolean getEnableDebugInfo() -
setEnableDebugInfo
public void setEnableDebugInfo(boolean enableDebugInfo) -
getEnableDebugEdges
public boolean getEnableDebugEdges() -
setEnableDebugEdges
public void setEnableDebugEdges(boolean enableDebugEdges) -
getEnableCustomZoom
public boolean getEnableCustomZoom() -
setEnableCustomZoom
public void setEnableCustomZoom(boolean enableCustomZoom) -
getEnableInternalVertices
public boolean getEnableInternalVertices() -
setEnableInternalVertices
public void setEnableInternalVertices(boolean enableInternalVertices) -
getEnableCoplanarEdges
public boolean getEnableCoplanarEdges() -
setEnableCoplanarEdges
public void setEnableCoplanarEdges(boolean enableCoplanarEdges) -
getEnableVisibleEdges
public boolean getEnableVisibleEdges() -
setEnableVisibleEdges
public void setEnableVisibleEdges(boolean enableVisibleEdges) -
getEnableHiddenEdges
public boolean getEnableHiddenEdges() -
setEnableHiddenEdges
public void setEnableHiddenEdges(boolean enableHiddenEdges) -
getEnableVisibleFaces
public boolean getEnableVisibleFaces() -
setEnableVisibleFaces
public void setEnableVisibleFaces(boolean enableVisibleFaces) -
getEnableHiddenFaces
public boolean getEnableHiddenFaces() -
setEnableHiddenFaces
public void setEnableHiddenFaces(boolean enableHiddenFaces) -
getEnableHullVerticesLabels
public boolean getEnableHullVerticesLabels() -
setEnableHullVerticesLabels
public void setEnableHullVerticesLabels(boolean enableHullVerticesLabels) -
getEnableTransparentFaces
public boolean getEnableTransparentFaces() -
setEnableTransparentFaces
public void setEnableTransparentFaces(boolean enableTransparentFaces) -
getZoomFactor
public float getZoomFactor() -
setZoomFactor
public void setZoomFactor(float zoomFactor) -
splitByVisibility
Check if the face is visible or not. Due to the convex solid property, a positive dot product means that the face has the normal in the same direction of the sight, thus it is not visible because there exist faces which cover the sight of the analyzed one.- Parameters:
forward- Viewing direction.
-
countFaceVertices
protected void countFaceVertices() -
incrementFaceCounter
-
paint
-
drawAxes
-
drawBorderString
protected void drawBorderString(Graphics2D g, String s, int x, int y, Color textColor, Color borderColor) -
drawGrids
protected void drawGrids(Graphics2D g, float size, int numSegments, boolean xEnable, boolean yEnable, boolean zEnable) -
drawFace
protected void drawFace(Graphics2D g, Convex3DGraph.PointData p1, Convex3DGraph.PointData p2, Convex3DGraph.PointData p3, HullFace face) -
drawEdge
protected void drawEdge(Graphics2D g, Convex3DGraph.PointData p1, Convex3DGraph.PointData p2, HullEdge edge, boolean visible) -
drawVertex
-
floatString
Formats a floating point value with the specified number of decimals.- Parameters:
value- Value to convert into string.decimals- Number of decimals.- Returns:
-
printMatrix4
Prints matrix coefficients in a human-readable manner.- Parameters:
g- Graphics context.m- Matrix to print.x- Left coordinate.y- Top coordinate.name- Displayed matrix name.- Returns:
- The new Y coordinate after printing text lines.
-
printViewState
Prints useful internal data, such as rotation angles and transform matrices.- Parameters:
g- Graphics context.
-
clamp
protected static float clamp(float min, float value, float max) Keeps a value within bounds.- Parameters:
min- Minimum value.value- Value to check.max- Maximum value.- Returns:
- The clamped value.
-
getScreenProjector
- Returns:
- The internal ScreenProjector instance.
-
updateProjection
public void updateProjection()Projects 3D points onto the screen and repaints the diagram. -
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener
-
componentMoved
- Specified by:
componentMovedin interfaceComponentListener
-
componentResized
- Specified by:
componentResizedin interfaceComponentListener
-
componentShown
- Specified by:
componentShownin interfaceComponentListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
handleMovements
-
selectStation
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-