yops
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 yops.Graphic
                      extended by yops.Line
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, 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.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class yops.Graphic
THICK_STROKE
 
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.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(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.
 String toString()
          Returns a String representation of the Line, including the coordinates of its end points.
 
Methods inherited from class yops.Graphic
add, setFillColor, setLineColor
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, 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, 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, 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, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, 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 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 JComponent

paint

public void paint(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 JComponent

toString

public 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.