 | | Interface Manipulation Package v4.0 (2008-06-25) |  | ©copyright |  |
imp.gui
Class Polyline
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
imp.gui.Polyline
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable
public class Polyline
- extends JComponent
Defines a polygon/polyline object drawn in a canvas and contains predefined polygon.
- See Also:
- Serialized Form
Constructor Summary |
Polyline(Polygon polygon,
boolean closed,
Color bgcolor,
Color color)
Constructs a polyline of a given color. |
Method Summary |
boolean |
contains(int x,
int y)
Determines whether the specified coordinates are inside this polygon. |
Rectangle |
getBounds()
Returns the polyline bounds. |
static Polygon |
getCross(int x,
int y,
char c,
int size)
Returns a cross of center (x,y) and given size. |
static Polygon |
getEllipse(int x,
int y,
double I_xx,
double I_xy,
double I_yy)
Returns an ellipse of center (x,y), and second-order momenta (I_xx,I_xy,I_yy). |
static Polygon |
getLine(int x1,
int y1,
int x2,
int y2,
boolean arrow)
Returns a line-segment between (x1,y1) and (x2,y2) with an optional arrow. |
static Polygon |
getOval(int x,
int y,
int width,
int height,
double alpha,
double gamma)
Returns an oval (a super-ellipse) of center (x,y), orientation alpha in radian, sizes (width x height) and rectangularity gamma. |
static Polygon |
getPolarLine(int x,
int y,
int size,
double alpha,
boolean arrow)
Returns a line-segment of center (x,y), orientation alpha in radian, of given size, with an optional arrow. |
static Polygon |
getPolygon(Value points)
Returns a polygon defined by a list of points obtained from an XML construct. |
static Polygon |
getRectangle(int x,
int y,
int width,
int height)
Returns a rectangle of center (x,y) and size (width x height). |
int[] |
projection(int x,
int y)
Returns the projection (closest point) of (x,y) onto the polyline. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, 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, 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, transferFocus, transferFocusUpCycle |
Polyline
public Polyline(Polygon polygon,
boolean closed,
Color bgcolor,
Color color)
- Constructs a polyline of a given color.
- Parameters:
polygon
- Points defining this polyline.closed
- True if the polyline is closed (geometric polygon), false if not.bgcolor
- Polygon fill color, if any (else null).color
- Polyline border color, if any (else null).
contains
public boolean contains(int x,
int y)
- Determines whether the specified coordinates are inside this polygon.
- Overrides:
contains
in class JComponent
getBounds
public Rectangle getBounds()
- Returns the polyline bounds.
- Overrides:
getBounds
in class Component
getCross
public static Polygon getCross(int x,
int y,
char c,
int size)
- Returns a cross of center (x,y) and given size.
- Parameters:
x
- Horizontal location. As double:
Rounded value.y
- Vertical location. As double:
Rounded value.c
- [optional, default is 'x'] Cross pattern:
'x' for a x cross, '+' for a + cross, 's' for a square, 'o' for a circle.size
- [optional, default is 5] Cross size. As double:
Rounded value.
getEllipse
public static Polygon getEllipse(int x,
int y,
double I_xx,
double I_xy,
double I_yy)
- Returns an ellipse of center (x,y), and second-order momenta (I_xx,I_xy,I_yy).
This ellipse corresponds to the equation x^2 / I_xx + 2 x y / I_xy + y^2 / I_yy = 1
- Parameters:
x
- Horizontal location. As double:
Rounded value.y
- Vertical location. As double:
Rounded value.I_xx
- Second order momentum.I_xy
- Second order momentum.I_yy
- Second order momentum.
getLine
public static Polygon getLine(int x1,
int y1,
int x2,
int y2,
boolean arrow)
- Returns a line-segment between (x1,y1) and (x2,y2) with an optional arrow.
- Parameters:
x1
- Horizontal location. As double:
Rounded value.y1
- Vertical location. As double:
Rounded value.x2
- Horizontal location. As double:
Rounded value.y2
- Vertical location. As double:
Rounded value.arrow
- [optional, default is false] Whether this line has an arrow at (x2, y2).
getOval
public static Polygon getOval(int x,
int y,
int width,
int height,
double alpha,
double gamma)
- Returns an oval (a super-ellipse) of center (x,y), orientation alpha in radian, sizes (width x height) and rectangularity gamma.
This oval corresponds to the equation (x/width)^gamma + (y/height)^gamma = 1
- Parameters:
x
- Horizontal location. As double:
Rounded value.y
- Vertical location. As double:
Rounded value.width
- Oval width. As double:
Rounded value.height
- [optional, default is with] Oval height. Default value is the width (thus defining a circle). As double:
Rounded value.alpha
- [optional, default is 0] Oval orientation (radian). Default is 0 (thus defining an horizontal ellipse).gamma
- [optional, default is 2] Rectangularity. Default is 2 (thus defining an ellipse).
getPolarLine
public static Polygon getPolarLine(int x,
int y,
int size,
double alpha,
boolean arrow)
- Returns a line-segment of center (x,y), orientation alpha in radian, of given size, with an optional arrow.
- Parameters:
x
- Horizontal location. As double:
Rounded value.y
- Vertical location. As double:
Rounded value.alpha
- Line orientation (radian).size
- Line size.arrow
- [optional, default is false] Whether this line has an arrow at (x2, y2).
getPolygon
public static Polygon getPolygon(Value points)
- Returns a polygon defined by a list of points obtained from an XML construct.
- Parameters:
points
- A construct of either the form <.. x-a='..' y-a='..' x-b='..' y-b='..' .. /> or <..><<.. x=".." y=".."/>... As String:
The construct in a String.
getRectangle
public static Polygon getRectangle(int x,
int y,
int width,
int height)
- Returns a rectangle of center (x,y) and size (width x height).
- Parameters:
x
- Horizontal location. As double:
Rounded value.y
- Vertical location. As double:
Rounded value.width
- Rectangle width. As double:
Rounded value.height
- [optional, default is width] Rectangle height. Default value is the width (thus defining a square). As double:
Rounded value.
projection
public int[] projection(int x,
int y)
- Returns the projection (closest point) of (x,y) onto the polyline.