Changeset 17890 in josm for trunk/src/org
- Timestamp:
- 2021-05-13T00:19:28+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r16694 r17890 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color; 6 7 import java.util.HashSet; 7 8 import java.util.Objects; … … 44 45 import org.openstreetmap.josm.gui.util.ChangeNotifier; 45 46 import org.openstreetmap.josm.tools.CheckParameterUtil; 47 import org.openstreetmap.josm.tools.ColorScale; 46 48 import org.openstreetmap.josm.tools.Logging; 47 49 … … 89 91 private final DiffTableModel referenceNodeListTableModel; 90 92 private final DiffTableModel currentNodeListTableModel; 93 private final ColorScale dateScale; 91 94 92 95 /** … … 101 104 currentRelationMemberTableModel = new DiffTableModel(); 102 105 referenceRelationMemberTableModel = new DiffTableModel(); 106 dateScale = ColorScale.createHSBScale(256); 103 107 104 108 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); … … 193 197 setLatest(newLatest); 194 198 } 199 if (!history.isEmpty()) { 200 this.dateScale.setRange( 201 history.getEarliest().getInstant().toEpochMilli(), 202 history.getLatest().getInstant().toEpochMilli()); 203 } 195 204 initTagTableModels(); 196 205 fireModelChange(); … … 689 698 } 690 699 700 /** 701 * Returns the color for the primitive in the given row 702 * @param row row number 703 * @return the color for the primitive in the given row 704 */ 705 public Color getVersionColor(int row) { 706 HistoryOsmPrimitive primitive = getPrimitive(row); 707 return primitive != null && primitive.getInstant() != null ? getVersionColor(primitive) : null; 708 } 709 710 /** 711 * Returns the color for the given primitive timestamp 712 * @param primitive the history primitive 713 * @return the color for the given primitive timestamp 714 */ 715 public Color getVersionColor(HistoryOsmPrimitive primitive) { 716 return dateScale.getColor(primitive.getInstant().toEpochMilli()); 717 } 691 718 } -
trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java
r17887 r17890 5 5 import java.awt.Component; 6 6 7 import javax.swing.BorderFactory; 7 8 import javax.swing.JLabel; 8 9 import javax.swing.JTable; … … 48 49 String text = ""; 49 50 String tooltip = null; 51 setBorder(null); 50 52 if (model.hasTag(key)) { 51 53 switch(column) { … … 63 65 text = "v" + primitive.getVersion(); 64 66 tooltip = tr("Key ''{0}'' was changed in version {1}", key, primitive.getVersion()); 67 setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2, model.getVersionColor(primitive))); 65 68 } 66 69 default: // Do nothing -
trunk/src/org/openstreetmap/josm/gui/history/TagTableModel.java
r17887 r17890 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import java.awt.Color; 4 5 import java.util.ArrayList; 5 6 import java.util.Collections; … … 96 97 97 98 /** 99 * Returns the color for the given primitive timestamp 100 * @param primitive the history primitive 101 * @return the color for the given primitive timestamp 102 */ 103 public Color getVersionColor(HistoryOsmPrimitive primitive) { 104 return model.getVersionColor(primitive); 105 } 106 107 /** 98 108 * Determines if a tag exists in the opposite point in time for the given key. 99 109 * @param key tag key -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableCellRenderer.java
r17889 r17890 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import javax.swing.BorderFactory; 4 5 import javax.swing.JLabel; 5 6 import javax.swing.JTable; 6 7 import javax.swing.SwingConstants; 7 8 import javax.swing.table.TableCellRenderer; 9 import java.awt.Color; 8 10 import java.awt.Component; 9 11 … … 28 30 } 29 31 setText(v); 32 Color color = ((VersionTableModel) table.getModel()).getVersionColor(row); 33 if (color != null) { 34 setBorder(BorderFactory.createMatteBorder(0, 2, 0, 0, color)); 35 } else { 36 setBorder(null); 37 } 30 38 return this; 31 39 } -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableModel.java
r17838 r17890 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import java.awt.Color; 4 5 import java.time.format.FormatStyle; 5 6 … … 78 79 } 79 80 81 /** 82 * Returns the color for the primitive in the given row 83 * @param row row number 84 * @return the color for the primitive in the given row 85 */ 86 public Color getVersionColor(int row) { 87 return model.getVersionColor(row); 88 } 89 80 90 @Override 81 91 public void setValueAt(Object aValue, int row, int column) {
Note:
See TracChangeset
for help on using the changeset viewer.