Changeset 16879 in josm for trunk


Ignore:
Timestamp:
2020-08-12T20:42:35+02:00 (4 years ago)
Author:
simon04
Message:

fix #8227 - MarkerLayer: allow to customize marker size/stroke

Advanced preference keys draw.rawgps.markers.size, draw.rawgps.markers.stroke

Location:
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r15497 r16879  
    22package org.openstreetmap.josm.gui.layer.markerlayer;
    33
    4 import java.awt.Graphics;
     4import java.awt.Graphics2D;
    55import java.awt.Insets;
    66import java.awt.Point;
     
    4444    }
    4545
    46     @Override public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
     46    @Override public void paint(Graphics2D g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
    4747        if (!showTextOrIcon) {
    4848            super.paint(g, mv, mousePressed, showTextOrIcon);
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r16438 r16879  
    77import java.awt.Graphics2D;
    88import java.awt.Point;
     9import java.awt.Stroke;
    910import java.awt.event.ActionEvent;
    1011import java.awt.image.BufferedImage;
     
    268269     * @param showTextOrIcon true if text and icon shall be drawn
    269270     */
    270     public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
     271    public void paint(Graphics2D g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
    271272        Point screen = mv.getPoint(this);
     273        int size2 = parentLayer.markerSize / 2;
     274
    272275        if (symbol != null && showTextOrIcon) {
    273276            paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2);
    274277        } else {
    275             g.drawLine(screen.x-2, screen.y-2, screen.x+2, screen.y+2);
    276             g.drawLine(screen.x+2, screen.y-2, screen.x-2, screen.y+2);
     278            Stroke stroke = g.getStroke();
     279            g.setStroke(parentLayer.markerStroke);
     280            g.drawLine(screen.x - size2, screen.y - size2, screen.x + size2, screen.y + size2);
     281            g.drawLine(screen.x + size2, screen.y - size2, screen.x - size2, screen.y + size2);
     282            g.setStroke(stroke);
    277283        }
    278284
    279285        String labelText = getText();
    280286        if (!labelText.isEmpty() && showTextOrIcon) {
    281             g.drawString(labelText, screen.x+4, screen.y+2);
     287            g.drawString(labelText, screen.x + size2 + 2, screen.y + size2);
    282288        }
    283289    }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r16438 r16879  
    77import static org.openstreetmap.josm.tools.I18n.trn;
    88
     9import java.awt.BasicStroke;
    910import java.awt.Color;
    1011import java.awt.Component;
     
    3839import org.openstreetmap.josm.data.gpx.WayPoint;
    3940import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     41import org.openstreetmap.josm.data.preferences.IntegerProperty;
    4042import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     43import org.openstreetmap.josm.data.preferences.StrokeProperty;
    4144import org.openstreetmap.josm.gui.MainApplication;
    4245import org.openstreetmap.josm.gui.MapView;
     
    7982    public AudioMarker syncAudioMarker;
    8083    private Color color, realcolor;
     84    final int markerSize = new IntegerProperty("draw.rawgps.markers.size", 4).get();
     85    final BasicStroke markerStroke = new StrokeProperty("draw.rawgps.markers.stroke", "1").get();
    8186
    8287    /**
Note: See TracChangeset for help on using the changeset viewer.