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 GraphPalette
DEFAULT_PALETTE
static java.awt.Color
DEFAULT_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 void
addDrawingClickListener(DrawingClickListener listener)
Add a listener to click to this drawing.void
clear()
Clear the drawing (overlays and underlying graph/map).void
clearOverlays()
Remove overlays from the drawing (do not remove the underlying graph/map).org.insa.graphs.gui.drawing.components.BasicDrawing.BasicMarkerOverlay
createMarker(Point point, java.awt.Color outer, java.awt.Color inner, Drawing.AlphaMode mode)
PointSetOverlay
createPointSetOverlay()
Create a new PointSetOverlay that can be used to add overlay points to this drawing.PointSetOverlay
createPointSetOverlay(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 void
drawArc(Arc arc, GraphPalette palette, boolean repaint)
Draw the given arc.void
drawGraph(Graph graph)
Draw the given graph using a default palette specific to the implementation.void
drawGraph(Graph graph, GraphPalette palette)
Draw the given graph using the given palette.MarkerOverlay
drawMarker(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.PathOverlay
drawPath(Path path)
Draw a path with both origin and destination markers using a default color specific to the implementationPathOverlay
drawPath(Path path, boolean markers)
Draw a path using a default color specific to the implementationPathOverlay
drawPath(Path path, java.awt.Color color)
Draw a path with both origin and destination markers using the given color.PathOverlay
drawPath(Path path, java.awt.Color color, boolean markers)
Draw a path using the given color.protected Point
getLongitudeLatitude(java.awt.event.MouseEvent event)
Return the longitude and latitude corresponding to the given position of the MouseEvent.ZoomAndPanListener
getZoomAndPanListener()
protected void
initialize(Graph graph)
Initialize the drawing for the given graph.void
paintComponent(java.awt.Graphics g1)
void
removeDrawingClickListener(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:
paintComponent
in classjavax.swing.JComponent
-
clear
public void clear()
Description copied from interface:Drawing
Clear the drawing (overlays and underlying graph/map).
-
clearOverlays
public void clearOverlays()
Description copied from interface:Drawing
Remove overlays from the drawing (do not remove the underlying graph/map).- Specified by:
clearOverlays
in 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:Drawing
Add a listener to click to this drawing.- Specified by:
addDrawingClickListener
in interfaceDrawing
- Parameters:
listener
- DrawingClickListener to add to this Drawing.
-
removeDrawingClickListener
public void removeDrawingClickListener(DrawingClickListener listener)
Description copied from interface:Drawing
Remove the given listener from the drawing.- Specified by:
removeDrawingClickListener
in 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:Drawing
Draw a marker at the given position using the given colors and according to the given mode.- Specified by:
drawMarker
in 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:Drawing
Create 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:
createPointSetOverlay
in interfaceDrawing
- Returns:
- A new PointSetOverlay for this drawing.
-
createPointSetOverlay
public PointSetOverlay createPointSetOverlay(int width, java.awt.Color color)
Description copied from interface:Drawing
Create 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:
createPointSetOverlay
in 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:Drawing
Draw the given graph using the given palette.- Specified by:
drawGraph
in 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:Drawing
Draw 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:Drawing
Draw a path using the given color.
-
drawPath
public PathOverlay drawPath(Path path, java.awt.Color color)
Description copied from interface:Drawing
Draw a path with both origin and destination markers using the given color.- Specified by:
drawPath
in 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:Drawing
Draw a path with both origin and destination markers using a default color specific to the implementation- Specified by:
drawPath
in 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:Drawing
Draw a path using a default color specific to the implementation- Specified by:
drawPath
in 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)
-
-