org.gjt.universe.gui
Class PlanetDiagramPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.gjt.universe.gui.PlanetDiagramPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class PlanetDiagramPanel
extends javax.swing.JPanel
implements java.awt.ItemSelectable, java.awt.event.MouseListener, java.awt.event.ActionListener

This class is a panel used to diagramatically represent a particular planetary body. A planetary body is a planet or a moon. The diagram represents its characteristics (e.g. surface, atmosphere, population, etc.) and any fleets which might be in orbit around it.

TO DO:

See Also:
Serialized Form

Field Summary
private static java.lang.String BOMBARD_CMD_STR
           
private static java.lang.String COLONIZE_CMD_STR
           
private static java.lang.String DESTROY_CMD_STR
           
private static java.lang.String DETAILS_CMD_STR
           
private static java.lang.String INVADE_CMD_STR
           
private  boolean isSelected
           
protected  javax.swing.event.EventListenerList listenerList
           
private  PlanetBase myPlanet
           
private  CivID myViewerCivID
           
private static java.lang.String NEW_WINDOW_CMD_STR
           
private static java.awt.Dimension ourMinimumSize
           
private static java.lang.String SUBVERT_CMD_STR
           
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
PlanetDiagramPanel(CivID viewer, PlanetBase aPlanet)
          Designated constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addItemListener(java.awt.event.ItemListener l)
           
private  void drawAtmosphere(java.awt.Graphics2D g2d, int boundsWidth, int boundsHeight, int surfaceDiameter, int atmDiameter)
          This method draws a representation of the planet's atmosphere such that its chemical composition and thickness can be visually discerned by the user.
private  void drawBorder(java.awt.Graphics2D g2d, int boundsWidth, int boundsHeight, int borderDiameter, int borderThickness)
          This method draws a border around the planet if it is owned by a civilization and does nothing if not.
(package private)  void fireItemEvent(int selected)
           
 PlanetID getPlanetID()
          This method returns the ID of the planet which is being represented in the panel.
 java.lang.Object[] getSelectedObjects()
           
 boolean isSelected()
          Returns whether or not the panel is considered selected or not.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          Called whenever the user mouse clicks this panel.
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintComponent(java.awt.Graphics g)
          This method has been extended to do the actual drawing of the planet.
 void removeItemListener(java.awt.event.ItemListener l)
           
 void setPreferredSize(java.awt.Dimension newSize)
          This inherited method has be overridden to automatically ensure that neither axis of the provided argument is less than the minimum size supported by this instance.
 void setSelected(boolean newValue)
          Sets whether or not the panel is considered selected or not.
 
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, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, 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

ourMinimumSize

private static java.awt.Dimension ourMinimumSize

DETAILS_CMD_STR

private static final java.lang.String DETAILS_CMD_STR
See Also:
Constant Field Values

NEW_WINDOW_CMD_STR

private static final java.lang.String NEW_WINDOW_CMD_STR
See Also:
Constant Field Values

COLONIZE_CMD_STR

private static final java.lang.String COLONIZE_CMD_STR
See Also:
Constant Field Values

SUBVERT_CMD_STR

private static final java.lang.String SUBVERT_CMD_STR
See Also:
Constant Field Values

INVADE_CMD_STR

private static final java.lang.String INVADE_CMD_STR
See Also:
Constant Field Values

BOMBARD_CMD_STR

private static final java.lang.String BOMBARD_CMD_STR
See Also:
Constant Field Values

DESTROY_CMD_STR

private static final java.lang.String DESTROY_CMD_STR
See Also:
Constant Field Values

isSelected

private boolean isSelected

myPlanet

private PlanetBase myPlanet

myViewerCivID

private CivID myViewerCivID

listenerList

protected javax.swing.event.EventListenerList listenerList
Constructor Detail

PlanetDiagramPanel

public PlanetDiagramPanel(CivID viewer,
                          PlanetBase aPlanet)
Designated constructor.

Parameters:
viewer - The ID of the civilization which is doing the viewing.
aPlanet - The planetary body which is to be shown.
Method Detail

getPlanetID

public PlanetID getPlanetID()
This method returns the ID of the planet which is being represented in the panel.


setPreferredSize

public void setPreferredSize(java.awt.Dimension newSize)
This inherited method has be overridden to automatically ensure that neither axis of the provided argument is less than the minimum size supported by this instance. If so, the larger minimum value is substituted.

Overrides:
setPreferredSize in class javax.swing.JComponent
Parameters:
newSize - The dimension to be adopted.

paintComponent

protected void paintComponent(java.awt.Graphics g)
This method has been extended to do the actual drawing of the planet.

Overrides:
paintComponent in class javax.swing.JComponent

drawAtmosphere

private void drawAtmosphere(java.awt.Graphics2D g2d,
                            int boundsWidth,
                            int boundsHeight,
                            int surfaceDiameter,
                            int atmDiameter)
This method draws a representation of the planet's atmosphere such that its chemical composition and thickness can be visually discerned by the user.

Parameters:
g2d - Graphics context for drawing
boundsWidth - The current width of this panel's bounds
boundsHeight - The current height of this panel's bounds
surfaceDiameter - The diameter of the circle drawn to represent the surface of the planet
atmDiameter - The diameter of the circle drawn to represent the planet's atmosphere (slightly larger than surfaceDiameter)

drawBorder

private void drawBorder(java.awt.Graphics2D g2d,
                        int boundsWidth,
                        int boundsHeight,
                        int borderDiameter,
                        int borderThickness)
This method draws a border around the planet if it is owned by a civilization and does nothing if not.

Parameters:
g2d - Graphics context for drawing
boundsWidth - The current width of this panel's bounds
boundsHeight - The current height of this panel's bounds
borderDiameter - The diameter of the border circle
borderThickness - The thickness that should be used to draw the border.

isSelected

public boolean isSelected()
Returns whether or not the panel is considered selected or not.


setSelected

public void setSelected(boolean newValue)
Sets whether or not the panel is considered selected or not.

If the new value differs from the current one then all registered listeners will be notified in the change in state.

Parameters:
newValue - True if the panel should be considered selected. False otherwise.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Called whenever the user mouse clicks this panel. Toggles the current selection state.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Specified by:
getSelectedObjects in interface java.awt.ItemSelectable

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Specified by:
addItemListener in interface java.awt.ItemSelectable

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Specified by:
removeItemListener in interface java.awt.ItemSelectable

fireItemEvent

void fireItemEvent(int selected)


Copyright © 2001 Universe Dev Team All Rights Reserved.