public class Circle
extends javax.swing.JPanel
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_RADUIS
The minimum amount of distance between Circles in pixels when drawn on the GUI
|
static int |
DEFAULT_DIAMETER
The default diameter of Circles in pixels when drawn on the GUI
|
static java.awt.Color |
DEFAULT_NODE_COLOR |
static java.awt.Color |
DEFAULT_PARCEL_COLOR |
static java.awt.Color |
DEFAULT_TRUCK_COLOR |
static int |
PANEL_BUFFER
Extra space to add on diameter when calculating bounds
|
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Circle(BoardElement r,
int x,
int y,
int d)
Constructor: an instance at (x, y) of diameter d and colored black
that represents r and is not filled.
|
Circle(BoardElement r,
int x,
int y,
int d,
java.awt.Color c,
boolean filled)
Constructor: an instance at (x, y) of diameter d and colored c
that represents r and is filled iff filled.
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getColor()
Return the color of this circle.
|
int |
getDiameter()
Return the diameter field of this circle.
|
double |
getDistance(Circle c)
Return the distance between the centers of this Circle and c.
|
java.awt.Point |
getPoint()
Return the coordinates of this circle as a Point.
|
java.awt.Dimension |
getPreferredSize()
Return a bounding square (of size diameter * diameter) of the circle.
|
Vector |
getVectorTo(Circle c)
Return the vector from the center of this circle to the center of c.
|
int |
getX1()
Return the x coordinate of this circle.
|
int |
getY1()
Return the y coordinate of this circle.
|
boolean |
locationEquals(Circle c)
Return true iff the this circle has the same center as c
|
void |
paintComponent(java.awt.Graphics g)
Draw the Circle when the component is painted.
|
void |
setColor(java.awt.Color c)
Set the color of this circle to c.
|
void |
setX1(int x)
Set the x coordinate of this circle to x.
|
void |
setY1(int y)
Set the y coordinate of this circle to y
|
java.lang.String |
toString()
Return a string representation of this circle.
|
void |
updateColor()
Change the color according to the Color Policy
|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, 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
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, transferFocusDownCycle, validate
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, 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, transferFocusBackward, transferFocusUpCycle
public static final int DEFAULT_DIAMETER
public static final int PANEL_BUFFER
public static final int BUFFER_RADUIS
public static final java.awt.Color DEFAULT_TRUCK_COLOR
public static final java.awt.Color DEFAULT_NODE_COLOR
public static final java.awt.Color DEFAULT_PARCEL_COLOR
public Circle(BoardElement r, int x, int y, int d)
r
- - the Object this circle representsx
- - x coordinate of centery
- - y coordinate of centerd
- - the diameter of the circlepublic Circle(BoardElement r, int x, int y, int d, java.awt.Color c, boolean filled)
x
- - x coordinate of centery
- - y coordinate of centerd
- - the diameter of the circlec
- - the Color of this circle - if null, uses the default color for representsfilled
- - whether or not this circle is filled when it is drawnpublic int getX1()
public void setX1(int x)
public int getY1()
public void setY1(int y)
public java.awt.Color getColor()
public java.awt.Point getPoint()
public void setColor(java.awt.Color c)
java.lang.IllegalArgumentException
- - if c is not in Score.COLORS.public int getDiameter()
public void updateColor()
public double getDistance(Circle c)
public boolean locationEquals(Circle c)
public Vector getVectorTo(Circle c)
public java.lang.String toString()
toString
in class java.awt.Component
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent