14
opentcs-plantoverview-themes-default/build.gradle
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
apply from: "${rootDir}/gradle/java-project.gradle"
|
||||
apply from: "${rootDir}/gradle/java-codequality.gradle"
|
||||
apply from: "${rootDir}/gradle/publishing-java.gradle"
|
||||
|
||||
dependencies {
|
||||
api project(':opentcs-api-base')
|
||||
}
|
||||
|
||||
task release {
|
||||
dependsOn build
|
||||
}
|
||||
40
opentcs-plantoverview-themes-default/gradle.properties
Normal file
@@ -0,0 +1,40 @@
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapAnnotationArgs=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapAfterDotInChainedMethodCalls=false
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapFor=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.sortMembersByVisibility=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.visibilityOrder=PUBLIC;PROTECTED;DEFAULT;PRIVATE
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapMethodParams=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapDisjunctiveCatchTypes=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.keepGettersAndSettersTogether=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsList=WRAP_ALWAYS
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword=WRAP_ALWAYS
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsKeyword=WRAP_ALWAYS
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classMembersOrder=STATIC FIELD;FIELD;STATIC_INIT;CONSTRUCTOR;INSTANCE_INIT;STATIC METHOD;METHOD;STATIC CLASS;CLASS
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapEnumConstants=WRAP_ALWAYS
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapCommentText=false
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsList=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapAssert=WRAP_IF_LONG
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.continuationIndentSize=4
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.preserveNewLinesInComments=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
netbeans.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=100
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
netbeans.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
@@ -0,0 +1,171 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.plugins.themes;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.opentcs.components.plantoverview.LocationTheme;
|
||||
import org.opentcs.data.model.Location;
|
||||
import org.opentcs.data.model.LocationType;
|
||||
import org.opentcs.data.model.visualization.LocationRepresentation;
|
||||
|
||||
/**
|
||||
* Default location theme implementation.
|
||||
*/
|
||||
public class DefaultLocationTheme
|
||||
implements
|
||||
LocationTheme {
|
||||
|
||||
/**
|
||||
* The path containing the images.
|
||||
*/
|
||||
private static final String PATH = "/org/opentcs/guing/plugins/themes/symbols/location/";
|
||||
/**
|
||||
* The available symbols.
|
||||
*/
|
||||
private static final String[] LOCTYPE_REPRESENTATION_SYMBOLS
|
||||
= {
|
||||
"TransferStation.20x20.png", // 0
|
||||
"WorkingStation.20x20.png", // 1
|
||||
"ChargingStation.20x20.png", // 2
|
||||
"None.20x20.png", // 3
|
||||
};
|
||||
/**
|
||||
* A map of property values to image file names.
|
||||
*/
|
||||
private final Map<LocationRepresentation, Image> symbolMap
|
||||
= new EnumMap<>(LocationRepresentation.class);
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public DefaultLocationTheme() {
|
||||
initSymbolMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Image getImageFor(
|
||||
@Nonnull
|
||||
LocationRepresentation representation
|
||||
) {
|
||||
requireNonNull(representation, "representation");
|
||||
|
||||
return symbolMap.get(representation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Image getImageFor(
|
||||
@Nonnull
|
||||
Location location,
|
||||
@Nonnull
|
||||
LocationType locationType
|
||||
) {
|
||||
requireNonNull(location, "location");
|
||||
requireNonNull(locationType, "locationType");
|
||||
|
||||
LocationRepresentation representation = location.getLayout().getLocationRepresentation();
|
||||
if (representation == null || representation == LocationRepresentation.DEFAULT) {
|
||||
representation = locationType.getLayout().getLocationRepresentation();
|
||||
}
|
||||
return getImageFor(representation);
|
||||
}
|
||||
|
||||
private void initSymbolMap() {
|
||||
// NONE: A location without further description
|
||||
symbolMap.put(
|
||||
LocationRepresentation.NONE,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[3])
|
||||
);
|
||||
|
||||
// LOAD_TRANSFER_GENERIC: A generic location for vehicle load transfers.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_GENERIC,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
// LOAD_TRANSFER_ALT_1: A location for vehicle load transfers, variant 1.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_ALT_1,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
// LOAD_TRANSFER_ALT_2: A location for vehicle load transfers, variant 2.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_ALT_2,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
// LOAD_TRANSFER_ALT_3: A location for vehicle load transfers, variant 3.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_ALT_3,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
// LOAD_TRANSFER_ALT_4: A location for vehicle load transfers, variant 4.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_ALT_4,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
// LOAD_TRANSFER_ALT_5: A location for vehicle load transfers, variant 5.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.LOAD_TRANSFER_ALT_5,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[0])
|
||||
);
|
||||
|
||||
// WORKING_GENERIC: A location for some generic processing, generic variant.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.WORKING_GENERIC,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[1])
|
||||
);
|
||||
// WORKING_ALT_1: A location for some generic processing, variant 1.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.WORKING_ALT_1,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[1])
|
||||
);
|
||||
// WORKING_ALT_2: A location for some generic processing, variant 2.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.WORKING_ALT_2,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[1])
|
||||
);
|
||||
|
||||
// RECHARGE_GENERIC: A location for recharging a vehicle, generic variant.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.RECHARGE_GENERIC,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[2])
|
||||
);
|
||||
// RECHARGE_ALT_1: A location for recharging a vehicle, variant 1.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.RECHARGE_ALT_1,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[2])
|
||||
);
|
||||
// RECHARGE_ALT_2: A location for recharging a vehicle, variant 2.
|
||||
symbolMap.put(
|
||||
LocationRepresentation.RECHARGE_ALT_2,
|
||||
loadImageFromPath(LOCTYPE_REPRESENTATION_SYMBOLS[2])
|
||||
);
|
||||
}
|
||||
|
||||
private Image loadImageFromPath(String fileName) {
|
||||
return loadImage(PATH + fileName);
|
||||
}
|
||||
|
||||
private Image loadImage(String fileName) {
|
||||
requireNonNull(fileName, "fileName");
|
||||
|
||||
URL url = getClass().getResource(fileName);
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException("Invalid image file name " + fileName);
|
||||
}
|
||||
try {
|
||||
return ImageIO.read(url);
|
||||
}
|
||||
catch (IOException exc) {
|
||||
throw new IllegalArgumentException("Exception loading image", exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.plugins.themes;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.opentcs.components.plantoverview.VehicleTheme;
|
||||
import org.opentcs.data.model.Vehicle;
|
||||
|
||||
/**
|
||||
* An implementation of <code>VehicleTheme</code> using different images for different vehicle
|
||||
* states.
|
||||
*/
|
||||
public class StatefulImageVehicleTheme
|
||||
implements
|
||||
VehicleTheme {
|
||||
|
||||
/**
|
||||
* The path containing the images.
|
||||
*/
|
||||
private static final String PATH = "/org/opentcs/guing/plugins/themes/symbols/vehicle/";
|
||||
/**
|
||||
* The font to be used for labels.
|
||||
*/
|
||||
private static final Font LABEL_FONT = new Font("Arial", Font.BOLD, 12);
|
||||
/**
|
||||
* Map containing images for a specific vehicle state when it's in a default state.
|
||||
*/
|
||||
private final Map<Vehicle.State, Image> stateMapDefault
|
||||
= new EnumMap<>(Vehicle.State.class);
|
||||
/**
|
||||
* Map containing images for a specific vehicle state when it's loaded.
|
||||
*/
|
||||
private final Map<Vehicle.State, Image> stateMapLoaded
|
||||
= new EnumMap<>(Vehicle.State.class);
|
||||
/**
|
||||
* Map containing images for a specific vehicle state when it's paused.
|
||||
*/
|
||||
private final Map<Vehicle.State, Image> stateMapPaused
|
||||
= new EnumMap<>(Vehicle.State.class);
|
||||
/**
|
||||
* Map containing images for a specific vehicle state when it's loaded and paused.
|
||||
*/
|
||||
private final Map<Vehicle.State, Image> stateMapLoadedPaused
|
||||
= new EnumMap<>(Vehicle.State.class);
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public StatefulImageVehicleTheme() {
|
||||
initMaps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image statelessImage(Vehicle vehicle) {
|
||||
requireNonNull(vehicle, "vehicle");
|
||||
|
||||
return stateMapDefault.get(Vehicle.State.IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image statefulImage(Vehicle vehicle) {
|
||||
requireNonNull(vehicle, "vehicle");
|
||||
|
||||
if (loaded(vehicle)) {
|
||||
return vehicle.isPaused()
|
||||
? stateMapLoadedPaused.get(vehicle.getState())
|
||||
: stateMapLoaded.get(vehicle.getState());
|
||||
}
|
||||
else {
|
||||
return vehicle.isPaused()
|
||||
? stateMapPaused.get(vehicle.getState())
|
||||
: stateMapDefault.get(vehicle.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font labelFont() {
|
||||
return LABEL_FONT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color labelColor() {
|
||||
return Color.BLUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int labelOffsetY() {
|
||||
return 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int labelOffsetX() {
|
||||
return -15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String label(Vehicle vehicle) {
|
||||
return vehicle.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the maps with values.
|
||||
*/
|
||||
private void initMaps() {
|
||||
stateMapDefault.put(Vehicle.State.CHARGING, loadImage(PATH + "charging.png"));
|
||||
stateMapDefault.put(Vehicle.State.ERROR, loadImage(PATH + "error.png"));
|
||||
stateMapDefault.put(Vehicle.State.EXECUTING, loadImage(PATH + "normal.png"));
|
||||
stateMapDefault.put(Vehicle.State.IDLE, loadImage(PATH + "normal.png"));
|
||||
stateMapDefault.put(Vehicle.State.UNAVAILABLE, loadImage(PATH + "normal.png"));
|
||||
stateMapDefault.put(Vehicle.State.UNKNOWN, loadImage(PATH + "normal.png"));
|
||||
|
||||
stateMapLoaded.put(Vehicle.State.CHARGING, loadImage(PATH + "charging_loaded.png"));
|
||||
stateMapLoaded.put(Vehicle.State.ERROR, loadImage(PATH + "error_loaded.png"));
|
||||
stateMapLoaded.put(Vehicle.State.EXECUTING, loadImage(PATH + "normal_loaded.png"));
|
||||
stateMapLoaded.put(Vehicle.State.IDLE, loadImage(PATH + "normal_loaded.png"));
|
||||
stateMapLoaded.put(Vehicle.State.UNAVAILABLE, loadImage(PATH + "normal_loaded.png"));
|
||||
stateMapLoaded.put(Vehicle.State.UNKNOWN, loadImage(PATH + "normal_loaded.png"));
|
||||
|
||||
stateMapPaused.put(Vehicle.State.CHARGING, loadImage(PATH + "charging_paused.png"));
|
||||
stateMapPaused.put(Vehicle.State.ERROR, loadImage(PATH + "error_paused.png"));
|
||||
stateMapPaused.put(Vehicle.State.EXECUTING, loadImage(PATH + "normal_paused.png"));
|
||||
stateMapPaused.put(Vehicle.State.IDLE, loadImage(PATH + "normal_paused.png"));
|
||||
stateMapPaused.put(Vehicle.State.UNAVAILABLE, loadImage(PATH + "normal_paused.png"));
|
||||
stateMapPaused.put(Vehicle.State.UNKNOWN, loadImage(PATH + "normal_paused.png"));
|
||||
|
||||
stateMapLoadedPaused.put(
|
||||
Vehicle.State.CHARGING,
|
||||
loadImage(PATH + "charging_loaded_paused.png")
|
||||
);
|
||||
stateMapLoadedPaused.put(Vehicle.State.ERROR, loadImage(PATH + "error_loaded_paused.png"));
|
||||
stateMapLoadedPaused.put(Vehicle.State.EXECUTING, loadImage(PATH + "normal_loaded_paused.png"));
|
||||
stateMapLoadedPaused.put(Vehicle.State.IDLE, loadImage(PATH + "normal_loaded_paused.png"));
|
||||
stateMapLoadedPaused.put(
|
||||
Vehicle.State.UNAVAILABLE,
|
||||
loadImage(PATH + "normal_loaded_paused.png")
|
||||
);
|
||||
stateMapLoadedPaused.put(Vehicle.State.UNKNOWN, loadImage(PATH + "normal_loaded_paused.png"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given vehicle is loaded.
|
||||
*
|
||||
* @param vehicle The vehicle.
|
||||
* @return Flag indicating if it is loaded.
|
||||
*/
|
||||
private boolean loaded(Vehicle vehicle) {
|
||||
return vehicle.getLoadHandlingDevices().stream()
|
||||
.anyMatch(lhd -> lhd.isFull());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from the file with the given name.
|
||||
*
|
||||
* @param fileName The name of the file from which to load the image.
|
||||
* @return The image.
|
||||
*/
|
||||
private Image loadImage(String fileName) {
|
||||
requireNonNull(fileName, "fileName");
|
||||
|
||||
URL url = getClass().getResource(fileName);
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException("Invalid image file name " + fileName);
|
||||
}
|
||||
try {
|
||||
return ImageIO.read(url);
|
||||
}
|
||||
catch (IOException exc) {
|
||||
throw new IllegalArgumentException("Exception loading image", exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.plugins.themes;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.opentcs.components.plantoverview.VehicleTheme;
|
||||
import org.opentcs.data.model.Vehicle;
|
||||
|
||||
/**
|
||||
* An implementation of <code>VehicleTheme</code> using a single image, disregarding vehicles'
|
||||
* states.
|
||||
*/
|
||||
public class StatelessImageVehicleTheme
|
||||
implements
|
||||
VehicleTheme {
|
||||
|
||||
/**
|
||||
* The path containing the images.
|
||||
*/
|
||||
private static final String PATH
|
||||
= "/org/opentcs/guing/plugins/themes/symbols/vehicle/Vehicle24.png";
|
||||
/**
|
||||
* The single image used for representing vehicles, regardless of their state.
|
||||
*/
|
||||
private final Image image;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public StatelessImageVehicleTheme() {
|
||||
this.image = loadImage(PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image statelessImage(Vehicle vehicle) {
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image statefulImage(Vehicle vehicle) {
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from the file with the given name.
|
||||
*
|
||||
* @param fileName The name of the file from which to load the image.
|
||||
* @return The image.
|
||||
*/
|
||||
private Image loadImage(String fileName) {
|
||||
requireNonNull(fileName, "fileName");
|
||||
|
||||
URL url = getClass().getResource(fileName);
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException("Invalid image file name " + fileName);
|
||||
}
|
||||
try {
|
||||
return ImageIO.read(url);
|
||||
}
|
||||
catch (IOException exc) {
|
||||
throw new IllegalArgumentException("Exception loading image", exc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String label(Vehicle vehicle) {
|
||||
String name = vehicle.getName();
|
||||
|
||||
// Find digits.
|
||||
Pattern p = Pattern.compile("\\d+");
|
||||
Matcher m = p.matcher(name);
|
||||
|
||||
// If at least one group of digits was found, use the first one.
|
||||
if (m.find()) {
|
||||
return m.group();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int labelOffsetX() {
|
||||
return -8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int labelOffsetY() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color labelColor() {
|
||||
return Color.BLUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font labelFont() {
|
||||
return new Font("Arial", Font.BOLD, 12);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: The openTCS Authors
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
version = 1
|
||||
|
||||
[[annotations]]
|
||||
path = ["**/*.gif", "**/*.jpg", "**/*.png", "**/*.svg"]
|
||||
precedence = "closest"
|
||||
SPDX-FileCopyrightText = "The openTCS Authors"
|
||||
SPDX-License-Identifier = "CC-BY-4.0"
|
||||
|
After Width: | Height: | Size: 935 B |
|
After Width: | Height: | Size: 147 B |
|
After Width: | Height: | Size: 926 B |
|
After Width: | Height: | Size: 899 B |
|
After Width: | Height: | Size: 752 B |
|
After Width: | Height: | Size: 126 B |
|
After Width: | Height: | Size: 152 B |
|
After Width: | Height: | Size: 398 B |
|
After Width: | Height: | Size: 275 B |
|
After Width: | Height: | Size: 126 B |
|
After Width: | Height: | Size: 152 B |
|
After Width: | Height: | Size: 391 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 220 B |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 280 B |