|
e-Mohr v. 1.00 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
wc.CanvasWC
This CanvasWC class extends the JPanel class to
provide control over displaying using a device-independent coordinate
system called World Coordinates (WC), which is used by applications.
Displaying is buffered to a BufferedImage object (offscreen
image) to emulate double buffering rendering. The BufferedImage
object contains a Graphics2D object as part of its rendering state.
The Graphics2D object contains an AffineTransform
object that defines how to convert coordinates from client space (world
coordinates) to device-dependent (raster) coordinates in device space.
Clients need to extend this class, by creating subclasses, in order to use it.
The vertical Y axis of the CanvasWC object is set by default
in downward direction, but clients may specify it in upward direction
when the canvas is created.
===================
JPanel,
Graphics2D,
BufferedImage,
MouseListener,
MouseMotionListener,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
static int |
BASE_CENTER
Field constant used to define text alignment. |
static int |
BASE_LEFT
Field constant used to define text alignment. |
static int |
BASE_RIGHT
Field constant used to define text alignment. |
static int |
CENTER
Field constant used to define text alignment. |
static int |
DOWNWARD_Y
Field constant used to define the vertical Y axis of the canvas in downward direction. |
static int |
EAST
Field constant used to define text alignment. |
private java.awt.Point |
ept_raster
Private field that holds a mouse event point in raster (device) coordinates. |
private java.awt.geom.Point2D.Double |
ept_world
Private field that holds a mouse event point in world coordinates. |
private java.awt.Font |
fnt
Private field that holds current font that is used to display text. |
private java.awt.font.FontRenderContext |
frc
Font renderer context: private field that is a container for the information needed to measure text that is displayed. |
private java.awt.Graphics2D |
g2off
Graphics context object (Graphics2D) that contains an AffineTransform object that defines how to convert coordinates from client space (world coordinates) to device-dependent (raster) coordinates in device space. |
private java.awt.Graphics |
goff
Graphics context object (Graphics) of the offscreen image used privately for double buffering. |
(package private) java.awt.geom.AffineTransform |
identity
Private field that holds an auxiliary identity affine transformation matrix. |
private java.awt.image.BufferedImage |
ioff
BufferedImage object that is used to implement double buffering rendering. |
static int |
NORTH
Field constant used to define text alignment. |
static int |
NORTH_EAST
Field constant used to define text alignment. |
static int |
NORTH_WEST
Field constant used to define text alignment. |
static int |
OPAQUE
Field constant used to define opaque text background opacity. |
private java.awt.Point |
pt_raster
Private field that holds a auxiliary point in raster (device) coordinates. |
private java.awt.geom.Point2D.Double |
pt_world
Private field that holds a auxiliary point in world coordinates. |
protected java.awt.Dimension |
raster_area
Defines the canvas raster area. |
static int |
SOUTH
Field constant used to define text alignment. |
static int |
SOUTH_EAST
Field constant used to define text alignment. |
static int |
SOUTH_WEST
Field constant used to define text alignment. |
private int |
text_alignment
Private field that holds current text alignment parameter. |
private java.awt.Rectangle |
text_box
Private field that holds text box for opaque displaying. |
private int |
text_opacity
Private field that holds current text alignment parameter. |
static int |
TRANSPARENT
Field constant used to define transparent text background opacity. |
static int |
UPWARD_Y
Field constant used to define the vertical Y axis of the canvas in upward direction. |
protected double |
vdistortion
Keeps the WC window vertical distortion factor. |
static int |
WEST
Field constant used to define text alignment. |
protected java.awt.geom.Rectangle2D.Double |
world_area
Defines the canvas world coordinate area. |
protected java.awt.geom.Rectangle2D.Double |
world_raw
Defines the original canvas world coordinate area. |
protected int |
y_dir
Keeps the vertical Y axis direction state. |
| Fields inherited from class javax.swing.JPanel |
|
| 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.Container |
|
| 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 | |
CanvasWC()
Default constructor. |
|
CanvasWC(int y_dir)
Constructor that sets up WC canvas according to a given orientation. |
|
| Method Summary | |
private void |
adjustWorld()
Adjusts the window in world coordinates (world_area) to have the same aspect ratio between height and width of the canvas (in its current state). |
private void |
buildOffscreen()
Creates the BufferedImage object that is used to implement double buffering rendering. |
void |
drawString(java.lang.String text,
double x,
double y)
Draw a given string on a given position. |
double |
getVDistortion()
Gets the WC window vertical distortion factor. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Dummy method for the event of mouse clicked in canvas. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Handles the event of the user dragging the mouse while holding down the mouse button. |
abstract void |
mouseDraggedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
Mouse button dragged abstract method. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Dummy method for the event of mouse entered in canvas. |
void |
mouseExited(java.awt.event.MouseEvent e)
Dummy method for the event of mouse exited from canvas. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Dummy method for the event of mouse motion in canvas. |
void |
mousePressed(java.awt.event.MouseEvent e)
Handles the event of the user pressing down the mouse button. |
abstract void |
mousePressedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
Mouse button pressed abstract method. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Handles the event of the user releasing the mouse button. |
abstract void |
mouseReleasedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
Mouse button released abstract method. |
void |
paintComponent(java.awt.Graphics g)
Update method of canvas. |
void |
panWorldX(double fac)
Translates the world coordinate window of the target canvas in the horizontal direction based on a given pan factor. |
void |
panWorldY(double fac)
Translates the world coordinate window of the target canvas in the vertical direction based on a given pan factor. |
java.awt.geom.Point2D.Double |
raster2world(int raster_x,
int raster_y)
Transforms the coordinates of a point given in device space (raster) to client space (world coordinates). |
abstract void |
redraw(java.awt.Graphics2D g)
Redisplay abstract method. |
void |
scaleWorld(double fac)
Scales the world coordinate window of the target canvas based on the given scaling factor. |
void |
setFont(java.awt.Font fnt)
Set font to be used to display texts. |
void |
setTextAlignment(int text_alignment)
Set alignment to be used to display texts. |
void |
setTextOpacity(int text_opacity)
Set opacity to be used to display texts. |
void |
setVDistortion(double vdistortion)
Sets the WC window vertical distortion factor. |
void |
setWorld(double xmin,
double xmax,
double ymin,
double ymax)
Sets the limits of the world coordinate window for the target canvas. |
java.awt.Point |
world2raster(double world_x,
double world_y)
Transforms the coordinates of a point given in client space (WC) to device-dependent (raster) coordinates. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 |
protected java.awt.Dimension raster_area
Dimensionprotected java.awt.geom.Rectangle2D.Double world_area
Rectangle2D.Double,
vdistortion,
setWorld(double, double, double, double)protected java.awt.geom.Rectangle2D.Double world_raw
setWorld(double, double, double, double),
world_areapublic static final int DOWNWARD_Y
public static final int UPWARD_Y
protected int y_dir
DOWNWARD_Y (default) or UPWARD_Y. The
Y axis direction is specified during creation, when the
CanvasWC constructor is called.
private java.awt.image.BufferedImage ioff
private java.awt.Graphics goff
private java.awt.Graphics2D g2off
protected double vdistortion
setVDistortion(double),
world_areaprivate java.awt.geom.Point2D.Double pt_world
private java.awt.Point pt_raster
private java.awt.geom.Point2D.Double ept_world
private java.awt.Point ept_raster
public static final int TRANSPARENT
public static final int OPAQUE
private int text_opacity
private java.awt.Rectangle text_box
public static final int NORTH_WEST
public static final int NORTH
public static final int NORTH_EAST
public static final int SOUTH_WEST
public static final int SOUTH
public static final int SOUTH_EAST
public static final int WEST
public static final int CENTER
public static final int EAST
public static final int BASE_LEFT
public static final int BASE_CENTER
public static final int BASE_RIGHT
private int text_alignment
private java.awt.Font fnt
private java.awt.font.FontRenderContext frc
java.awt.geom.AffineTransform identity
| Constructor Detail |
public CanvasWC()
public CanvasWC(int y_dir)
y_dir - can either be DOWNWARD_Y or UPWARD_YDOWNWARD_Y,
UPWARD_Y| Method Detail |
public abstract void redraw(java.awt.Graphics2D g)
g - is the 2D graphics context that the client uses to display
public abstract void mousePressedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
e - is mouse event objectpt - is the mouse position in client's floating point world coordinates
public abstract void mouseDraggedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
e - is mouse event objectpt - is the mouse position in client's floating point world coordinates
public abstract void mouseReleasedWC(java.awt.event.MouseEvent e,
java.awt.geom.Point2D.Double pt)
e - is mouse event objectpt - is the mouse position in client's floating point world coordinatesprivate void buildOffscreen()
private void adjustWorld()
public void setWorld(double xmin,
double xmax,
double ymin,
double ymax)
The canvas is not automatically repainted by this method.
xmin - is the left limit of target windowxmax - is the right limit of target windowymin - is the bottom limit of target window if vertical Y axis is upward, otherwise it is the top limitymax - is the top limit of target window if vertical Y axis is upward, otherwise it is the bottom limitworld_area,
setVDistortion(double)public void panWorldX(double fac)
The canvas is not automatically repainted by this method.
fac - is the pan factorworld_area,
setWorld(double, double, double, double)public void panWorldY(double fac)
The canvas is not automatically repainted by this method.
fac - is the pan factorworld_area,
setWorld(double, double, double, double)public void scaleWorld(double fac)
The canvas is not automatically repainted by this method.
fac - is the scaling factorworld_area,
setWorld(double, double, double, double)public void setVDistortion(double vdistortion)
The canvas is not automatically repainted by this method.
vdistortion - is the vertical distortion factorvdistortion,
setWorld(double, double, double, double)public double getVDistortion()
vdistortion,
setVDistortion(double)
public java.awt.Point world2raster(double world_x,
double world_y)
CanvasWC object contains an AffineTransform
object that defines how to convert coordinates from client space (world
coordinates) to device-dependent (raster) coordinates in device space.
Note that, to avoid creating new point objects, the method returns a
reference to a private object and not a copy of a new point. If
needed, clients must clone the returned object.
world_x - is the x coordinate of given point in client spaceworld_y - is the y coordinate of given point in client space
setWorld(double, double, double, double),
raster2world(int, int)
public java.awt.geom.Point2D.Double raster2world(int raster_x,
int raster_y)
CanvasWC object contains an AffineTransform
object that defines how to convert coordinates from device-dependent
(raster) coordinates in device space to client space (world
coordinates).
Note that, to avoid creating new point objects, the method returns a
reference to a private object and not a copy of a new point. If
needed, clients must clone the returned object.
raster_x - is the x coordinate of the given point in device spaceraster_y - is the y coordinate of the given point in device space
setWorld(double, double, double, double),
world2raster(double, double)public void mousePressed(java.awt.event.MouseEvent e)
mousePressedWC
mousePressed in interface java.awt.event.MouseListenere - is mouse event objectmousePressedWC(java.awt.event.MouseEvent, java.awt.geom.Point2D.Double)public void mouseDragged(java.awt.event.MouseEvent e)
mouseDraggedWC
mouseDragged in interface java.awt.event.MouseMotionListenere - is mouse event objectmouseDraggedWC(java.awt.event.MouseEvent, java.awt.geom.Point2D.Double)public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleasedWC
mouseReleased in interface java.awt.event.MouseListenere - is mouse event objectmouseReleasedWC(java.awt.event.MouseEvent, java.awt.geom.Point2D.Double)public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenere - is mouse event objectpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenere - is mouse event objectpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenere - is mouse event objectpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenere - is mouse event objectpublic void paintComponent(java.awt.Graphics g)
BufferedImage object (offscreen image) to implement
double buffering rendering. In this case, the world coordinate window
defined by the client (if defined) is adjusted according to the new canvas
sizes.
Graphics2D graphics
context object of the offscreen image, so that the client may display
on it.
g - is the target graphics contextsetWorld(double, double, double, double),
redraw(java.awt.Graphics2D)public void setFont(java.awt.Font fnt)
public void setTextOpacity(int text_opacity)
public void setTextAlignment(int text_alignment)
public void drawString(java.lang.String text,
double x,
double y)
|
e-Mohr v. 1.00 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||