Commit 440ebf40 authored by mey's avatar mey
Browse files

FlowMapInspector.java: appends compressed notification to scale text

DirectionPortrayal.java
    made constant MINIMUM_FULL_DRAW_SCALE public
AbstractPathfindingMapInspector.java
    added protected method generateScaleText
parent 8fbfe266
......@@ -50,9 +50,15 @@ abstract class AbstractPathfindingMapInspector<T extends PathfindingMap> extends
private final GUIState guiState;
private double scale = 1;
private final NumberTextField scaleField = new NumberTextField(" Scale: ", 1.0, true) {
private final NumberTextField scaleField = new NumberTextField("Scale: ", 1.0, true) {
private static final long serialVersionUID = 1L;
@Override
public void setValue(double val) {
super.setValue(val);
setText(generateScaleText(val));
}
@Override
public double newValue(double newValue) {
if (newValue <= 0.0) {
......@@ -96,6 +102,22 @@ abstract class AbstractPathfindingMapInspector<T extends PathfindingMap> extends
add(scrollPane, BorderLayout.CENTER);
}
/**
* Called when scale text field changes. Default behavior is to simply
* display the scale value.
*
* @param scaleValue
* the current scale value
* @return the text that will appear in the scale text field
*/
protected String generateScaleText(double scaleValue) {
if (((int) scaleValue) == scaleValue) {
return "" + (int) scaleValue;
} else {
return "" + scaleValue;
}
}
/**
* Sets the scale (the zoom value) of the Display2D
*
......@@ -140,14 +162,6 @@ abstract class AbstractPathfindingMapInspector<T extends PathfindingMap> extends
repaint();
}
/**
* Returns a portrayal suitable for a specific pathfinding map. Portrayal
* needs to be created in implementing classes and returned here.
*
* @return the portrayal for the pathfinding map
*/
protected abstract FieldPortrayal2D getPortrayal();
/**
* Returns the String to be displayed within the info text field after the
* location. Returns toString as default. Override this for a custom
......@@ -161,6 +175,14 @@ abstract class AbstractPathfindingMapInspector<T extends PathfindingMap> extends
return wrapper.getObject().toString();
}
/**
* Returns a portrayal suitable for a specific pathfinding map. Portrayal
* needs to be created in implementing classes and returned here.
*
* @return the portrayal for the pathfinding map
*/
protected abstract FieldPortrayal2D getPortrayal();
@Override
public void updateInspector() {
getPortrayal().setDirtyField(true);
......
......@@ -33,6 +33,16 @@ public class FlowMapInspector extends AbstractPathfindingMapInspector<FlowMap> {
portrayal.setPortrayalForClass(Double2D.class, new DirectionPortrayal());
}
/** Appends notification text if view is compressed due to lack of space. */
@Override
protected String generateScaleText(double scaleValue) {
String scaleText = super.generateScaleText(scaleValue);
if (scaleValue < DirectionPortrayal.MINIMUM_FULL_DRAW_SCALE) {
return scaleText + " (compressed)";
}
return scaleText;
}
@Override
protected FieldPortrayal2D getPortrayal() {
return portrayal;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment