From: Sean B. <sbr...@ya...> - 2007-04-05 01:45:20
|
Looks good, this is checked in with commit 1738, http://triplea.svn.sourceforge.net/viewvc/triplea?view=rev&revision=1738 Sean --- Mark Rafn <da...@da...> wrote: > This just puts the small nationality icon over the > unit icon in the > territory panel. Makes it easier to tell who's who > on crowded maps with > icon colors that don't differ enough :) > -- > Mark Rafn da...@da... <http://www.dagon.net/>> Index: > triplea/src/games/strategy/ui/OverlayIcon.java > =================================================================== > --- triplea/src/games/strategy/ui/OverlayIcon.java > (revision 0) > +++ triplea/src/games/strategy/ui/OverlayIcon.java > (revision 0) > @@ -0,0 +1,50 @@ > +package games.strategy.ui; > + > +import java.awt.Component; > +import java.awt.Graphics; > + > +import javax.swing.Icon; > +import javax.swing.SwingConstants; > + > +/** > + * Make one icon from two. > + */ > +public class OverlayIcon implements Icon > +{ > + private final Icon m_back; > + private final Icon m_front; > + private final int m_x_offset; > + private final int m_y_offset; > + > + /** > + * Create a composite icon by overlaying the > front icon over the back icon. > + * @param back back icon > + * @param front front icon > + * @param x, y position of front icon relative > to back icon. > + */ > + public OverlayIcon(Icon back, Icon front, int > x, int y) { > + m_back = back; > + m_front = front; > + m_x_offset = x; > + m_y_offset = y; > + } > + > + public int getIconHeight() > + { > + return m_back.getIconHeight() > > (m_front.getIconHeight() + m_y_offset) ? > + m_back.getIconHeight() : > (m_front.getIconHeight() + m_y_offset); > + } > + > + public int getIconWidth() > + { > + return m_back.getIconWidth() > > (m_front.getIconWidth() + m_x_offset) ? > + m_back.getIconWidth() : > (m_front.getIconWidth() + m_x_offset); > + } > + > + public void paintIcon(Component c, Graphics g, > int x, int y) > + { > + m_back.paintIcon(c, g, x, y); > + m_front.paintIcon(c, g, x + m_x_offset, y + > m_y_offset); > + } > + > +} > > Property changes on: > triplea/src/games/strategy/ui/OverlayIcon.java > ___________________________________________________________________ > Name: svn:executable > + * > > Index: > triplea/src/games/strategy/triplea/ui/TerritoryDetailPanel.java > =================================================================== > --- > triplea/src/games/strategy/triplea/ui/TerritoryDetailPanel.java > (revision 1733) > +++ > triplea/src/games/strategy/triplea/ui/TerritoryDetailPanel.java > (working copy) > @@ -17,6 +17,7 @@ > import games.strategy.engine.data.*; > import > games.strategy.triplea.oddsCalculator.ta.OddsCalculatorDialog; > import games.strategy.triplea.util.*; > +import games.strategy.ui.OverlayIcon; > > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > @@ -129,12 +130,19 @@ > add(Box.createVerticalStrut(15)); > } > > - ImageIcon icon = > m_uiContext.getUnitImageFactory().getIcon( > + ImageIcon unitIcon = > m_uiContext.getUnitImageFactory().getIcon( > item.getType(), item.getOwner(), > m_data, item.getDamaged()); > + ImageIcon flagIcon = new ImageIcon( > + > m_uiContext.getFlagImageFactory().getSmallFlag(item.getOwner())); > + > + // overlay flag onto upper-right of > icon > + Icon flaggedUnitIcon = new > OverlayIcon(unitIcon, flagIcon, > + unitIcon.getIconWidth() - > flagIcon.getIconWidth() - 3, 3); > + > JLabel label = new JLabel("x" + > item.getUnits().size(), > - icon, > - > SwingConstants.LEFT > - ); > + flaggedUnitIcon, > + SwingConstants.LEFT > + ); > > add(label); > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> _______________________________________________ > Triplea-developers mailing list > Tri...@li... > https://lists.sourceforge.net/lists/listinfo/triplea-developers > ____________________________________________________________________________________ Food fight? Enjoy some healthy debate in the Yahoo! Answers Food & Drink Q&A. http://answers.yahoo.com/dir/?link=list&sid=396545367 |