Class BasicDrawing
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.insa.graphs.gui.drawing.components.BasicDrawing
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,Drawing
public class BasicDrawing extends javax.swing.JPanel implements Drawing
- 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
-
Nested classes/interfaces inherited from interface org.insa.graphs.gui.drawing.Drawing
Drawing.AlphaMode
-
-
Field Summary
Fields Modifier and Type Field Description static GraphPaletteDEFAULT_PALETTEstatic java.awt.ColorDEFAULT_PATH_COLOR-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description BasicDrawing()Create a new BasicDrawing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDrawingClickListener(DrawingClickListener listener)Add a listener to click to this drawing.voidclear()Clear the drawing (overlays and underlying graph/map).voidclearOverlays()Remove overlays from the drawing (do not remove the underlying graph/map).org.insa.graphs.gui.drawing.components.BasicDrawing.BasicMarkerOverlaycreateMarker(Point point, java.awt.Color outer, java.awt.Color inner, Drawing.AlphaMode mode)PointSetOverlaycreatePointSetOverlay()Create a new PointSetOverlay that can be used to add overlay points to this drawing.PointSetOverlaycreatePointSetOverlay(int width, java.awt.Color color)Create a new PointSetOverlay with the given initial width and color that can be used to add overlay points to this drawing.protected voiddrawArc(Arc arc, GraphPalette palette, boolean repaint)Draw the given arc.voiddrawGraph(Graph graph)Draw the given graph using a default palette specific to the implementation.voiddrawGraph(Graph graph, GraphPalette palette)Draw the given graph using the given palette.MarkerOverlaydrawMarker(Point point, java.awt.Color outer, java.awt.Color inner, Drawing.AlphaMode mode)Draw a marker at the given position using the given colors and according to the given mode.PathOverlaydrawPath(Path path)Draw a path with both origin and destination markers using a default color specific to the implementationPathOverlaydrawPath(Path path, boolean markers)Draw a path using a default color specific to the implementationPathOverlaydrawPath(Path path, java.awt.Color color)Draw a path with both origin and destination markers using the given color.PathOverlaydrawPath(Path path, java.awt.Color color, boolean markers)Draw a path using the given color.protected PointgetLongitudeLatitude(java.awt.event.MouseEvent event)Return the longitude and latitude corresponding to the given position of the MouseEvent.ZoomAndPanListenergetZoomAndPanListener()protected voidinitialize(Graph graph)Initialize the drawing for the given graph.voidpaintComponent(java.awt.Graphics g1)voidremoveDrawingClickListener(DrawingClickListener listener)Remove the given listener from the drawing.-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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 Detail
-
DEFAULT_PATH_COLOR
public static final java.awt.Color DEFAULT_PATH_COLOR
-
DEFAULT_PALETTE
public static final GraphPalette DEFAULT_PALETTE
-
-
Method Detail
-
paintComponent
public void paintComponent(java.awt.Graphics g1)
- Overrides:
paintComponentin classjavax.swing.JComponent
-
clear
public void clear()
Description copied from interface:DrawingClear the drawing (overlays and underlying graph/map).
-
clearOverlays
public void clearOverlays()
Description copied from interface:DrawingRemove overlays from the drawing (do not remove the underlying graph/map).- Specified by:
clearOverlaysin interfaceDrawing
-
getZoomAndPanListener
public ZoomAndPanListener getZoomAndPanListener()
- Returns:
- The current ZoomAndPanListener associated with this drawing.
-
getLongitudeLatitude
protected Point getLongitudeLatitude(java.awt.event.MouseEvent event) throws java.awt.geom.NoninvertibleTransformException
Return the longitude and latitude corresponding to the given position of the MouseEvent.- Parameters:
event- MouseEvent from which longitude/latitude should be retrieved.- Returns:
- Point representing the projection of the MouseEvent position in the graph/map.
- Throws:
java.awt.geom.NoninvertibleTransformException- if the actual transformation is invalid.
-
addDrawingClickListener
public void addDrawingClickListener(DrawingClickListener listener)
Description copied from interface:DrawingAdd a listener to click to this drawing.- Specified by:
addDrawingClickListenerin interfaceDrawing- Parameters:
listener- DrawingClickListener to add to this Drawing.
-
removeDrawingClickListener
public void removeDrawingClickListener(DrawingClickListener listener)
Description copied from interface:DrawingRemove the given listener from the drawing.- Specified by:
removeDrawingClickListenerin interfaceDrawing- Parameters:
listener- DrawingClickListener to remove from this Drawing.
-
createMarker
public org.insa.graphs.gui.drawing.components.BasicDrawing.BasicMarkerOverlay createMarker(Point point, java.awt.Color outer, java.awt.Color inner, Drawing.AlphaMode mode)
-
drawMarker
public MarkerOverlay drawMarker(Point point, java.awt.Color outer, java.awt.Color inner, Drawing.AlphaMode mode)
Description copied from interface:DrawingDraw a marker at the given position using the given colors and according to the given mode.- Specified by:
drawMarkerin interfaceDrawing- Parameters:
point- Position of the marker to draw.outer- Color for the outer part of the marker to draw.inner- Color for the inner part of the marker to draw.mode- Mode for filling the inner par of the marker.- Returns:
- A MarkerOverlay instance representing the newly drawn marker.
-
createPointSetOverlay
public PointSetOverlay createPointSetOverlay()
Description copied from interface:DrawingCreate a new PointSetOverlay that can be used to add overlay points to this drawing. PointSetOverlay are heavy memory resources, do not use one for each point!- Specified by:
createPointSetOverlayin interfaceDrawing- Returns:
- A new PointSetOverlay for this drawing.
-
createPointSetOverlay
public PointSetOverlay createPointSetOverlay(int width, java.awt.Color color)
Description copied from interface:DrawingCreate a new PointSetOverlay with the given initial width and color that can be used to add overlay points to this drawing. PointSetOverlay are heavy memory resources, do not use one for each point!- Specified by:
createPointSetOverlayin interfaceDrawing- Parameters:
width- Initial width of points in the overlay.color- Initial width of points in the overlay.- Returns:
- A new PointSetOverlay for this drawing.
-
drawArc
protected void drawArc(Arc arc, GraphPalette palette, boolean repaint)
Draw the given arc.- Parameters:
arc- Arc to draw.palette- Palette to use to retrieve color and width for arc, or null to use current settings.
-
initialize
protected void initialize(Graph graph)
Initialize the drawing for the given graph.- Parameters:
graph-
-
drawGraph
public void drawGraph(Graph graph, GraphPalette palette)
Description copied from interface:DrawingDraw the given graph using the given palette.- Specified by:
drawGraphin interfaceDrawing- Parameters:
graph- Graph to draw.palette- Palette to use to draw the graph.- See Also:
BasicGraphPalette,BlackAndWhiteGraphPalette
-
drawGraph
public void drawGraph(Graph graph)
Description copied from interface:DrawingDraw the given graph using a default palette specific to the implementation.
-
drawPath
public PathOverlay drawPath(Path path, java.awt.Color color, boolean markers)
Description copied from interface:DrawingDraw a path using the given color.
-
drawPath
public PathOverlay drawPath(Path path, java.awt.Color color)
Description copied from interface:DrawingDraw a path with both origin and destination markers using the given color.- Specified by:
drawPathin interfaceDrawing- Parameters:
path- Path to draw.color- Color of the path to draw.- Returns:
- A PathOverlay instance representing the newly drawn path.
- See Also:
Drawing.drawPath(Path, Color, boolean)
-
drawPath
public PathOverlay drawPath(Path path)
Description copied from interface:DrawingDraw a path with both origin and destination markers using a default color specific to the implementation- Specified by:
drawPathin interfaceDrawing- Parameters:
path- Path to draw.- Returns:
- A PathOverlay instance representing the newly drawn path.
- See Also:
Drawing.drawPath(Path, Color, boolean)
-
drawPath
public PathOverlay drawPath(Path path, boolean markers)
Description copied from interface:DrawingDraw a path using a default color specific to the implementation- Specified by:
drawPathin interfaceDrawing- Parameters:
path- Path to draw.markers- true to show origin and destination markers.- Returns:
- A PathOverlay instance representing the newly drawn path.
- See Also:
Drawing.drawPath(Path, Color, boolean)
-
-