Skip to content

Commit

Permalink
feat: show trip date and surveyors in hint labels
Browse files Browse the repository at this point in the history
also make text smaller and make foreground/background respond to color
pickers
  • Loading branch information
jedwards1211 committed Oct 19, 2020
1 parent 1b763ab commit 4a8ce98
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
53 changes: 42 additions & 11 deletions breakout-main/src/main/java/org/breakout/BreakoutMainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import java.util.stream.Stream;

import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.CellEditor;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JDialog;
Expand Down Expand Up @@ -233,9 +234,11 @@
import org.breakout.model.calc.CalculateGeometry;
import org.breakout.model.calc.Parsed2Calc;
import org.breakout.model.compass.Compass;
import org.breakout.model.parsed.ParsedField;
import org.breakout.model.parsed.ParsedProject;
import org.breakout.model.parsed.ParsedShot;
import org.breakout.model.parsed.ParsedShotMeasurement;
import org.breakout.model.parsed.ParsedTrip;
import org.breakout.model.parsed.ProjectParser;
import org.breakout.model.raw.MetacaveExporter;
import org.breakout.model.raw.MetacaveImporter;
Expand Down Expand Up @@ -1485,7 +1488,9 @@ public float yOffset() {

final WeakHashMap<Animation, Object> protectedAnimations = new WeakHashMap<>();

Box hintLabelBox;
JLabel hintLabel;
JLabel hintLabel2;

CameraView currentView;

Expand Down Expand Up @@ -1683,14 +1688,19 @@ public JoglViewState getViewState() {

hintLabel = new JLabel("A");
hintLabel.setForeground(Color.WHITE);
hintLabel.setBackground(Color.BLACK);
hintLabel.setOpaque(true);
Font hintFont = hintLabel.getFont();
hintLabel.setFont(hintFont.deriveFont(Font.PLAIN).deriveFont(hintFont.getSize2D() + 3f));
hintLabel.setFont(hintFont.deriveFont(Font.PLAIN));
hintLabel.setPreferredSize(new Dimension(200, hintLabel.getPreferredSize().height));
hintLabel.setText(" ");
hintLabel.setVerticalAlignment(SwingConstants.TOP);

hintLabel2 = new JLabel("A");
hintLabel2.setForeground(hintLabel.getForeground());
hintLabel2.setFont(hintLabel.getFont());
hintLabel2.setPreferredSize(hintLabel.getPreferredSize());
hintLabel2.setText(" ");
hintLabel2.setVerticalAlignment(hintLabel.getVerticalAlignment());

final Consumer<Runnable> sortRunner = r -> sortTaskService.submit(task -> {
task.setStatus("Sorting survey table...");
r.run();
Expand Down Expand Up @@ -1858,19 +1868,23 @@ public void onLayoutChanged(Container target) {
spinnerDelegate.putExtraConstraint(Side.LEFT, new SideConstraint(miniSurveyDrawer, Side.RIGHT, 0));
spinnerDelegate.putExtraConstraint(Side.BOTTOM, new SideConstraint(surveyDrawer, Side.TOP, 0));

hintLabelBox = Box.createVerticalBox();
hintLabelBox.add(hintLabel);
hintLabelBox.add(hintLabel2);

SideConstraintLayoutDelegate hintLabelDelegate = new SideConstraintLayoutDelegate();
hintLabelDelegate.putExtraConstraint(Side.LEFT, new SideConstraint(taskListDrawer.pinButton(), Side.RIGHT, 0));
hintLabelDelegate.putExtraConstraint(Side.RIGHT, new SideConstraint(settingsDrawer, Side.LEFT, 0));
hintLabelDelegate.putExtraConstraint(Side.BOTTOM, new SideConstraint(surveyDrawer, Side.TOP, 0));

mainPanel.add(taskListDrawer.pinButton(), spinnerDelegate);
mainPanel.add(hintLabel, hintLabelDelegate);
mainPanel.add(hintLabelBox, hintLabelDelegate);

SideConstraintLayoutDelegate canvasDelegate = new SideConstraintLayoutDelegate();
canvasDelegate.putExtraConstraint(Side.TOP, new SideConstraint(taskListDrawer, Side.BOTTOM, 0));
canvasDelegate.putExtraConstraint(Side.LEFT, new SideConstraint(miniSurveyDrawer, Side.RIGHT, 0));
canvasDelegate.putExtraConstraint(Side.RIGHT, new SideConstraint(settingsDrawer, Side.LEFT, 0));
canvasDelegate.putExtraConstraint(Side.BOTTOM, new SideConstraint(hintLabel, Side.TOP, 0));
canvasDelegate.putExtraConstraint(Side.BOTTOM, new SideConstraint(hintLabelBox, Side.TOP, 0));
mainPanel.add(canvas, canvasDelegate);

surveyDrawer.table().setTransferHandler(new SurveyTableTransferHandler());
Expand Down Expand Up @@ -1918,6 +1932,7 @@ public void surveyNotesClicked(String link, int viewRow) {
@Override
protected void onValueChanged(Color bgColor) {
if (bgColor != null) {
mainPanel.setBackground(bgColor);
BreakoutMainView.this.bgColor
.set(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f);
if (model3d != null) {
Expand Down Expand Up @@ -2018,6 +2033,8 @@ protected void onValueChanged(Boolean showTerrain) {
protected void onValueChanged(Color stationLabelColor) {
if (stationLabelColor == null)
return;
hintLabel.setForeground(stationLabelColor);
hintLabel2.setForeground(stationLabelColor);
if (model3d != null) {
model3d.setStationLabelColor(stationLabelColor);
}
Expand Down Expand Up @@ -3777,15 +3794,16 @@ void updateHintLabel(final Shot3dPickResult picked) {
SurveyTrip trip = orig != null ? orig.getTrip() : null;
ShotKey key = picked != null ? picked.picked.key() : null;
ParsedShot shot = key != null ? parsedProject.shots.get(key) : null;
if (shot == null)

{
ParsedTrip parsedTrip = shot != null ? shot.trip : null;
if (shot == null) {
Float maxDate = getProjectModel().get(ProjectModel.maxDate);
if (maxDate == null || Float.isNaN(maxDate)) {
hintLabel.setText("");
hintLabel2.setText("");
}
else {
hintLabel
hintLabel.setText("");
hintLabel2
.setText(
"Date: " + SettingsDrawer.maxDateFormat.format(ColorParam.calcDateFromDaysSince1800(maxDate)));
}
Expand Down Expand Up @@ -3843,19 +3861,32 @@ void updateHintLabel(final Shot3dPickResult picked) {
String
.format(
"<html>Stations: <b>%s - %s</b>&emsp;Dist: <b>%s</b>&emsp;Azm: <b>%s/%s</b>"
+ "&emsp;Inc: <b>%s/%s</b>&emsp;<i>%s</i>%s</html>",
+ "&emsp;Inc: <b>%s/%s</b>&emsp;%s</html>",
key.fromStation,
key.toStation,
formattedDistance,
formattedFrontAzimuth,
formattedBackAzimuth,
formattedFrontInclination,
formattedBackInclination,
trip != null ? trip.getName() : "",
formattedLeads);

hintLabel.setText(hintText);
hintLabel.invalidate();

Date parsedDate = ParsedField.getValue(parsedTrip != null ? parsedTrip.date : null);

String hintText2 =
trip != null
? String
.format(
"<html>Trip: <b>%s</b>&emsp;Date: <b>%s</b>&emsp;Surveyors: <b>%s</b></html>",
trip.getName(),
parsedDate != null ? SettingsDrawer.maxDateFormat.format(parsedDate) : trip.getDate(),
StringUtils.join(", ", trip.getSurveyors()))
: "";
hintLabel2.setText(hintText2);
hintLabel2.setText(hintText2);
}
}

Expand Down
3 changes: 1 addition & 2 deletions breakout-main/src/main/java/org/breakout/TaskListDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package org.breakout;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -69,7 +68,7 @@ public TaskListDrawer() {
delegate().dockingSide(Side.TOP);
mainResizeHandle();
pinButton().setUI(new SpinnerButtonUI());
pinButton().setBackground(Color.BLACK);
pinButton().setOpaque(false);
}

public void addTaskService(TaskService taskService) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.breakout.model.parsed;

import java.util.BitSet;
import java.util.List;

public class ParsedShot {
Expand All @@ -11,8 +10,10 @@ public class ParsedShot {
private static final int HAS_ATTACHED_FILES = 2;

private void setFlag(int flag, boolean value) {
if (value) flags |= flag;
else flags &= ~flag;
if (value)
flags |= flag;
else
flags &= ~flag;
}

private boolean getFlag(int flag) {
Expand All @@ -26,7 +27,7 @@ public boolean isExcludeDistance() {
public boolean isExcludeFromPlotting() {
return getFlag(EXCLUDE_FROM_PLOTTING);
}

public boolean hasSurveyNotes() {
return getFlag(HAS_ATTACHED_FILES);
}
Expand All @@ -45,4 +46,5 @@ public void setHasAttachedFiles(boolean value) {

public ParsedShot overrides;
public ParsedShot overriddenBy;
public ParsedTrip trip;
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ public ShotKey parse(SurveyRow raw) {
}
else if (fromStation != null && toStation != null) {
ParsedShot shot = new ParsedShot();
shot.trip = parsedTrip;
shot.setHasAttachedFiles(raw.getAttachedFiles() != null && !raw.getAttachedFiles().isEmpty());
shot.measurements = new ArrayList<>(2);
if (frontsights != null) {
Expand Down

0 comments on commit 4a8ce98

Please sign in to comment.