Changeset 2666 in josm


Ignore:
Timestamp:
2009-12-20T16:19:03+01:00 (14 years ago)
Author:
jttt
Message:

Minor mappaint cleanup, use constants for colors

Location:
trunk/src/org/openstreetmap/josm
Files:
2 added
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r2655 r2666  
    22package org.openstreetmap.josm.actions.mapmode;
    33
    4 import static org.openstreetmap.josm.tools.I18n.marktr;
    54import static org.openstreetmap.josm.tools.I18n.tr;
    65import static org.openstreetmap.josm.tools.I18n.trn;
     
    4847import org.openstreetmap.josm.data.osm.Way;
    4948import org.openstreetmap.josm.data.osm.WaySegment;
     49import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    5050import org.openstreetmap.josm.gui.MapFrame;
    5151import org.openstreetmap.josm.gui.MapView;
     
    208208        super.enterMode();
    209209        currCursor = Cursors.crosshair;
    210         selectedColor = Main.pref.getColor(marktr("selected"), Color.red);
     210        selectedColor =PaintColors.SELECTED.get();
    211211        drawHelperLine = Main.pref.getBoolean("draw.helper-line", true);
    212212        drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true);
     
    344344                newSelection.add(n);
    345345                getCurrentDataSet().setSelected(n);
    346                 selection = getCurrentDataSet().getSelected();
    347346                // The user explicitly selected a node, so let him continue drawing
    348347                wayIsFinished = false;
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r2450 r2666  
    22package org.openstreetmap.josm.actions.mapmode;
    33
    4 import static org.openstreetmap.josm.tools.I18n.marktr;
    54import static org.openstreetmap.josm.tools.I18n.tr;
    65
     
    3433import org.openstreetmap.josm.data.osm.Way;
    3534import org.openstreetmap.josm.data.osm.WaySegment;
     35import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    3636import org.openstreetmap.josm.gui.MapFrame;
    3737import org.openstreetmap.josm.gui.MapView;
     
    6565     * counts as a move, in milliseconds
    6666     */
    67     private static int initialMoveDelay = 200;
     67    private int initialMoveDelay = 200;
    6868    /**
    6969     * The initial EastNorths of node1 and node2
     
    105105        putValue("help", "Action/Extrude/Extrude");
    106106        initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200);
    107         selectedColor = Main.pref.getColor(marktr("selected"), Color.red);
     107        selectedColor = PaintColors.SELECTED.get();
    108108    }
    109109
     
    235235        } else {
    236236            if (newN1en != null) {
    237                 Graphics2D g2 = (Graphics2D)g;
     237                Graphics2D g2 = g;
    238238                g2.setColor(selectedColor);
    239239                g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r2512 r2666  
    2020import java.util.Set;
    2121import java.util.TreeSet;
    22 import java.util.logging.Logger;
    2322
    2423import javax.swing.JOptionPane;
     
    3938import org.openstreetmap.josm.data.osm.WaySegment;
    4039import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
    41 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
     40import org.openstreetmap.josm.data.osm.visitor.paint.SimplePaintVisitor;
    4241import org.openstreetmap.josm.gui.ExtendedDialog;
    4342import org.openstreetmap.josm.gui.MapFrame;
     
    6261 */
    6362public class SelectAction extends MapMode implements SelectionEnded {
    64     static private final Logger logger = Logger.getLogger(SelectAction.class.getName());
     63    //static private final Logger logger = Logger.getLogger(SelectAction.class.getName());
    6564
    6665    /**
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r2655 r2666  
    5252    private File preferencesDirFile = null;
    5353
    54     public static interface PreferenceChangeEvent{
    55         public String getKey();
    56         public String getOldValue();
    57         public String getNewValue();
    58     }
    59 
    60     public static interface PreferenceChangedListener {
     54    public interface PreferenceChangeEvent{
     55        String getKey();
     56        String getOldValue();
     57        String getNewValue();
     58    }
     59
     60    public interface PreferenceChangedListener {
    6161        void preferenceChanged(PreferenceChangeEvent e);
    6262    }
     
    124124            this.area = area;
    125125        }
     126    }
     127
     128    public interface ColorKey {
     129        String getColorName();
     130        String getSpecialName();
     131        Color getDefault();
    126132    }
    127133
     
    581587    }
    582588
     589    public Color getColor(ColorKey key) {
     590        return getColor(key.getColorName(), key.getSpecialName(), key.getDefault());
     591    }
     592
    583593    /**
    584594     * Convenience method for accessing colour preferences.
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java

    r2665 r2666  
    11/* License: GPL. Copyright 2007 by Immanuel Scholz and others */
    2 package org.openstreetmap.josm.data.osm.visitor;
     2package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    44/* To enable debugging or profiling remove the double / signs */
    55
    6 import static org.openstreetmap.josm.tools.I18n.marktr;
    76import static org.openstreetmap.josm.tools.I18n.tr;
    87
     
    4140import org.openstreetmap.josm.data.osm.RelationMember;
    4241import org.openstreetmap.josm.data.osm.Way;
     42import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    4343import org.openstreetmap.josm.gui.DefaultNameFormatter;
    4444import org.openstreetmap.josm.gui.mappaint.AreaElemStyle;
     
    12481248    {
    12491249        super.getColors();
    1250         untaggedColor = Main.pref.getColor(marktr("untagged"),Color.GRAY);
    1251         textColor = Main.pref.getColor (marktr("text"), Color.WHITE);
    1252         areaTextColor = Main.pref.getColor (marktr("areatext"), Color.LIGHT_GRAY);
     1250        untaggedColor = PaintColors.UNTAGGED.get();
     1251        textColor = PaintColors.TEXT.get();
     1252        areaTextColor = PaintColors.AREA_TEXT.get();
    12531253    }
    12541254
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/SimplePaintVisitor.java

    r2665 r2666  
    11/* License: GPL. Copyright 2007 by Immanuel Scholz and others */
    2 package org.openstreetmap.josm.data.osm.visitor;
     2package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    44/* To enable debugging or profiling remove the double / signs */
    5 
    6 import static org.openstreetmap.josm.tools.I18n.marktr;
    75
    86import java.awt.BasicStroke;
     
    2624import org.openstreetmap.josm.data.osm.RelationMember;
    2725import org.openstreetmap.josm.data.osm.Way;
     26import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    2827import org.openstreetmap.josm.gui.NavigatableComponent;
    2928
     
    3534 */
    3635public class SimplePaintVisitor extends AbstractVisitor {
    37 
    38     public final static Color darkerblue = new Color(0,0,96);
    39     public final static Color darkblue = new Color(0,0,128);
    40     public final static Color darkgreen = new Color(0,128,0);
    41     public final static Color teal = new Color(0,128,128);
    42     public final static Color lightteal= new Color(0, 255, 186);
    43 
    4436    /**
    4537     * The environment to paint to.
     
    9284    public void getColors()
    9385    {
    94         inactiveColor = Main.pref.getColor(marktr("inactive"), Color.darkGray);
    95         selectedColor = Main.pref.getColor(marktr("selected"), Color.red);
    96         nodeColor = Main.pref.getColor(marktr("node"), Color.yellow);
    97         dfltWayColor = Main.pref.getColor(marktr("way"), darkblue);
    98         relationColor = Main.pref.getColor(marktr("relation"), teal);
    99         untaggedWayColor = Main.pref.getColor(marktr("untagged way"), darkgreen);
    100         incompleteColor = Main.pref.getColor(marktr("incomplete way"), darkerblue);
    101         backgroundColor = Main.pref.getColor(marktr("background"), Color.BLACK);
    102         highlightColor = Main.pref.getColor(marktr("highlight"), lightteal);
     86        inactiveColor = PaintColors.INACTIVE.get();
     87        selectedColor = PaintColors.SELECTED.get();
     88        nodeColor = PaintColors.NODE.get();
     89        dfltWayColor = PaintColors.DEFAULT_WAY.get();
     90        relationColor = PaintColors.RELATION.get();
     91        untaggedWayColor = PaintColors.UNTAGGED_WAY.get();
     92        incompleteColor = PaintColors.INCOMPLETE_WAY.get();
     93        backgroundColor = PaintColors.BACKGROUND.get();
     94        highlightColor = PaintColors.HIGHLIGHT.get();
    10395    }
    10496
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r2655 r2666  
    4444import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4545import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     46import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    4647import org.openstreetmap.josm.gui.layer.GpxLayer;
    4748import org.openstreetmap.josm.gui.layer.Layer;
     
    444445        Graphics2D tempG = offscreenBuffer.createGraphics();
    445446        tempG.setClip(g.getClip());
    446         tempG.setColor(Main.pref.getColor("background", Color.BLACK));
     447        tempG.setColor(PaintColors.BACKGROUND.get());
    447448        tempG.fillRect(0, 0, getWidth(), getHeight());
    448449
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r2578 r2666  
    5959import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    6060import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    61 import org.openstreetmap.josm.data.osm.visitor.MapPaintVisitor;
    62 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
     61import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintVisitor;
     62import org.openstreetmap.josm.data.osm.visitor.paint.SimplePaintVisitor;
    6363import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    6464import org.openstreetmap.josm.gui.MapView;
  • trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java

    r2512 r2666  
    3434
    3535import org.openstreetmap.josm.Main;
    36 import org.openstreetmap.josm.data.osm.visitor.MapPaintVisitor;
     36import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintVisitor;
    3737import org.openstreetmap.josm.gui.MapScaler;
    3838import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
Note: See TracChangeset for help on using the changeset viewer.