Changeset 1793 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-07-15T17:58:37+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #2638: Relation editor should show double entries better

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  
    44import java.awt.Color;
    55import java.awt.Component;
    6 import java.text.DecimalFormat;
    76import java.util.ArrayList;
    87import java.util.Collections;
    98import java.util.HashMap;
    109
    11 import javax.swing.BorderFactory;
    1210import javax.swing.ImageIcon;
    1311import javax.swing.JLabel;
    1412import javax.swing.JTable;
    15 import javax.swing.border.Border;
    1613import javax.swing.table.TableCellRenderer;
    1714
    1815import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1916import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    20 import org.openstreetmap.josm.data.osm.RelationMember;
    2117import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
    2218import org.openstreetmap.josm.tools.ImageProvider;
     
    2723 */
    2824public  class MemberTableCellRenderer extends JLabel implements TableCellRenderer {
    29     private final static DecimalFormat COORD_FORMATTER = new DecimalFormat("###0.0000");
    3025    public final static Color BGCOLOR_SELECTED = new Color(143,170,255);
    3126    public final static Color BGCOLOR_EMPTY_ROW = new Color(234,234,234);
    3227
    3328    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);
    3630
    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);
    4131
    4232    private HashMap<OsmPrimitiveType, ImageIcon>  icons;
    43     private  Border rowNumberBorder = null;
    4433
    4534    /**
     
    10796    }
    10897
    109 
    110     protected void renderBackground( boolean isSelected) {
     98    protected void renderBackground( MemberTableModel model, OsmPrimitive primitive, boolean isSelected) {
    11199        Color bgc = Color.WHITE;
    112100        if (isSelected) {
    113101            bgc = BGCOLOR_SELECTED;
     102        } else if (primitive != null && model.getNumMembersWithPrimitive(primitive) > 1) {
     103            bgc = BGCOLOR_DOUBLE_ENTRY;
    114104        }
    115105        setBackground(bgc);
     
    133123
    134124        reset();
    135         renderBackground(isSelected);
     125
    136126        renderForeground(isSelected);
    137127        switch(column) {
    138128        case 0:
    139129            String role = (String)value;
     130            renderBackground(getModel(table), null, isSelected);
    140131            setText(role);
    141132            break;
    142133        case 1:
    143134            OsmPrimitive primitive = (OsmPrimitive)value;
     135            renderBackground(getModel(table), primitive, isSelected);
    144136            renderPrimitive(primitive);
    145137            break;
    146138        case 2:
    147139            setText("");
     140            renderBackground(getModel(table), null, isSelected);
    148141            break;
    149142        default:
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r1792 r1793  
    310310        fireMakeMemberVisible(idx+1);
    311311    }
     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    }
    312328}
Note: See TracChangeset for help on using the changeset viewer.