Changeset 1793 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-07-15T17:58:37+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableCellRenderer.java
r1790 r1793 4 4 import java.awt.Color; 5 5 import java.awt.Component; 6 import java.text.DecimalFormat;7 6 import java.util.ArrayList; 8 7 import java.util.Collections; 9 8 import java.util.HashMap; 10 9 11 import javax.swing.BorderFactory;12 10 import javax.swing.ImageIcon; 13 11 import javax.swing.JLabel; 14 12 import javax.swing.JTable; 15 import javax.swing.border.Border;16 13 import javax.swing.table.TableCellRenderer; 17 14 18 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 20 import org.openstreetmap.josm.data.osm.RelationMember;21 17 import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 22 18 import org.openstreetmap.josm.tools.ImageProvider; … … 27 23 */ 28 24 public class MemberTableCellRenderer extends JLabel implements TableCellRenderer { 29 private final static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000");30 25 public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 31 26 public final static Color BGCOLOR_EMPTY_ROW = new Color(234,234,234); 32 27 33 28 public final static Color BGCOLOR_NOT_IN_OPPOSITE = new Color(255,197,197); 34 public final static Color BGCOLOR_IN_OPPOSITE = new Color(255,234,213); 35 public final static Color BGCOLOR_SAME_POSITION_IN_OPPOSITE = new Color(217,255,217); 29 public final static Color BGCOLOR_DOUBLE_ENTRY = new Color(255,234,213); 36 30 37 public final static Color BGCOLOR_PARTICIPAING_IN_COMPARISON = Color.BLACK;38 public final static Color FGCOLOR_PARTICIPAING_IN_COMPARISON = Color.WHITE;39 40 public final static Color BGCOLOR_FROZEN = new Color(234,234,234);41 31 42 32 private HashMap<OsmPrimitiveType, ImageIcon> icons; 43 private Border rowNumberBorder = null;44 33 45 34 /** … … 107 96 } 108 97 109 110 protected void renderBackground( boolean isSelected) { 98 protected void renderBackground( MemberTableModel model, OsmPrimitive primitive, boolean isSelected) { 111 99 Color bgc = Color.WHITE; 112 100 if (isSelected) { 113 101 bgc = BGCOLOR_SELECTED; 102 } else if (primitive != null && model.getNumMembersWithPrimitive(primitive) > 1) { 103 bgc = BGCOLOR_DOUBLE_ENTRY; 114 104 } 115 105 setBackground(bgc); … … 133 123 134 124 reset(); 135 renderBackground(isSelected); 125 136 126 renderForeground(isSelected); 137 127 switch(column) { 138 128 case 0: 139 129 String role = (String)value; 130 renderBackground(getModel(table), null, isSelected); 140 131 setText(role); 141 132 break; 142 133 case 1: 143 134 OsmPrimitive primitive = (OsmPrimitive)value; 135 renderBackground(getModel(table), primitive, isSelected); 144 136 renderPrimitive(primitive); 145 137 break; 146 138 case 2: 147 139 setText(""); 140 renderBackground(getModel(table), null, isSelected); 148 141 break; 149 142 default: -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1792 r1793 310 310 fireMakeMemberVisible(idx+1); 311 311 } 312 313 /** 314 * Replies the number of members which refer to a particular primitive 315 * 316 * @param primitive the primitive 317 * @return the number of members which refer to a particular primitive 318 */ 319 public int getNumMembersWithPrimitive(OsmPrimitive primitive) { 320 int count = 0; 321 for (RelationMember member : members) { 322 if (member.member.equals(primitive)) { 323 count++; 324 } 325 } 326 return count; 327 } 312 328 }
Note:
See TracChangeset
for help on using the changeset viewer.