nip
Class Line

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by nip.Graphic
                      extended by nip.Line
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Line
extends Graphic

A Line is a visual display of a line segment defined by the coordinates of two pixels at its end points.

Author:
Kenneth J. Goldman
Created Jun 28, 2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
Line(int x1, int y1, int x2, int y2)
          Creates a Line with the given end points.
 
Method Summary
 boolean contains(int x, int y)
          This contains method reports true if the given point is on, or very near, the line segment.
 boolean isFilled()
          I If a Graphic is filled, it will be painted in a solid color.
 void paint(java.awt.Graphics g)
          Paints the Line when requested by the Java's graphics system.
 void setCenter(int x, int y)
          Sets the location of this Graphic so that its center is at the given pixel coordinates within its container.
 void setCorners(int x1, int y1, int x2, int y2)
          Changes the endpoints of the line, as well as the bounding box of the graphic based on any two diagonally opposite corners.
 void setFilled(boolean filled)
          Sets whether or not the graphic should be filled (painted in a solid color).
 void setSize(int x, int y)
           
 void setUpperLeft(int x, int y)
          Sets the location of this Graphic so that its upper left corner is at the given pixel coordinates within its container.
 java.lang.String toString()
          Returns a String representation of the Line, including the coordinates of its end points.
 
Methods inherited from class nip.Graphic
add, getCenterX, getCenterY, setFillColor, setLineColor
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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
 
Methods inherited from class java.awt.Container
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, 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, 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, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Line

public Line(int x1,
            int y1,
            int x2,
            int y2)
Creates a Line with the given end points.

Parameters:
x1 - the x coordinate of the first end point
y1 - the y coordinate of the first end point
x2 - the x coordinate of the second end point
y2 - the y coordinate of the second end point
Method Detail

isFilled

public boolean isFilled()
Description copied from class: Graphic
I If a Graphic is filled, it will be painted in a solid color.

Overrides:
isFilled in class Graphic
Returns:
true if the Graphic is filled.

setFilled

public void setFilled(boolean filled)
Description copied from class: Graphic
Sets whether or not the graphic should be filled (painted in a solid color). A Graphic will ignore this method if its filled status cannot be changed.

Overrides:
setFilled in class Graphic
Parameters:
filled - whether or not the Graphic should be filled

setCorners

public void setCorners(int x1,
                       int y1,
                       int x2,
                       int y2)
Changes the endpoints of the line, as well as the bounding box of the graphic based on any two diagonally opposite corners.

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point

setSize

public void setSize(int x,
                    int y)
Overrides:
setSize in class java.awt.Component

setCenter

public void setCenter(int x,
                      int y)
Description copied from class: Graphic
Sets the location of this Graphic so that its center is at the given pixel coordinates within its container.

Overrides:
setCenter in class Graphic
Parameters:
x - in pixels
y - in pixels

setUpperLeft

public void setUpperLeft(int x,
                         int y)
Description copied from class: Graphic
Sets the location of this Graphic so that its upper left corner is at the given pixel coordinates within its container. (This is the same as setLocation.)

Overrides:
setUpperLeft in class Graphic
Parameters:
x - in pixels
y - in pixels

contains

public boolean contains(int x,
                        int y)
This contains method reports true if the given point is on, or very near, the line segment. The reason for this inexactness is to support selection; it would be difficult for a user to position the cursor exactly on the thin region defined by the line.

Overrides:
contains in class javax.swing.JComponent

paint

public void paint(java.awt.Graphics g)
Paints the Line when requested by the Java's graphics system. You should not need to call this method. If you want to specifically request that a component be repainted, call Component.repaint(). (If you do not see the line, it may not have been added to a visible container, it may be behind another graphic, its color may blend with the background, or its coordinates may be outside the visible region of the container.)

Overrides:
paint in class javax.swing.JComponent

toString

public java.lang.String toString()
Returns a String representation of the Line, including the coordinates of its end points.

Overrides:
toString in class Graphic
Returns:
a String description of this graphic, including its class name, upper left corner, and pixel dimensions.