This commit is contained in:
15
opentcs-plantoverview-base/build.gradle
Normal file
15
opentcs-plantoverview-base/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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/guice-project.gradle"
|
||||
apply from: "${rootDir}/gradle/publishing-java.gradle"
|
||||
|
||||
dependencies {
|
||||
api project(':opentcs-api-base')
|
||||
}
|
||||
|
||||
task release {
|
||||
dependsOn build
|
||||
}
|
||||
40
opentcs-plantoverview-base/gradle.properties
Normal file
40
opentcs-plantoverview-base/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,22 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base;
|
||||
|
||||
/**
|
||||
* Defines the allocation states a resource can be in.
|
||||
*/
|
||||
public enum AllocationState {
|
||||
|
||||
/**
|
||||
* The resource is claimed by a vehicle.
|
||||
*/
|
||||
CLAIMED,
|
||||
/**
|
||||
* The resource is allocated by a vehicle.
|
||||
*/
|
||||
ALLOCATED,
|
||||
/**
|
||||
* The resource is allocated by a vehicle but its related transport order is withdrawn.
|
||||
*/
|
||||
ALLOCATED_WITHDRAWN;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base;
|
||||
|
||||
/**
|
||||
* Defines constants regarding internationalization.
|
||||
*/
|
||||
public interface I18nPlantOverviewBase {
|
||||
|
||||
/**
|
||||
* The path to the project's resource bundle.
|
||||
*/
|
||||
String BUNDLE_PATH = "i18n/org/opentcs/plantoverview/base/Bundle";
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.layer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.opentcs.data.model.visualization.Layer;
|
||||
import org.opentcs.data.model.visualization.LayerGroup;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Wraps a {@link Layer} instance and the {@link LayerGroup} instance that the layer is assigned to.
|
||||
* Instances of this class are referenced by {@link ModelComponent}s. This allows multiple model
|
||||
* components to be updated simultaneously with the update of only one layer wrapper.
|
||||
*/
|
||||
public class LayerWrapper {
|
||||
|
||||
/**
|
||||
* The layer.
|
||||
*/
|
||||
private Layer layer;
|
||||
/**
|
||||
* The layer group the layer is assigned to.
|
||||
*/
|
||||
private LayerGroup layerGroup;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param layer The layer.
|
||||
* @param layerGroup The layer group the layer is assigned to.
|
||||
*/
|
||||
public LayerWrapper(
|
||||
@Nonnull
|
||||
Layer layer,
|
||||
@Nonnull
|
||||
LayerGroup layerGroup
|
||||
) {
|
||||
this.layer = requireNonNull(layer, "layer");
|
||||
this.layerGroup = requireNonNull(layerGroup, "layerGroup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the layer.
|
||||
*
|
||||
* @return The layer.
|
||||
*/
|
||||
@Nonnull
|
||||
public Layer getLayer() {
|
||||
return layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layer.
|
||||
*
|
||||
* @param layer The layer.
|
||||
*/
|
||||
public void setLayer(
|
||||
@Nonnull
|
||||
Layer layer
|
||||
) {
|
||||
this.layer = requireNonNull(layer, "layer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the layer group the layer is assigned to.
|
||||
*
|
||||
* @return The layer group.
|
||||
*/
|
||||
public LayerGroup getLayerGroup() {
|
||||
return layerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layer group the layer is assigned to.
|
||||
*
|
||||
* @param layerGroup The layer group.
|
||||
*/
|
||||
public void setLayerGroup(LayerGroup layerGroup) {
|
||||
this.layerGroup = layerGroup;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.layer;
|
||||
|
||||
import org.opentcs.data.model.visualization.Layer;
|
||||
import org.opentcs.data.model.visualization.LayerGroup;
|
||||
|
||||
/**
|
||||
* A null object for a layer wrapper.
|
||||
*/
|
||||
public class NullLayerWrapper
|
||||
extends
|
||||
LayerWrapper {
|
||||
|
||||
public NullLayerWrapper() {
|
||||
super(new Layer(0, 0, true, "null", 0), new LayerGroup(0, "null", true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* An event that notifies all {@link AttributesChangeListener}s that a model component has been
|
||||
* changed.
|
||||
*/
|
||||
public class AttributesChangeEvent
|
||||
extends
|
||||
EventObject {
|
||||
|
||||
/**
|
||||
* The model.
|
||||
*/
|
||||
protected ModelComponent fModelComponent;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param listener The listener.
|
||||
* @param model The model component.
|
||||
*/
|
||||
public AttributesChangeEvent(AttributesChangeListener listener, ModelComponent model) {
|
||||
super(listener);
|
||||
fModelComponent = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the model.
|
||||
*/
|
||||
public ModelComponent getModel() {
|
||||
return fModelComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initiator.
|
||||
*/
|
||||
public AttributesChangeListener getInitiator() {
|
||||
return (AttributesChangeListener) getSource();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.event;
|
||||
|
||||
/**
|
||||
* Interface that controllers/views implement.
|
||||
*
|
||||
* @see AttributesChangeEvent
|
||||
*/
|
||||
public interface AttributesChangeListener {
|
||||
|
||||
/**
|
||||
* Event received when the model has been changed.
|
||||
*
|
||||
* @param e The event.
|
||||
*/
|
||||
void propertiesChanged(AttributesChangeEvent e);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.event;
|
||||
|
||||
/**
|
||||
* A PropertiesModelChangeListener that does nothing.
|
||||
*/
|
||||
public class NullAttributesChangeListener
|
||||
implements
|
||||
AttributesChangeListener {
|
||||
|
||||
/**
|
||||
* Creates a new instance of NullPropertiesModelChangeListener
|
||||
*/
|
||||
public NullAttributesChangeListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertiesChanged(AttributesChangeEvent e) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Abstract super class for properties that should get their own details dialog
|
||||
* for editing because editing in simple text fields or combo boxes is hard to
|
||||
* realize or not comfortable for the user.
|
||||
*/
|
||||
public abstract class AbstractComplexProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public AbstractComplexProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Attribute of a {@link ModelComponent}.
|
||||
*/
|
||||
public abstract class AbstractModelAttribute
|
||||
implements
|
||||
ModelAttribute {
|
||||
|
||||
/**
|
||||
* The model this attribute is attached to.
|
||||
*/
|
||||
private ModelComponent fModel;
|
||||
/**
|
||||
* Indicates that this attribute has changed.
|
||||
*/
|
||||
private ChangeState fChangeState = ChangeState.NOT_CHANGED;
|
||||
/**
|
||||
* Description of this attribute.
|
||||
*/
|
||||
private String fDescription = "";
|
||||
/**
|
||||
* Tooltip text.
|
||||
*/
|
||||
private String fHelptext = "";
|
||||
/**
|
||||
* Indicates whether or not this attribute can simultaneously be edited with other
|
||||
* attributes of the same name of other model components.
|
||||
*/
|
||||
private boolean fCollectiveEditable;
|
||||
/**
|
||||
* Indicates whether or not this attribute can be changed in modeling mode.
|
||||
*/
|
||||
private boolean fModellingEditable = true;
|
||||
/**
|
||||
* Indicates whether or not this attribute can be changed in operating mode.
|
||||
*/
|
||||
private boolean fOperatingEditable;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public AbstractModelAttribute(ModelComponent model) {
|
||||
fModel = model;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public ModelComponent getModel() {
|
||||
return fModel;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setModel(ModelComponent model) {
|
||||
fModel = model;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void markChanged() {
|
||||
fChangeState = ChangeState.CHANGED;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void unmarkChanged() {
|
||||
fChangeState = ChangeState.NOT_CHANGED;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setChangeState(ChangeState state) {
|
||||
fChangeState = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the change state of this attribute.
|
||||
*
|
||||
* @return The change state.
|
||||
*/
|
||||
public ChangeState getChangeState() {
|
||||
return fChangeState;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public boolean hasChanged() {
|
||||
return (fChangeState != ChangeState.NOT_CHANGED);
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setDescription(String description) {
|
||||
fDescription = description;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public String getDescription() {
|
||||
return fDescription;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setHelptext(String helptext) {
|
||||
fHelptext = helptext;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public String getHelptext() {
|
||||
return fHelptext;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setCollectiveEditable(boolean collectiveEditable) {
|
||||
fCollectiveEditable = collectiveEditable;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public boolean isCollectiveEditable() {
|
||||
return fCollectiveEditable;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setModellingEditable(boolean editable) {
|
||||
fModellingEditable = editable;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public boolean isModellingEditable() {
|
||||
return fModellingEditable;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public void setOperatingEditable(boolean editable) {
|
||||
fOperatingEditable = editable;
|
||||
}
|
||||
|
||||
@Override // ModelAttribute
|
||||
public boolean isOperatingEditable() {
|
||||
return fOperatingEditable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Base implementation for a property.
|
||||
*/
|
||||
public abstract class AbstractProperty
|
||||
extends
|
||||
AbstractModelAttribute
|
||||
implements
|
||||
Property {
|
||||
|
||||
/**
|
||||
* The value of this property.
|
||||
*/
|
||||
protected Object fValue;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public AbstractProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param newValue The new value.
|
||||
*/
|
||||
public void setValue(Object newValue) {
|
||||
fValue = newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this property.
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException exc) {
|
||||
throw new RuntimeException("Unexpected exception", exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Base implementation for properties having a value and a unit.
|
||||
* (Examples: 1 s, 200 m, 30 m/s.)
|
||||
* Also specifies conversion relations (see {@link Relation}) between units that allow conversion
|
||||
* to other units.
|
||||
*
|
||||
* @param <U> The enum type.
|
||||
*/
|
||||
public abstract class AbstractQuantity<U extends Enum<U>>
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* This class's logger.
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractQuantity.class);
|
||||
/**
|
||||
* A {@link ValidRangePair} indicating the range of the valid values
|
||||
* for this quantity.
|
||||
*/
|
||||
protected ValidRangePair validRange = new ValidRangePair();
|
||||
/**
|
||||
* The unit's enum class;
|
||||
*/
|
||||
private final Class<U> fUnitClass;
|
||||
/**
|
||||
* List of possible units.
|
||||
*/
|
||||
private final List<U> fPossibleUnits;
|
||||
/**
|
||||
* List of relations between different units.
|
||||
*/
|
||||
private final List<Relation<U>> fRelations;
|
||||
/**
|
||||
* Current unit.
|
||||
*/
|
||||
private U fUnit;
|
||||
/**
|
||||
* Whether or not this property is an integer value.
|
||||
*/
|
||||
private boolean fIsInteger;
|
||||
/**
|
||||
* Whether or not this property is unsigned.
|
||||
*/
|
||||
private boolean fIsUnsigned;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The value.
|
||||
* @param unit The unit.
|
||||
* @param unitClass The unit class.
|
||||
* @param relations The relations.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public AbstractQuantity(
|
||||
ModelComponent model, double value, U unit, Class<U> unitClass,
|
||||
List<Relation<U>> relations
|
||||
) {
|
||||
super(model);
|
||||
fUnit = requireNonNull(unit, "unit");
|
||||
fUnitClass = requireNonNull(unitClass, "unitClass");
|
||||
fPossibleUnits = Arrays.asList(unitClass.getEnumConstants());
|
||||
fRelations = requireNonNull(relations, "relations");
|
||||
fIsInteger = false;
|
||||
fIsUnsigned = false;
|
||||
initValidRange();
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new valid range.
|
||||
*
|
||||
* @param newRange The new {@link ValidRangePair}.
|
||||
*/
|
||||
public void setValidRangePair(ValidRangePair newRange) {
|
||||
validRange = Objects.requireNonNull(newRange, "newRange is null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the valid range for this quantity.
|
||||
*
|
||||
* @return The {@link ValidRangePair}.
|
||||
*/
|
||||
public ValidRangePair getValidRange() {
|
||||
return validRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the valid range of values.
|
||||
*/
|
||||
protected abstract void initValidRange();
|
||||
|
||||
/**
|
||||
* Sets the value of this property to be an integer or decimal number.
|
||||
*
|
||||
* @param isInteger Whether the value is an integer.
|
||||
*/
|
||||
public void setInteger(boolean isInteger) {
|
||||
fIsInteger = isInteger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the value of this property is an integer value.
|
||||
*
|
||||
* @return Whether the value is an integer.
|
||||
*/
|
||||
public boolean isInteger() {
|
||||
return fIsInteger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of this property to be unsigned or not.
|
||||
*
|
||||
* @param isUnsigned Whether the value is unsigned.
|
||||
*/
|
||||
public void setUnsigned(boolean isUnsigned) {
|
||||
this.fIsUnsigned = isUnsigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the value is unsigned or not.
|
||||
*
|
||||
* @return Whether the value is unsigned.
|
||||
*/
|
||||
public boolean isUnsigned() {
|
||||
return fIsUnsigned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
try {
|
||||
double value = Double.parseDouble(fValue.toString());
|
||||
|
||||
if (isInteger()) {
|
||||
return (int) (value + 0.5);
|
||||
}
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
LOG.info("Error parsing value", nfe);
|
||||
return fValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this property converted to the specified unit.
|
||||
*
|
||||
* @param unit The unit return.
|
||||
* @return The value by the given unit.
|
||||
*/
|
||||
public double getValueByUnit(U unit) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
AbstractQuantity<U> property = (AbstractQuantity<U>) clone();
|
||||
// PercentProperty threw
|
||||
// java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
|
||||
// this is a workaround 12.09.14
|
||||
double value;
|
||||
if (isInteger()) {
|
||||
value = ((Integer) getValue()).doubleValue();
|
||||
}
|
||||
else {
|
||||
value = (double) getValue();
|
||||
}
|
||||
property.setValueAndUnit(value, getUnit());
|
||||
property.convertTo(unit);
|
||||
if (isInteger()) {
|
||||
value = ((Integer) property.getValue()).doubleValue();
|
||||
}
|
||||
else {
|
||||
value = (double) property.getValue();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
LOG.error("Exception: ", e);
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the property to the new unit.
|
||||
*
|
||||
* @param unit The new unit to use.
|
||||
*/
|
||||
public void convertTo(U unit) {
|
||||
if (!fPossibleUnits.contains(unit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fUnit.equals(unit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int indexUnitA = fPossibleUnits.indexOf(fUnit);
|
||||
int indexUnitB = fPossibleUnits.indexOf(unit);
|
||||
|
||||
int lowerIndex;
|
||||
int upperIndex;
|
||||
if (indexUnitA < indexUnitB) {
|
||||
lowerIndex = indexUnitA;
|
||||
upperIndex = indexUnitB;
|
||||
}
|
||||
else {
|
||||
lowerIndex = indexUnitB;
|
||||
upperIndex = indexUnitA;
|
||||
}
|
||||
|
||||
double relationValue = 1.0;
|
||||
|
||||
for (int i = lowerIndex; i < upperIndex; i++) {
|
||||
U unitA = fPossibleUnits.get(i);
|
||||
U unitB = fPossibleUnits.get(i + 1);
|
||||
|
||||
Relation<U> relation = findFittingRelation(unitA, unitB);
|
||||
relationValue *= relation.relationValue();
|
||||
}
|
||||
|
||||
U lowerUnit = fPossibleUnits.get(lowerIndex);
|
||||
U upperUnit = fPossibleUnits.get(upperIndex);
|
||||
|
||||
Relation<U> relation = new Relation<>(lowerUnit, upperUnit, relationValue);
|
||||
Relation.Operation operation = relation.getOperation(fUnit, unit);
|
||||
|
||||
fUnit = unit;
|
||||
|
||||
switch (operation) {
|
||||
case DIVISION:
|
||||
setValue((double) fValue / relation.relationValue());
|
||||
break;
|
||||
case MULTIPLICATION:
|
||||
setValue((double) fValue * relation.relationValue());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unhandled operation: " + operation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current unit for this property.
|
||||
*
|
||||
* @return The unit.
|
||||
*/
|
||||
public U getUnit() {
|
||||
return fUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this property is applicable to the specified unit.
|
||||
*
|
||||
* @param unit The unit.
|
||||
* @return {@code true}, if the given unit is a valid/possible one, otherwise {@code false}.
|
||||
*/
|
||||
public boolean isPossibleUnit(U unit) {
|
||||
return fPossibleUnits.contains(unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string is a valid/possible unit.
|
||||
*
|
||||
* @param unitString The unit as a string.
|
||||
* @return {@code true}, if the given string is a valid/possible unit, otherwise {@code false}.
|
||||
*/
|
||||
public boolean isPossibleUnit(String unitString) {
|
||||
for (U unit : fPossibleUnits) {
|
||||
if (Objects.equals(unitString, unit.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value and unit for this property.
|
||||
* {@link IllegalArgumentException} is thrown if the unit is not applicable to this property.
|
||||
*
|
||||
* @param value The new value.
|
||||
* @param unit The new unit.
|
||||
* @throws IllegalArgumentException If the given unit is not usable.
|
||||
*/
|
||||
public void setValueAndUnit(double value, U unit)
|
||||
throws IllegalArgumentException {
|
||||
if (!isPossibleUnit(unit)) {
|
||||
throw new IllegalArgumentException(String.format("'%s' is not a valid unit.", unit));
|
||||
}
|
||||
if (!Double.isNaN(value)) {
|
||||
if (fValue instanceof Double) {
|
||||
if ((double) fValue != value) {
|
||||
markChanged();
|
||||
}
|
||||
}
|
||||
else {
|
||||
markChanged();
|
||||
}
|
||||
}
|
||||
|
||||
fUnit = unit;
|
||||
|
||||
setValue(value);
|
||||
|
||||
if (fIsUnsigned) {
|
||||
setValue(Math.abs(value));
|
||||
}
|
||||
}
|
||||
|
||||
public void setValueAndUnit(double value, String unitString)
|
||||
throws IllegalArgumentException {
|
||||
requireNonNull(unitString);
|
||||
|
||||
for (U unit : fUnitClass.getEnumConstants()) {
|
||||
if (unitString.equals(unit.toString())) {
|
||||
setValueAndUnit(value, unit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown unit \"" + unitString + "\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (fValue instanceof Integer) {
|
||||
return ((int) fValue) + " " + fUnit;
|
||||
}
|
||||
else if (fValue instanceof Double) {
|
||||
return fValue + " " + fUnit;
|
||||
}
|
||||
else {
|
||||
return fValue.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of possible units for this property.
|
||||
*
|
||||
* @return A list of possible units.
|
||||
*/
|
||||
public List<U> getPossibleUnits() {
|
||||
return fPossibleUnits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
@SuppressWarnings("unchecked")
|
||||
AbstractQuantity<U> quantity = (AbstractQuantity<U>) property;
|
||||
|
||||
try {
|
||||
if (quantity.getValue() instanceof Double) {
|
||||
setValueAndUnit((double) quantity.getValue(), quantity.getUnit());
|
||||
}
|
||||
else if (quantity.getValue() instanceof Integer) {
|
||||
setValueAndUnit(((Integer) quantity.getValue()).doubleValue(), quantity.getUnit());
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
LOG.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the conversion relation that is applicable for both specified units.
|
||||
*
|
||||
* @return the conversion relation for the units.
|
||||
*/
|
||||
private Relation<U> findFittingRelation(U unitFrom, U unitTo) {
|
||||
for (Relation<U> relation : fRelations) {
|
||||
if (relation.fits(unitFrom, unitTo)) {
|
||||
return relation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public class ValidRangePair {
|
||||
|
||||
private double min = Double.NEGATIVE_INFINITY;
|
||||
private double max = Double.MAX_VALUE;
|
||||
|
||||
public ValidRangePair() {
|
||||
}
|
||||
|
||||
public ValidRangePair(double min, double max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given value is in the valid range.
|
||||
*
|
||||
* @param value The value to test.
|
||||
* @return <code>true</code> if the value is in range, <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isValueValid(double value) {
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public ValidRangePair setMin(double min) {
|
||||
this.min = min;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public ValidRangePair setMax(double max) {
|
||||
this.max = max;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
/**
|
||||
* An invalid but still acceptable value for a property.
|
||||
*/
|
||||
public interface AcceptableInvalidValue {
|
||||
|
||||
/**
|
||||
* Returns a description for the value.
|
||||
*
|
||||
* @return A description.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Returns a helptext for the value.
|
||||
*
|
||||
* @return A helptext.
|
||||
*/
|
||||
String getHelptext();
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for angles.
|
||||
*/
|
||||
public class AngleProperty
|
||||
extends
|
||||
AbstractQuantity<AngleProperty.Unit> {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public AngleProperty(ModelComponent model) {
|
||||
this(model, Double.NaN, Unit.DEG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The property value.
|
||||
* @param unit The value's unit.
|
||||
*/
|
||||
public AngleProperty(ModelComponent model, double value, Unit unit) {
|
||||
super(model, value, unit, Unit.class, relations());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue) + getUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
if (newValue instanceof Double) {
|
||||
if (getUnit() == Unit.DEG) {
|
||||
super.setValue(((double) newValue) % 360);
|
||||
}
|
||||
else {
|
||||
super.setValue(((double) newValue) % (2 * Math.PI));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initValidRange() {
|
||||
validRange.setMin(0);
|
||||
}
|
||||
|
||||
private static List<Relation<Unit>> relations() {
|
||||
List<Relation<Unit>> relations = new ArrayList<>();
|
||||
relations.add(new Relation<>(Unit.DEG, Unit.RAD, 180.0 / Math.PI));
|
||||
relations.add(new Relation<>(Unit.RAD, Unit.DEG, Math.PI / 180.0));
|
||||
return relations;
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported units.
|
||||
*/
|
||||
public enum Unit {
|
||||
/**
|
||||
* Degrees.
|
||||
*/
|
||||
DEG("deg"),
|
||||
/**
|
||||
* Radians.
|
||||
*/
|
||||
RAD("rad");
|
||||
|
||||
private final String displayString;
|
||||
|
||||
Unit(String displayString) {
|
||||
this.displayString = displayString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.opentcs.guing.base.model.elements.BlockModel.Type;
|
||||
|
||||
/**
|
||||
* Subclass for a {@link Type} selection property.
|
||||
*/
|
||||
public class BlockTypeProperty
|
||||
extends
|
||||
SelectionProperty<Type> {
|
||||
|
||||
public BlockTypeProperty(
|
||||
ModelComponent model,
|
||||
List<Type> possibleValues,
|
||||
Object value
|
||||
) {
|
||||
super(model, possibleValues, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for a boolean value.
|
||||
*/
|
||||
public class BooleanProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public BooleanProperty(ModelComponent model) {
|
||||
this(model, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new property with a value.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The value.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public BooleanProperty(ModelComponent model, boolean value) {
|
||||
super(model);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
@Override // Property
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
BooleanProperty booleanProperty = (BooleanProperty) property;
|
||||
setValue(booleanProperty.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.opentcs.util.Assertions.checkArgument;
|
||||
|
||||
import org.opentcs.guing.base.model.BoundingBoxModel;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a bounding box.
|
||||
*/
|
||||
public class BoundingBoxProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
public BoundingBoxProperty(ModelComponent model, BoundingBoxModel boundingBox) {
|
||||
super(model);
|
||||
fValue = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
BoundingBoxProperty other = (BoundingBoxProperty) property;
|
||||
setValue(other.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
BoundingBoxProperty clone = (BoundingBoxProperty) super.clone();
|
||||
clone.setValue(getValue());
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"(%s, %s, %s), offset: (%s, %s)",
|
||||
getValue().getLength(),
|
||||
getValue().getWidth(),
|
||||
getValue().getHeight(),
|
||||
getValue().getReferenceOffset().getX(),
|
||||
getValue().getReferenceOffset().getY()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBoxModel getValue() {
|
||||
return (BoundingBoxModel) super.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
checkArgument(
|
||||
newValue instanceof BoundingBoxModel,
|
||||
"newValue is not an instance of BoundingBoxModel"
|
||||
);
|
||||
|
||||
super.setValue(newValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.awt.Color;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A color property.
|
||||
*/
|
||||
public final class ColorProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* The color.
|
||||
*/
|
||||
private Color fColor;
|
||||
|
||||
/**
|
||||
* Create a new instance with a color.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param color The color.
|
||||
*/
|
||||
public ColorProperty(ModelComponent model, Color color) {
|
||||
super(model);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color.
|
||||
*
|
||||
* @param color The color
|
||||
*/
|
||||
public void setColor(Color color) {
|
||||
fColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color.
|
||||
*
|
||||
* @return The color.
|
||||
*/
|
||||
public Color getColor() {
|
||||
return fColor;
|
||||
}
|
||||
|
||||
@Override // Property
|
||||
public Object getComparableValue() {
|
||||
return fColor;
|
||||
}
|
||||
|
||||
@Override // AbstractProperty
|
||||
public void copyFrom(Property property) {
|
||||
ColorProperty colorProperty = (ColorProperty) property;
|
||||
setColor(colorProperty.getColor());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* An attribute for coordinates.
|
||||
* Examples: 1 mm, 20 cm, 3.4 m, 17.98 km
|
||||
*/
|
||||
public class CoordinateProperty
|
||||
extends
|
||||
LengthProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance of CoordinateProperty.
|
||||
*
|
||||
* @param model Point- or LocationModel.
|
||||
*/
|
||||
public CoordinateProperty(ModelComponent model) {
|
||||
this(model, 0, Unit.MM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of CoordinateProperty.
|
||||
*
|
||||
* @param model Point- or LocationModel.
|
||||
* @param value The initial value.
|
||||
* @param unit The initial unit.
|
||||
*/
|
||||
public CoordinateProperty(ModelComponent model, double value, Unit unit) {
|
||||
super(model, value, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initValidRange() {
|
||||
validRange.setMin(Double.NEGATIVE_INFINITY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.data.model.Vehicle.EnergyLevelThresholdSet;
|
||||
|
||||
/**
|
||||
* A representation of an {@link EnergyLevelThresholdSet}.
|
||||
*/
|
||||
public class EnergyLevelThresholdSetModel {
|
||||
|
||||
private final int energyLevelCritical;
|
||||
private final int energyLevelGood;
|
||||
private final int energyLevelSufficientlyRecharged;
|
||||
private final int energyLevelFullyRecharged;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param energyLevelCritical The value at/below which the vehicle's energy level is considered
|
||||
* "critical".
|
||||
* @param energyLevelGood The value at/above which the vehicle's energy level is considered
|
||||
* "good".
|
||||
* @param energyLevelSufficientlyRecharged The value at/above which the vehicle's energy level
|
||||
* is considered fully recharged.
|
||||
* @param energyLevelFullyRecharged The value at/above which the vehicle's energy level is
|
||||
* considered sufficiently recharged.
|
||||
*/
|
||||
public EnergyLevelThresholdSetModel(
|
||||
int energyLevelCritical,
|
||||
int energyLevelGood,
|
||||
int energyLevelSufficientlyRecharged,
|
||||
int energyLevelFullyRecharged
|
||||
) {
|
||||
this.energyLevelCritical = energyLevelCritical;
|
||||
this.energyLevelGood = energyLevelGood;
|
||||
this.energyLevelSufficientlyRecharged = energyLevelSufficientlyRecharged;
|
||||
this.energyLevelFullyRecharged = energyLevelFullyRecharged;
|
||||
}
|
||||
|
||||
public int getEnergyLevelCritical() {
|
||||
return energyLevelCritical;
|
||||
}
|
||||
|
||||
public int getEnergyLevelGood() {
|
||||
return energyLevelGood;
|
||||
}
|
||||
|
||||
public int getEnergyLevelSufficientlyRecharged() {
|
||||
return energyLevelSufficientlyRecharged;
|
||||
}
|
||||
|
||||
public int getEnergyLevelFullyRecharged() {
|
||||
return energyLevelFullyRecharged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.opentcs.util.Assertions.checkArgument;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains an {@link EnergyLevelThresholdSetModel}.
|
||||
*/
|
||||
public class EnergyLevelThresholdSetProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
public EnergyLevelThresholdSetProperty(
|
||||
ModelComponent model,
|
||||
EnergyLevelThresholdSetModel energyLevelThresholdSet
|
||||
) {
|
||||
super(model);
|
||||
fValue = energyLevelThresholdSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
EnergyLevelThresholdSetProperty other = (EnergyLevelThresholdSetProperty) property;
|
||||
setValue(other.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
EnergyLevelThresholdSetProperty clone = (EnergyLevelThresholdSetProperty) super.clone();
|
||||
clone.setValue(getValue());
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"(%s%%, %s%%, %s%%, %s%%)",
|
||||
getValue().getEnergyLevelCritical(),
|
||||
getValue().getEnergyLevelGood(),
|
||||
getValue().getEnergyLevelSufficientlyRecharged(),
|
||||
getValue().getEnergyLevelFullyRecharged()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public EnergyLevelThresholdSetModel getValue() {
|
||||
return (EnergyLevelThresholdSetModel) super.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
checkArgument(
|
||||
newValue instanceof EnergyLevelThresholdSetModel,
|
||||
"newValue is not an instance of EnergyLevelThresholdSetModel"
|
||||
);
|
||||
|
||||
super.setValue(newValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.guing.base.model.EnvelopeModel;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a list of envelopes.
|
||||
*/
|
||||
public class EnvelopesProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
public EnvelopesProperty(
|
||||
ModelComponent model,
|
||||
List<EnvelopeModel> envelopes
|
||||
) {
|
||||
super(model);
|
||||
fValue = envelopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
EnvelopesProperty other = (EnvelopesProperty) property;
|
||||
setValue(new ArrayList<>(other.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
EnvelopesProperty clone = (EnvelopesProperty) super.clone();
|
||||
clone.setValue(new ArrayList<>(getValue()));
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().stream()
|
||||
.map(envelope -> envelope.getKey() + ": " + envelope.getVertices())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<EnvelopeModel> getValue() {
|
||||
return (List) super.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for an integer value.
|
||||
*/
|
||||
public class IntegerProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public IntegerProperty(ModelComponent model) {
|
||||
this(model, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with a value.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The value.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public IntegerProperty(ModelComponent model, int value) {
|
||||
super(model);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fValue instanceof Integer ? Integer.toString((int) fValue) : (String) fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
IntegerProperty integerProperty = (IntegerProperty) property;
|
||||
setValue(integerProperty.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property containing a key-value pair.
|
||||
*/
|
||||
public class KeyValueProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* The key.
|
||||
*/
|
||||
private String fKey;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public KeyValueProperty(ModelComponent model) {
|
||||
this(model, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with a key and value.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param key The key.
|
||||
* @param value The value.
|
||||
*/
|
||||
public KeyValueProperty(ModelComponent model, String key, String value) {
|
||||
super(model);
|
||||
fKey = key;
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return fKey + fValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the key and the value.
|
||||
*
|
||||
* @param key The key
|
||||
* @param value The value
|
||||
*/
|
||||
public void setKeyAndValue(String key, String value) {
|
||||
fKey = key;
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key.
|
||||
*
|
||||
* @return The key of this property.
|
||||
*/
|
||||
public String getKey() {
|
||||
return fKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return (String) fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fKey + "=" + fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
KeyValueProperty keyValueProperty = (KeyValueProperty) property;
|
||||
setKeyAndValue(keyValueProperty.getKey(), keyValueProperty.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* An attribute which contains a quantity of key-value pairs.
|
||||
*/
|
||||
public class KeyValueSetProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* The quantity of key-value-pairs.
|
||||
*/
|
||||
private List<KeyValueProperty> fItems = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public KeyValueSetProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (KeyValueProperty property : fItems) {
|
||||
sb.append(property.getKey()).append(property.getValue());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a property.
|
||||
*
|
||||
* @param item The property to add.
|
||||
*/
|
||||
public void addItem(KeyValueProperty item) {
|
||||
for (KeyValueProperty property : fItems) {
|
||||
if (item.getKey().equals(property.getKey())) {
|
||||
property.setKeyAndValue(property.getKey(), item.getValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a property.
|
||||
*
|
||||
* @param item The property to remove.
|
||||
*/
|
||||
public void removeItem(KeyValueProperty item) {
|
||||
fItems.remove(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list with key-value-pairs..
|
||||
*
|
||||
* @param items The values.
|
||||
*/
|
||||
public void setItems(List<KeyValueProperty> items) {
|
||||
fItems = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all key-value-pairs.
|
||||
*
|
||||
* @return The properties.
|
||||
*/
|
||||
public List<KeyValueProperty> getItems() {
|
||||
return fItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
KeyValueSetProperty other = (KeyValueSetProperty) property;
|
||||
List<KeyValueProperty> items = new ArrayList<>(other.getItems());
|
||||
setItems(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (fValue != null) {
|
||||
return fValue.toString();
|
||||
}
|
||||
|
||||
return getItems().stream()
|
||||
.sorted((i1, i2) -> i1.getKey().compareTo(i2.getKey()))
|
||||
.map(item -> item.toString())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
KeyValueSetProperty clone = (KeyValueSetProperty) super.clone();
|
||||
List<KeyValueProperty> items = new ArrayList<>(getItems());
|
||||
clone.setItems(items);
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.data.model.visualization.LayerGroup;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a list of layer groups.
|
||||
*/
|
||||
public class LayerGroupsProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
* @param layerGroups The layer groups.
|
||||
*/
|
||||
public LayerGroupsProperty(ModelComponent model, Map<Integer, LayerGroup> layerGroups) {
|
||||
super(model);
|
||||
fValue = layerGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().values().stream()
|
||||
.sorted(Comparator.comparing(group -> group.getId()))
|
||||
.map(group -> group.getName())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
LayerGroupsProperty other = (LayerGroupsProperty) property;
|
||||
Map<Integer, LayerGroup> items = new HashMap<>(other.getValue());
|
||||
setValue(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Integer, LayerGroup> getValue() {
|
||||
return (Map) super.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.components.layer.LayerWrapper;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a {@link LayerWrapper} instance.
|
||||
*/
|
||||
public class LayerWrapperProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The layer wrapper.
|
||||
*/
|
||||
public LayerWrapperProperty(ModelComponent model, LayerWrapper value) {
|
||||
super(model);
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return getValue().getLayer().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().getLayer().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
LayerWrapperProperty layerWrapperProperty = (LayerWrapperProperty) property;
|
||||
setValue(layerWrapperProperty.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayerWrapper getValue() {
|
||||
return (LayerWrapper) super.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.guing.base.components.layer.LayerWrapper;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a list of layer wrappers.
|
||||
*/
|
||||
public class LayerWrappersProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
* @param layerWrappers The layer wrappers.
|
||||
*/
|
||||
public LayerWrappersProperty(ModelComponent model, Map<Integer, LayerWrapper> layerWrappers) {
|
||||
super(model);
|
||||
fValue = layerWrappers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().values().stream()
|
||||
.sorted(Comparator.comparing(wrapper -> wrapper.getLayer().getId()))
|
||||
.map(wrapper -> wrapper.getLayer().getName())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
LayerWrappersProperty other = (LayerWrappersProperty) property;
|
||||
Map<Integer, LayerWrapper> items = new HashMap<>(other.getValue());
|
||||
setValue(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Integer, LayerWrapper> getValue() {
|
||||
return (Map) super.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for a length.
|
||||
*/
|
||||
public class LengthProperty
|
||||
extends
|
||||
AbstractQuantity<LengthProperty.Unit> {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public LengthProperty(ModelComponent model) {
|
||||
this(model, 0, Unit.MM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with a value and a unit.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The value.
|
||||
* @param unit The unit.
|
||||
*/
|
||||
public LengthProperty(ModelComponent model, double value, Unit unit) {
|
||||
super(model, value, unit, Unit.class, relations());
|
||||
}
|
||||
|
||||
@Override // Property
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue) + getUnit();
|
||||
}
|
||||
|
||||
private static List<Relation<Unit>> relations() {
|
||||
List<Relation<Unit>> relations = new ArrayList<>();
|
||||
relations.add(new Relation<>(Unit.MM, Unit.CM, 10));
|
||||
relations.add(new Relation<>(Unit.CM, Unit.M, 100));
|
||||
relations.add(new Relation<>(Unit.M, Unit.KM, 1000));
|
||||
return relations;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initValidRange() {
|
||||
validRange.setMin(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported length units.
|
||||
*/
|
||||
public enum Unit {
|
||||
|
||||
/**
|
||||
* Millimeters.
|
||||
*/
|
||||
MM("mm"),
|
||||
/**
|
||||
* Centimeters.
|
||||
*/
|
||||
CM("cm"),
|
||||
/**
|
||||
* Meters.
|
||||
*/
|
||||
M("m"),
|
||||
/**
|
||||
* Kilometers.
|
||||
*/
|
||||
KM("km");
|
||||
|
||||
private final String displayString;
|
||||
|
||||
Unit(String displayString) {
|
||||
this.displayString = displayString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.opentcs.guing.base.model.elements.PathModel.Type;
|
||||
|
||||
/**
|
||||
* Subclass for a {@link Type} selection property.
|
||||
*/
|
||||
public class LinerTypeProperty
|
||||
extends
|
||||
SelectionProperty<Type> {
|
||||
|
||||
public LinerTypeProperty(
|
||||
ModelComponent model,
|
||||
List<Type> possibleValues,
|
||||
Object value
|
||||
) {
|
||||
super(model, possibleValues, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for link actions.
|
||||
*/
|
||||
public class LinkActionsProperty
|
||||
extends
|
||||
StringSetProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public LinkActionsProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for location actions.
|
||||
*/
|
||||
public class LocationTypeActionsProperty
|
||||
extends
|
||||
StringSetProperty {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public LocationTypeActionsProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that can take a value from a given set of location types.
|
||||
*/
|
||||
public class LocationTypeProperty
|
||||
extends
|
||||
AbstractProperty
|
||||
implements
|
||||
Selectable<String> {
|
||||
|
||||
private List<String> fPossibleValues;
|
||||
|
||||
public LocationTypeProperty(ModelComponent model) {
|
||||
this(model, new ArrayList<>(), "");
|
||||
}
|
||||
|
||||
public LocationTypeProperty(ModelComponent model, List<String> possibleValues, Object value) {
|
||||
super(model);
|
||||
this.fPossibleValues = requireNonNull(possibleValues, "possibleValues");
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (fPossibleValues.contains(value)
|
||||
|| value instanceof AcceptableInvalidValue) {
|
||||
super.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return fPossibleValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPossibleValues(List<String> possibleValues) {
|
||||
fPossibleValues = requireNonNull(possibleValues, "possibleValues");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
LocationTypeProperty locTypeProperty = (LocationTypeProperty) property;
|
||||
setValue(locTypeProperty.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Interface to specify how an attribute of a model component must appear.
|
||||
*/
|
||||
public interface ModelAttribute
|
||||
extends
|
||||
Serializable {
|
||||
|
||||
/**
|
||||
* Potential change states of the attribute.
|
||||
*/
|
||||
enum ChangeState {
|
||||
/**
|
||||
* The attribute has not changed.
|
||||
*/
|
||||
NOT_CHANGED,
|
||||
/**
|
||||
* The attribute has changed.
|
||||
*/
|
||||
CHANGED,
|
||||
/**
|
||||
* (Only) A detail of the attribute has changed.
|
||||
*/
|
||||
DETAIL_CHANGED,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the model component this attribute is attached to.
|
||||
*
|
||||
* @return The model component.
|
||||
*/
|
||||
ModelComponent getModel();
|
||||
|
||||
/**
|
||||
* Sets the model component this attribute is attached to.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
void setModel(ModelComponent model);
|
||||
|
||||
/**
|
||||
* Marks the attribute as changed.
|
||||
*/
|
||||
void markChanged();
|
||||
|
||||
/**
|
||||
* Marks the attribute as not changed.
|
||||
*/
|
||||
void unmarkChanged();
|
||||
|
||||
/**
|
||||
* Sets the change state for this attribute.
|
||||
*
|
||||
* @param changeState The new change state.
|
||||
*/
|
||||
void setChangeState(AbstractModelAttribute.ChangeState changeState);
|
||||
|
||||
/**
|
||||
* Returns whether or not the attribute has changed.
|
||||
*
|
||||
* @return {@code true}, if the state of the model attribute has changed, otherwiese
|
||||
* {@code false}.
|
||||
*/
|
||||
boolean hasChanged();
|
||||
|
||||
/**
|
||||
* Sets the description of the attribute.
|
||||
*
|
||||
* @param description The description.
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
/**
|
||||
* Returns the description of the attribute.
|
||||
*
|
||||
* @return The description.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Sets the tooltip text for this attribute.
|
||||
*
|
||||
* @param helptext The tooltip text.
|
||||
*/
|
||||
void setHelptext(String helptext);
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for this attribute.
|
||||
*
|
||||
* @return The helptext.
|
||||
*/
|
||||
String getHelptext();
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets whether or not the attribute is collectively editable with attributes
|
||||
* of the same name of other model components.
|
||||
*
|
||||
* @param collectiveEditable Whether the attribute is collectively editable with attributes
|
||||
* of the same name of other model components.
|
||||
*/
|
||||
void setCollectiveEditable(boolean collectiveEditable);
|
||||
|
||||
/**
|
||||
* Returns whether or not the attribute is collectively editable with attributes of the same name
|
||||
* of other model components.
|
||||
*
|
||||
* @return Whether the attribute is collectively editable with attributes of the same name
|
||||
* of other model components.
|
||||
*/
|
||||
boolean isCollectiveEditable();
|
||||
|
||||
/**
|
||||
* Sets whether or not the attribute can be changed in modelling mode.
|
||||
*
|
||||
* @param editable True if the attribute can be changed in modelling mode.
|
||||
*/
|
||||
void setModellingEditable(boolean editable);
|
||||
|
||||
/**
|
||||
* Returns whether or not the attribute can be changed in modelling mode.
|
||||
*
|
||||
* @return True if the attribute can be changed in modelling mode.
|
||||
*/
|
||||
boolean isModellingEditable();
|
||||
|
||||
/**
|
||||
* Sets whether or not the attribute can be changed in operating mode.
|
||||
*
|
||||
* @param editable True if the attribute can be changed in operating mode.
|
||||
*/
|
||||
void setOperatingEditable(boolean editable);
|
||||
|
||||
/**
|
||||
* Returns whether or not the attribute can be changed in operating mode.
|
||||
*
|
||||
* @return True if the attribute can be changed in operating mode.
|
||||
*/
|
||||
boolean isOperatingEditable();
|
||||
|
||||
/**
|
||||
* Whether this attribute should be included when persisting the model to a file.
|
||||
*
|
||||
* @return true, if this attribute should be included when persisting the model to a file.
|
||||
*/
|
||||
default boolean isPersistent() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MultipleDifferentValues
|
||||
implements
|
||||
AcceptableInvalidValue {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public MultipleDifferentValues() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ResourceBundle.getBundle(BUNDLE_PATH)
|
||||
.getString("multipleDifferentValues.description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelptext() {
|
||||
return ResourceBundle.getBundle(BUNDLE_PATH)
|
||||
.getString("multipleDifferentValues.helptext");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a set of transport order types represented by strings.
|
||||
*/
|
||||
public class OrderTypesProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* The set of transport order types.
|
||||
*/
|
||||
private Set<String> fItems = new TreeSet<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public OrderTypesProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (String s : fItems) {
|
||||
sb.append(s);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string.
|
||||
*
|
||||
* @param item The string to add.
|
||||
*/
|
||||
public void addItem(String item) {
|
||||
fItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of strings.
|
||||
*
|
||||
* @param items The list.
|
||||
*/
|
||||
public void setItems(Set<String> items) {
|
||||
fItems = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of string.
|
||||
*
|
||||
* @return The list.
|
||||
*/
|
||||
public Set<String> getItems() {
|
||||
return fItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
OrderTypesProperty other = (OrderTypesProperty) property;
|
||||
Set<String> items = new TreeSet<>(other.getItems());
|
||||
setItems(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
Iterator<String> e = getItems().iterator();
|
||||
|
||||
while (e.hasNext()) {
|
||||
b.append(e.next());
|
||||
|
||||
if (e.hasNext()) {
|
||||
b.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
OrderTypesProperty clone = (OrderTypesProperty) super.clone();
|
||||
Set<String> items = new TreeSet<>(getItems());
|
||||
clone.setItems(items);
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for percentages.
|
||||
*/
|
||||
public class PercentProperty
|
||||
extends
|
||||
AbstractQuantity<PercentProperty.Unit> {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public PercentProperty(ModelComponent model) {
|
||||
this(model, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param isInteger Whether only the integer part of the value is relevant.
|
||||
*/
|
||||
public PercentProperty(ModelComponent model, boolean isInteger) {
|
||||
this(model, Double.NaN, Unit.PERCENT, isInteger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with value.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The property's value.
|
||||
* @param unit The unit in which the value is measured.
|
||||
* @param isInteger Whether only the integer part of the value is relevant.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public PercentProperty(ModelComponent model, double value, Unit unit, boolean isInteger) {
|
||||
super(model, value, unit, Unit.class, new ArrayList<Relation<Unit>>());
|
||||
setInteger(isInteger);
|
||||
}
|
||||
|
||||
@Override // Property
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue) + getUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initValidRange() {
|
||||
validRange.setMin(0).setMax(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported units.
|
||||
*/
|
||||
public enum Unit {
|
||||
|
||||
/**
|
||||
* Percent.
|
||||
*/
|
||||
PERCENT("%");
|
||||
|
||||
private final String displayString;
|
||||
|
||||
Unit(String displayString) {
|
||||
this.displayString = displayString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.opentcs.guing.base.model.PeripheralOperationModel;
|
||||
|
||||
/**
|
||||
* A property that contains a list of Peripheral operations.
|
||||
*/
|
||||
public class PeripheralOperationsProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
public PeripheralOperationsProperty(
|
||||
ModelComponent model,
|
||||
List<PeripheralOperationModel> operations
|
||||
) {
|
||||
super(model);
|
||||
fValue = operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().stream()
|
||||
.map(op -> op.getLocationName() + ": " + op.getOperation())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
PeripheralOperationsProperty other = (PeripheralOperationsProperty) property;
|
||||
setValue(new ArrayList<>(other.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
PeripheralOperationsProperty clone = (PeripheralOperationsProperty) super.clone();
|
||||
clone.setValue(new ArrayList<>(getValue()));
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<PeripheralOperationModel> getValue() {
|
||||
return (List) super.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.opentcs.guing.base.model.elements.PointModel.Type;
|
||||
|
||||
/**
|
||||
* Subclass for a {@link Type} selection property.
|
||||
*/
|
||||
public class PointTypeProperty
|
||||
extends
|
||||
SelectionProperty<Type> {
|
||||
|
||||
public PointTypeProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
public PointTypeProperty(
|
||||
ModelComponent model,
|
||||
List<Type> possibleValues,
|
||||
Object value
|
||||
) {
|
||||
super(model, possibleValues, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
/**
|
||||
* Interface for properties.
|
||||
* Wraps a type into a property to be able to change a value without creating a new object.
|
||||
* The property object stays the same while the value changes.
|
||||
*/
|
||||
public interface Property
|
||||
extends
|
||||
ModelAttribute,
|
||||
Cloneable {
|
||||
|
||||
/**
|
||||
* Copies the value of the property into this property.
|
||||
*
|
||||
* @param property The property.
|
||||
*/
|
||||
void copyFrom(Property property);
|
||||
|
||||
/**
|
||||
* Returns a comparable represantation of the value of this property.
|
||||
*
|
||||
* @return A represantation to compare this property to other ones.
|
||||
*/
|
||||
Object getComparableValue();
|
||||
|
||||
/**
|
||||
* Creates a copy of this property.
|
||||
*
|
||||
* @return The cloned property.
|
||||
*/
|
||||
Object clone();
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A conversion relationship between two units.
|
||||
*
|
||||
* @param <U> The type of units the relation is valid for.
|
||||
*/
|
||||
public class Relation<U>
|
||||
implements
|
||||
Serializable {
|
||||
|
||||
/**
|
||||
* The source unit.
|
||||
*/
|
||||
private final U fUnitFrom;
|
||||
/**
|
||||
* The destination unit.
|
||||
*/
|
||||
private final U fUnitTo;
|
||||
/**
|
||||
* The conversion relationship.
|
||||
*/
|
||||
private final double fRelationValue;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param unitFrom The unit from which to convert.
|
||||
* @param unitTo The unit to which to convert.
|
||||
* @param relationValue The relation value between the two units.
|
||||
*/
|
||||
public Relation(U unitFrom, U unitTo, double relationValue) {
|
||||
fUnitFrom = unitFrom;
|
||||
fUnitTo = unitTo;
|
||||
fRelationValue = relationValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this relation is applicable to the specified units.
|
||||
*
|
||||
* @param unitA The first unit.
|
||||
* @param unitB The second unit.
|
||||
* @return {@code true}, if the two given units are covered by this relation, otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
public boolean fits(U unitA, U unitB) {
|
||||
if (fUnitFrom.equals(unitA) && fUnitTo.equals(unitB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fUnitFrom.equals(unitB) && fUnitTo.equals(unitA)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the conversion relationship as a number.
|
||||
*
|
||||
* @return The relation value between the two units.
|
||||
*/
|
||||
public double relationValue() {
|
||||
return fRelationValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the operation used for the conversion of the first unit into the second unit.
|
||||
*
|
||||
* @param unitFrom The unit from which to convert.
|
||||
* @param unitTo The unit to which to convert.
|
||||
* @return The operation that is to be used for the conversion.
|
||||
*/
|
||||
public Operation getOperation(U unitFrom, U unitTo) {
|
||||
if (unitFrom.equals(fUnitFrom)) {
|
||||
return Operation.DIVISION;
|
||||
}
|
||||
else {
|
||||
return Operation.MULTIPLICATION;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported operations.
|
||||
*/
|
||||
public enum Operation {
|
||||
/**
|
||||
* A division.
|
||||
*/
|
||||
DIVISION,
|
||||
/**
|
||||
* A multiplication.
|
||||
*/
|
||||
MULTIPLICATION
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.opentcs.data.model.TCSResourceReference;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that holds a list of sets of {@link TCSResourceReference}s.
|
||||
*/
|
||||
public class ResourceProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* A list of of sets {@link TCSResourceReference}s.
|
||||
*/
|
||||
private List<Set<TCSResourceReference<?>>> items = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new ResourceProperty instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public ResourceProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return items.stream()
|
||||
.flatMap(set -> set.stream())
|
||||
.map(r -> r.getName())
|
||||
.collect(Collectors.joining());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all items of this property.
|
||||
*
|
||||
* @return a list of all items of this property.
|
||||
*/
|
||||
public List<Set<TCSResourceReference<?>>> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list.
|
||||
*
|
||||
* @param items the list of items for this property.
|
||||
*/
|
||||
public void setItems(List<Set<TCSResourceReference<?>>> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one item to the list.
|
||||
*
|
||||
* @param item the item to add.
|
||||
*/
|
||||
public void addItem(Set<TCSResourceReference<?>> item) {
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one item from the list.
|
||||
*
|
||||
* @param item the item to remove.
|
||||
*/
|
||||
public void removeItem(Set<TCSResourceReference<?>> item) {
|
||||
items.remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
ResourceProperty other = (ResourceProperty) property;
|
||||
List<Set<TCSResourceReference<?>>> items = new ArrayList<>(other.getItems());
|
||||
setItems(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (fValue != null) {
|
||||
return fValue.toString();
|
||||
}
|
||||
|
||||
return items.stream()
|
||||
.flatMap(set -> set.stream())
|
||||
.map(r -> r.getName())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
ResourceProperty clone = (ResourceProperty) super.clone();
|
||||
List<Set<TCSResourceReference<?>>> items = new ArrayList<>(getItems());
|
||||
clone.setItems(items);
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for a property indicating this property has different
|
||||
* possible values to choose from.
|
||||
*
|
||||
* @param <E> The type of elements that can be selected from.
|
||||
*/
|
||||
public interface Selectable<E> {
|
||||
|
||||
/**
|
||||
* Sets the possible values.
|
||||
*
|
||||
* @param possibleValues An array with the possible values.
|
||||
*/
|
||||
void setPossibleValues(List<E> possibleValues);
|
||||
|
||||
/**
|
||||
* Returns the possible values.
|
||||
*
|
||||
* @return The possible values.
|
||||
*/
|
||||
List<E> getPossibleValues();
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property whose value is one out of a list of possible values.
|
||||
*
|
||||
* @param <E> The type of the enum.
|
||||
*/
|
||||
public class SelectionProperty<E extends Enum<E>>
|
||||
extends
|
||||
AbstractProperty
|
||||
implements
|
||||
Selectable<E> {
|
||||
|
||||
/**
|
||||
* The possible values.
|
||||
*/
|
||||
private List<E> fPossibleValues;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public SelectionProperty(ModelComponent model) {
|
||||
this(model, new ArrayList<>(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model Component.
|
||||
* @param possibleValues The possible values.
|
||||
* @param value The value.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public SelectionProperty(
|
||||
ModelComponent model, List<E> possibleValues,
|
||||
Object value
|
||||
) {
|
||||
super(model);
|
||||
setPossibleValues(possibleValues);
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return fValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the possible values for this property.
|
||||
*
|
||||
* @param possibleValues A list of possible values.
|
||||
*/
|
||||
@Override
|
||||
public void setPossibleValues(List<E> possibleValues) {
|
||||
fPossibleValues = Objects.requireNonNull(possibleValues, "possibleValues is null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (fPossibleValues.contains(value)
|
||||
|| value instanceof AcceptableInvalidValue) {
|
||||
fValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getValue().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> getPossibleValues() {
|
||||
return fPossibleValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
AbstractProperty selectionProperty = (AbstractProperty) property;
|
||||
setValue(selectionProperty.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for speeds.
|
||||
*/
|
||||
public class SpeedProperty
|
||||
extends
|
||||
AbstractQuantity<SpeedProperty.Unit> {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public SpeedProperty(ModelComponent model) {
|
||||
this(model, 0, Unit.M_S);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with a value and a unit.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param value The value.
|
||||
* @param unit The unit.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public SpeedProperty(ModelComponent model, double value, Unit unit) {
|
||||
super(model, value, unit, Unit.class, relations());
|
||||
setUnsigned(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return String.valueOf(fValue) + getUnit();
|
||||
}
|
||||
|
||||
private static List<Relation<Unit>> relations() {
|
||||
List<Relation<Unit>> relations = new ArrayList<>();
|
||||
relations.add(new Relation<>(Unit.KM_H, Unit.M_S, 3.6));
|
||||
relations.add(new Relation<>(Unit.M_S, Unit.MM_S, 0.001));
|
||||
return relations;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initValidRange() {
|
||||
validRange.setMin(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported speed units.
|
||||
*/
|
||||
public enum Unit {
|
||||
/**
|
||||
* Kilometers per hour.
|
||||
*/
|
||||
KM_H("km/h"),
|
||||
/**
|
||||
* Meters per second.
|
||||
*/
|
||||
M_S("m/s"),
|
||||
/**
|
||||
* Millimeters per second.
|
||||
*/
|
||||
MM_S("mm/s");
|
||||
|
||||
private final String displayString;
|
||||
|
||||
Unit(String displayString) {
|
||||
this.displayString = displayString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for a string.
|
||||
*/
|
||||
public class StringProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* The string.
|
||||
*/
|
||||
private String fText;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public StringProperty(ModelComponent model) {
|
||||
this(model, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with a value.
|
||||
*
|
||||
* @param model The model component.
|
||||
* @param text The text.
|
||||
*/
|
||||
public StringProperty(ModelComponent model, String text) {
|
||||
super(model);
|
||||
fText = requireNonNull(text, "text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return fText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string.
|
||||
*
|
||||
* @param text the new string.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
fText = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string.
|
||||
*
|
||||
* @return The String.
|
||||
*/
|
||||
public String getText() {
|
||||
return fText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
StringProperty stringProperty = (StringProperty) property;
|
||||
setText(stringProperty.getText());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property that contains a quantity of strings.
|
||||
*/
|
||||
public class StringSetProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* The strings.
|
||||
*/
|
||||
private List<String> fItems = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public StringSetProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (String s : fItems) {
|
||||
sb.append(s);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string.
|
||||
*
|
||||
* @param item The string to add.
|
||||
*/
|
||||
public void addItem(String item) {
|
||||
fItems.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of strings.
|
||||
*
|
||||
* @param items The list.
|
||||
*/
|
||||
public void setItems(List<String> items) {
|
||||
fItems = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of string.
|
||||
*
|
||||
* @return The list.
|
||||
*/
|
||||
public List<String> getItems() {
|
||||
return fItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
StringSetProperty other = (StringSetProperty) property;
|
||||
setItems(new ArrayList<>(other.getItems()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
Iterator<String> e = getItems().iterator();
|
||||
|
||||
while (e.hasNext()) {
|
||||
b.append(e.next());
|
||||
|
||||
if (e.hasNext()) {
|
||||
b.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
StringSetProperty clone = (StringSetProperty) super.clone();
|
||||
clone.setItems(new ArrayList<>(getItems()));
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.data.model.visualization.LocationRepresentation;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* A property for a graphical symbol.
|
||||
*/
|
||||
public class SymbolProperty
|
||||
extends
|
||||
AbstractComplexProperty {
|
||||
|
||||
/**
|
||||
* The location representation.
|
||||
*/
|
||||
private LocationRepresentation locationRepresentation;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component this property belongs to.
|
||||
*/
|
||||
public SymbolProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return locationRepresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the location representation for this property.
|
||||
*
|
||||
* @param locationRepresentation The location representation.
|
||||
*/
|
||||
public void setLocationRepresentation(LocationRepresentation locationRepresentation) {
|
||||
this.locationRepresentation = locationRepresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location representation for this property.
|
||||
*
|
||||
* @return The location representation.
|
||||
*/
|
||||
public LocationRepresentation getLocationRepresentation() {
|
||||
return locationRepresentation;
|
||||
}
|
||||
|
||||
@Override // java.lang.Object
|
||||
public String toString() {
|
||||
if (fValue != null) {
|
||||
return fValue.toString();
|
||||
}
|
||||
|
||||
return locationRepresentation == null ? "" : locationRepresentation.name();
|
||||
}
|
||||
|
||||
@Override // AbstractProperty
|
||||
public void copyFrom(Property property) {
|
||||
SymbolProperty symbolProperty = (SymbolProperty) property;
|
||||
symbolProperty.setValue(null);
|
||||
setLocationRepresentation(symbolProperty.getLocationRepresentation());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import org.opentcs.data.model.Triple;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A property for a 3 dimensional point.
|
||||
*/
|
||||
public class TripleProperty
|
||||
extends
|
||||
AbstractProperty {
|
||||
|
||||
/**
|
||||
* The point.
|
||||
*/
|
||||
private Triple fTriple;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param model The model component.
|
||||
*/
|
||||
public TripleProperty(ModelComponent model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComparableValue() {
|
||||
return fTriple.getX() + "," + fTriple.getY() + "," + fTriple.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of this property.
|
||||
*
|
||||
* @param triple The triple.
|
||||
*/
|
||||
public void setValue(Triple triple) {
|
||||
fTriple = triple;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Triple getValue() {
|
||||
return fTriple;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fTriple == null ? "null"
|
||||
: String.format("(%d, %d, %d)", fTriple.getX(), fTriple.getY(), fTriple.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(Property property) {
|
||||
TripleProperty tripleProperty = (TripleProperty) property;
|
||||
|
||||
try {
|
||||
Triple foreignTriple = tripleProperty.getValue();
|
||||
setValue(foreignTriple);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LoggerFactory.getLogger(TripleProperty.class).error("Exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.opentcs.guing.base.model.elements.BlockModel;
|
||||
|
||||
/**
|
||||
* An event that informs listener about changes in a block area.
|
||||
*/
|
||||
public class BlockChangeEvent
|
||||
extends
|
||||
EventObject {
|
||||
|
||||
/**
|
||||
* Creates a new instance of BlockElementChangeEvent.
|
||||
*
|
||||
* @param block The <code>BlockModel</code> that has changed.
|
||||
*/
|
||||
public BlockChangeEvent(BlockModel block) {
|
||||
super(block);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.event;
|
||||
|
||||
/**
|
||||
* Interface for listener that want to be informed wenn a block area has
|
||||
* changed.
|
||||
*/
|
||||
public interface BlockChangeListener {
|
||||
|
||||
/**
|
||||
* Message that the course elements have changed.
|
||||
*
|
||||
* @param e The fire event.
|
||||
*/
|
||||
void courseElementsChanged(BlockChangeEvent e);
|
||||
|
||||
/**
|
||||
* Message that the color of the block area has changed.
|
||||
*
|
||||
* @param e The fire event.
|
||||
*/
|
||||
void colorChanged(BlockChangeEvent e);
|
||||
|
||||
/**
|
||||
* Message that a block area was removed.
|
||||
*
|
||||
* @param e The fire event.
|
||||
*/
|
||||
void blockRemoved(BlockChangeEvent e);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.opentcs.guing.base.model.elements.AbstractConnection;
|
||||
|
||||
/**
|
||||
* An event for changes on connections.
|
||||
*/
|
||||
public class ConnectionChangeEvent
|
||||
extends
|
||||
EventObject {
|
||||
|
||||
/**
|
||||
* Creates a new instance of ConnectionChangeEvent.
|
||||
*
|
||||
* @param connection The connection that has changed.
|
||||
*/
|
||||
public ConnectionChangeEvent(AbstractConnection connection) {
|
||||
super(connection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.event;
|
||||
|
||||
/**
|
||||
* Interface for listeners that want to be informed on connection changes.
|
||||
*/
|
||||
public interface ConnectionChangeListener {
|
||||
|
||||
/**
|
||||
* Message from a connection that its components have changed.
|
||||
*
|
||||
* @param e The fired event.
|
||||
*/
|
||||
void connectionChanged(ConnectionChangeEvent e);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.elements.AbstractConnection;
|
||||
|
||||
/**
|
||||
* A {@link ModelComponent} that can be connected with another model component.
|
||||
*/
|
||||
public abstract class AbstractConnectableModelComponent
|
||||
extends
|
||||
AbstractModelComponent
|
||||
implements
|
||||
DrawnModelComponent,
|
||||
ConnectableModelComponent {
|
||||
|
||||
/**
|
||||
* The Links and Paths connected with this model component (Location or Point).
|
||||
*/
|
||||
private List<AbstractConnection> fConnections = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public AbstractConnectableModelComponent() {
|
||||
// Do nada.
|
||||
}
|
||||
|
||||
@Override // ConnectableModelComponent
|
||||
public void addConnection(AbstractConnection connection) {
|
||||
fConnections.add(connection);
|
||||
}
|
||||
|
||||
@Override // ConnectableModelComponent
|
||||
public void removeConnection(AbstractConnection connection) {
|
||||
fConnections.remove(connection);
|
||||
}
|
||||
|
||||
@Override // ConnectableModelComponent
|
||||
public List<AbstractConnection> getConnections() {
|
||||
return fConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there is a connection to the given component.
|
||||
*
|
||||
* @param component The component.
|
||||
* @return <code>true</code> if, and only if, this component is connected to
|
||||
* the given one.
|
||||
*/
|
||||
public boolean hasConnectionTo(ConnectableModelComponent component) {
|
||||
return getConnectionTo(component) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connection to the given component.
|
||||
*
|
||||
* @param component The component.
|
||||
* @return The connection to the given component, or <code>null</code>, if
|
||||
* there is none.
|
||||
*/
|
||||
public AbstractConnection getConnectionTo(ConnectableModelComponent component) {
|
||||
for (AbstractConnection connection : fConnections) {
|
||||
if (connection.getStartComponent() == this
|
||||
&& connection.getEndComponent() == component) {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public AbstractModelComponent clone()
|
||||
throws CloneNotSupportedException {
|
||||
AbstractConnectableModelComponent clone = (AbstractConnectableModelComponent) super.clone();
|
||||
clone.fConnections = new ArrayList<>();
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeEvent;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.Property;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
|
||||
/**
|
||||
* Abstract implementation of a model component.
|
||||
*/
|
||||
public abstract class AbstractModelComponent
|
||||
implements
|
||||
ModelComponent {
|
||||
|
||||
/**
|
||||
* Name of the component in the tree view.
|
||||
*/
|
||||
private final String fTreeViewName;
|
||||
/**
|
||||
* Whether or not the component is visible in the tree view.
|
||||
*/
|
||||
private boolean fTreeViewVisibility = true;
|
||||
/**
|
||||
* The parent component.
|
||||
*/
|
||||
private transient ModelComponent fParent;
|
||||
/**
|
||||
* Attribute change listeners.
|
||||
*/
|
||||
private transient List<AttributesChangeListener> fAttributesChangeListeners
|
||||
= new CopyOnWriteArrayList<>();
|
||||
/**
|
||||
* The actual parent of this component. PropertiesCollection e.g.
|
||||
* overwrites it.
|
||||
*/
|
||||
private ModelComponent actualParent;
|
||||
/**
|
||||
* The component's attributes.
|
||||
*/
|
||||
private Map<String, Property> fProperties = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public AbstractModelComponent() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the given name.
|
||||
*
|
||||
* @param treeViewName The name.
|
||||
*/
|
||||
public AbstractModelComponent(String treeViewName) {
|
||||
fTreeViewName = requireNonNull(treeViewName, "treeViewName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ModelComponent component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ModelComponent component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelComponent> getChildComponents() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTreeViewName() {
|
||||
return fTreeViewName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ModelComponent component) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelComponent getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelComponent getActualParent() {
|
||||
return actualParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(ModelComponent parent) {
|
||||
if (parent instanceof PropertiesCollection) {
|
||||
actualParent = fParent;
|
||||
}
|
||||
fParent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreeViewVisible() {
|
||||
return fTreeViewVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTreeViewVisibility(boolean visibility) {
|
||||
fTreeViewVisibility = visibility;
|
||||
}
|
||||
|
||||
@Override // ModelComponent
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
StringProperty property = getPropertyName();
|
||||
return property == null ? "" : property.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
getPropertyName().setText(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty(String name) {
|
||||
return fProperties.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Property> getProperties() {
|
||||
return fProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String name, Property property) {
|
||||
fProperties.put(name, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAttributesChangeListener(AttributesChangeListener listener) {
|
||||
if (fAttributesChangeListeners == null) {
|
||||
fAttributesChangeListeners = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
if (!fAttributesChangeListeners.contains(listener)) {
|
||||
fAttributesChangeListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttributesChangeListener(AttributesChangeListener listener) {
|
||||
if (fAttributesChangeListeners != null) {
|
||||
fAttributesChangeListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAttributesChangeListener(AttributesChangeListener listener) {
|
||||
if (fAttributesChangeListeners == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return fAttributesChangeListeners.contains(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertiesChanged(AttributesChangeListener initiator) {
|
||||
if (fAttributesChangeListeners != null) {
|
||||
for (AttributesChangeListener listener : fAttributesChangeListeners) {
|
||||
if (initiator != listener) {
|
||||
listener.propertiesChanged(new AttributesChangeEvent(initiator, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
unmarkAllPropertyChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractModelComponent clone()
|
||||
throws CloneNotSupportedException {
|
||||
AbstractModelComponent clonedModelComponent = (AbstractModelComponent) super.clone();
|
||||
clonedModelComponent.fAttributesChangeListeners = new CopyOnWriteArrayList<>();
|
||||
// "Shallow" copy of the Map
|
||||
clonedModelComponent.fProperties = new LinkedHashMap<>();
|
||||
// "Deep" copy: clone all properties
|
||||
for (Map.Entry<String, Property> entry : getProperties().entrySet()) {
|
||||
Property clonedProperty = (Property) entry.getValue().clone();
|
||||
// XXX Don't clone the name but create a new, unique one here!
|
||||
if (entry.getKey().equals(NAME)) {
|
||||
((StringProperty) clonedProperty).setText("");
|
||||
}
|
||||
|
||||
clonedProperty.setModel(clonedModelComponent);
|
||||
clonedModelComponent.setProperty(entry.getKey(), clonedProperty);
|
||||
}
|
||||
|
||||
return clonedModelComponent;
|
||||
}
|
||||
|
||||
private void unmarkAllPropertyChanges() {
|
||||
for (Property property : fProperties.values()) {
|
||||
property.unmarkChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.opentcs.data.model.BoundingBox;
|
||||
import org.opentcs.data.model.Couple;
|
||||
|
||||
/**
|
||||
* A representation of a {@link BoundingBox}.
|
||||
*/
|
||||
public class BoundingBoxModel {
|
||||
|
||||
private final long length;
|
||||
private final long width;
|
||||
private final long height;
|
||||
private final Couple referenceOffset;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param length The bounding box's length.
|
||||
* @param width The bounding box's width.
|
||||
* @param height The bounding box's height.
|
||||
* @param referenceOffset The bounding box's reference offset.
|
||||
*/
|
||||
public BoundingBoxModel(
|
||||
long length,
|
||||
long width,
|
||||
long height,
|
||||
@Nonnull
|
||||
Couple referenceOffset
|
||||
) {
|
||||
this.length = length;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.referenceOffset = requireNonNull(referenceOffset, "referenceOffset");
|
||||
}
|
||||
|
||||
public long getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public long getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public long getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public Couple getReferenceOffset() {
|
||||
return referenceOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstract implementation of a composite model component that holds a set of child components.
|
||||
*/
|
||||
public abstract class CompositeModelComponent
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
|
||||
/**
|
||||
* The child elements.
|
||||
*/
|
||||
private List<ModelComponent> fChildComponents = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public CompositeModelComponent() {
|
||||
this("Composite");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the given name.
|
||||
*
|
||||
* @param treeViewName The name to be used.
|
||||
*/
|
||||
public CompositeModelComponent(String treeViewName) {
|
||||
super(treeViewName);
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public void add(ModelComponent component) {
|
||||
getChildComponents().add(component);
|
||||
component.setParent(this);
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public List<ModelComponent> getChildComponents() {
|
||||
return fChildComponents;
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public void remove(ModelComponent component) {
|
||||
getChildComponents().remove(component);
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public boolean contains(ModelComponent component) {
|
||||
return getChildComponents().contains(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeModelComponent clone()
|
||||
throws CloneNotSupportedException {
|
||||
CompositeModelComponent clone = (CompositeModelComponent) super.clone();
|
||||
clone.fChildComponents = new ArrayList<>(fChildComponents);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import java.util.List;
|
||||
import org.opentcs.guing.base.model.elements.AbstractConnection;
|
||||
|
||||
/**
|
||||
* A {@link ModelComponent} that can be connected with another model component.
|
||||
*/
|
||||
public interface ConnectableModelComponent
|
||||
extends
|
||||
ModelComponent {
|
||||
|
||||
/**
|
||||
* Adds a connection.
|
||||
*
|
||||
* @param connection The connection to be added.
|
||||
*/
|
||||
void addConnection(AbstractConnection connection);
|
||||
|
||||
/**
|
||||
* Returns all connections.
|
||||
*
|
||||
* @return All connections.
|
||||
*/
|
||||
List<AbstractConnection> getConnections();
|
||||
|
||||
/**
|
||||
* Removes a connection.
|
||||
*
|
||||
* @param connection The connection to be removed.
|
||||
*/
|
||||
void removeConnection(AbstractConnection connection);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrapperProperty;
|
||||
|
||||
/**
|
||||
* A model component that is drawn and represented by a corresponding figure.
|
||||
*/
|
||||
public interface DrawnModelComponent
|
||||
extends
|
||||
ModelComponent {
|
||||
|
||||
/**
|
||||
* The property key for the layer wrapper that contains the layer on which a model component
|
||||
* (respectively its figure) is to be drawn.
|
||||
*/
|
||||
String LAYER_WRAPPER = "LAYER_WRAPPER";
|
||||
|
||||
/**
|
||||
* Returns this component's layer wrapper property.
|
||||
*
|
||||
* @return This component's layer wrapper property.
|
||||
*/
|
||||
default LayerWrapperProperty getPropertyLayerWrapper() {
|
||||
return (LayerWrapperProperty) getProperty(LAYER_WRAPPER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import org.opentcs.data.model.Couple;
|
||||
import org.opentcs.data.model.Envelope;
|
||||
|
||||
/**
|
||||
* A representation of an {@link Envelope} with an additional (reference) key.
|
||||
*/
|
||||
public class EnvelopeModel {
|
||||
|
||||
private final String key;
|
||||
private final List<Couple> vertices;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param key The key to be used for referencing the envelope.
|
||||
* @param vertices The sequence of vertices the envelope consists of.
|
||||
*/
|
||||
public EnvelopeModel(
|
||||
@Nonnull
|
||||
String key,
|
||||
@Nonnull
|
||||
List<Couple> vertices
|
||||
) {
|
||||
this.key = requireNonNull(key, "key");
|
||||
this.vertices = requireNonNull(vertices, "vertices");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public List<Couple> getVertices() {
|
||||
return vertices;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.model.elements.BlockModel;
|
||||
import org.opentcs.guing.base.model.elements.VehicleModel;
|
||||
|
||||
/**
|
||||
* Provides methods to configure the data that is used to decorate a model component's figure.
|
||||
*/
|
||||
public interface FigureDecorationDetails {
|
||||
|
||||
/**
|
||||
* Returns a map of vehicles that claim or allocate the resource (the figure is associated with)
|
||||
* to the respective allocation state.
|
||||
* <p>
|
||||
* This information is used to decorate a model component's figure to indicate that it is part of
|
||||
* the route of the respective vehicles.
|
||||
*
|
||||
* @return A map of vehicles to allocation states.
|
||||
*/
|
||||
@Nonnull
|
||||
Map<VehicleModel, AllocationState> getAllocationStates();
|
||||
|
||||
/**
|
||||
* Updates the allocation state for the given vehicle.
|
||||
*
|
||||
* @param model The vehicle model.
|
||||
* @param allocationState The vehicle's new allocation state.
|
||||
*/
|
||||
void updateAllocationState(
|
||||
@Nonnull
|
||||
VehicleModel model,
|
||||
@Nonnull
|
||||
AllocationState allocationState
|
||||
);
|
||||
|
||||
/**
|
||||
* Clears the allocation state for the given vehicle.
|
||||
*
|
||||
* @param model The vehicle model.
|
||||
*/
|
||||
void clearAllocationState(
|
||||
@Nonnull
|
||||
VehicleModel model
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds a block model.
|
||||
*
|
||||
* @param model The block model.
|
||||
*/
|
||||
void addBlockModel(BlockModel model);
|
||||
|
||||
/**
|
||||
* Removes a block model.
|
||||
*
|
||||
* @param model The block model.
|
||||
*/
|
||||
void removeBlockModel(BlockModel model);
|
||||
|
||||
/**
|
||||
* Returns a set of block models for which a model component's figure is to be decorated to
|
||||
* indicate that the model component is part of the respective block.
|
||||
*
|
||||
* @return A set of block models.
|
||||
*/
|
||||
Set<BlockModel> getBlockModels();
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.Property;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
|
||||
/**
|
||||
* Defines a component in the system model.
|
||||
*/
|
||||
public interface ModelComponent
|
||||
extends
|
||||
Cloneable {
|
||||
|
||||
/**
|
||||
* Key for the name property.
|
||||
*/
|
||||
String NAME = "Name";
|
||||
/**
|
||||
* Key for the miscellaneous properties.
|
||||
*/
|
||||
String MISCELLANEOUS = "Miscellaneous";
|
||||
|
||||
/**
|
||||
* Adds a child component.
|
||||
*
|
||||
* @param component The model component to add.
|
||||
*/
|
||||
void add(ModelComponent component);
|
||||
|
||||
/**
|
||||
* Removes a child component.
|
||||
*
|
||||
* @param component The model component to remove.
|
||||
*/
|
||||
void remove(ModelComponent component);
|
||||
|
||||
/**
|
||||
* Returns all child components.
|
||||
*
|
||||
* @return A list of all child components.
|
||||
*/
|
||||
List<ModelComponent> getChildComponents();
|
||||
|
||||
/**
|
||||
* Retruns this model component's name that is displayed in the tree view.
|
||||
*
|
||||
* @return The name that is displayed in the tree view.
|
||||
*/
|
||||
String getTreeViewName();
|
||||
|
||||
/**
|
||||
* Returns whether the given component is a child of this model component.
|
||||
*
|
||||
* @param component The component.
|
||||
* @return {@code true}, if the given component is a child of this model component, otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
boolean contains(ModelComponent component);
|
||||
|
||||
/**
|
||||
* Returns this model component's parent component.
|
||||
*
|
||||
* @return The parent component.
|
||||
*/
|
||||
ModelComponent getParent();
|
||||
|
||||
/**
|
||||
* Returns the actual parent of this model component.
|
||||
* PropertiesCollection e.g. overwrites it. May be null.
|
||||
*
|
||||
* @return The actual parent.
|
||||
*/
|
||||
ModelComponent getActualParent();
|
||||
|
||||
/**
|
||||
* Set this model component's parent component.
|
||||
*
|
||||
* @param parent The new parent component.
|
||||
*/
|
||||
void setParent(ModelComponent parent);
|
||||
|
||||
/**
|
||||
* Returns whether this model component is to be shown in the tree view.
|
||||
*
|
||||
* @return {@code true}, if the model component is to be shown in the tree view, otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
boolean isTreeViewVisible();
|
||||
|
||||
/**
|
||||
* Sets this model component's visibility in the tree view.
|
||||
*
|
||||
* @param visibility Whether the model component is to be shown in the tree view or not.
|
||||
*/
|
||||
void setTreeViewVisibility(boolean visibility);
|
||||
|
||||
/**
|
||||
* Returns a description for the model component.
|
||||
*
|
||||
* @return A description for the model component.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Returns the name of the component.
|
||||
*
|
||||
* @return The name of the component.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets this model component's name.
|
||||
*
|
||||
* @param name The new name.
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
/**
|
||||
* Returns the property with the given name.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @return The property with the given name.
|
||||
*/
|
||||
Property getProperty(String name);
|
||||
|
||||
/**
|
||||
* Returns all properties.
|
||||
*
|
||||
* @return A map containing all properties.
|
||||
*/
|
||||
Map<String, Property> getProperties();
|
||||
|
||||
/**
|
||||
* Sets the property with the given name.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @param property The property.
|
||||
*/
|
||||
void setProperty(String name, Property property);
|
||||
|
||||
/**
|
||||
* Returns this component's name property.
|
||||
*
|
||||
* @return This component's name property.
|
||||
*/
|
||||
default StringProperty getPropertyName() {
|
||||
return (StringProperty) getProperty(NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given {@link AttributesChangeListener}.
|
||||
* The {@link AttributesChangeListener} is notified when properties of the model component
|
||||
* have changed.
|
||||
*
|
||||
* @param l The listener.
|
||||
*/
|
||||
void addAttributesChangeListener(AttributesChangeListener l);
|
||||
|
||||
/**
|
||||
* Removes the given {@link AttributesChangeListener}.
|
||||
*
|
||||
* @param l The listener.
|
||||
*/
|
||||
void removeAttributesChangeListener(AttributesChangeListener l);
|
||||
|
||||
/**
|
||||
* Returns whether the given {@link AttributesChangeListener} is already registered with the model
|
||||
* component.
|
||||
*
|
||||
* @param l The listener.
|
||||
* @return {@code true}, if the given {@link AttributesChangeListener} is already registered with
|
||||
* the model component, otherwise {@code false}.
|
||||
*/
|
||||
boolean containsAttributesChangeListener(AttributesChangeListener l);
|
||||
|
||||
/**
|
||||
* Notifies all registered {@link AttributesChangeListener}s that properties of the model
|
||||
* component have changed.
|
||||
*
|
||||
* @param l The initiator of the change.
|
||||
*/
|
||||
void propertiesChanged(AttributesChangeListener l);
|
||||
|
||||
/**
|
||||
* Clones this ModelComponent.
|
||||
*
|
||||
* @return A clone of this ModelComponent.
|
||||
* @throws java.lang.CloneNotSupportedException If the model component doesn't implement the
|
||||
* {@link Cloneable} interface.
|
||||
*/
|
||||
ModelComponent clone()
|
||||
throws CloneNotSupportedException;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.opentcs.data.peripherals.PeripheralOperation;
|
||||
|
||||
/**
|
||||
* A Bean to hold the Peripheral operation.
|
||||
*/
|
||||
public class PeripheralOperationModel {
|
||||
|
||||
/**
|
||||
* The operation to be performed by the peripheral device.
|
||||
*/
|
||||
private final String operation;
|
||||
/**
|
||||
* The name of the location the peripheral device is associated with.
|
||||
*/
|
||||
@Nonnull
|
||||
private final String locationName;
|
||||
/**
|
||||
* The moment at which this operation is to be performed.
|
||||
*/
|
||||
@Nonnull
|
||||
private final PeripheralOperation.ExecutionTrigger executionTrigger;
|
||||
/**
|
||||
* Whether the completion of this operation is required to allow a vehicle to continue driving.
|
||||
*/
|
||||
private final boolean completionRequired;
|
||||
|
||||
public PeripheralOperationModel(
|
||||
String locationName,
|
||||
String operation,
|
||||
PeripheralOperation.ExecutionTrigger executionTrigger,
|
||||
boolean completionRequired
|
||||
) {
|
||||
this.operation = requireNonNull(operation, "operation");
|
||||
this.locationName = requireNonNull(locationName, "locationName");
|
||||
this.executionTrigger = requireNonNull(executionTrigger, "executionTrigger");
|
||||
this.completionRequired = requireNonNull(completionRequired, "completionRequired");
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public String getLocationName() {
|
||||
return locationName;
|
||||
}
|
||||
|
||||
public PeripheralOperation.ExecutionTrigger getExecutionTrigger() {
|
||||
return executionTrigger;
|
||||
}
|
||||
|
||||
public boolean isCompletionRequired() {
|
||||
return completionRequired;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
/**
|
||||
* Defines constants for {@link ModelComponent}s that have model coordinates.
|
||||
*/
|
||||
public interface PositionableModelComponent
|
||||
extends
|
||||
ModelComponent {
|
||||
|
||||
/**
|
||||
* Key for the X (model) cordinate.
|
||||
*/
|
||||
String MODEL_X_POSITION = "modelXPosition";
|
||||
/**
|
||||
* Key for the Y (model) cordinate.
|
||||
*/
|
||||
String MODEL_Y_POSITION = "modelYPosition";
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.AbstractProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.MultipleDifferentValues;
|
||||
import org.opentcs.guing.base.components.properties.type.Property;
|
||||
|
||||
/**
|
||||
* Allows to change properties with the same name of multiple model components at the same time.
|
||||
*/
|
||||
public class PropertiesCollection
|
||||
extends
|
||||
CompositeModelComponent {
|
||||
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param models The model components.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public PropertiesCollection(Collection<ModelComponent> models) {
|
||||
Objects.requireNonNull(models, "models is null");
|
||||
|
||||
for (ModelComponent curModel : models) {
|
||||
add(curModel);
|
||||
}
|
||||
|
||||
extractSameProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the properties that can be collectively edited.
|
||||
*/
|
||||
private void extractSameProperties() {
|
||||
if (getChildComponents().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ModelComponent firstModel = getChildComponents().get(0);
|
||||
Map<String, Property> properties = firstModel.getProperties();
|
||||
|
||||
for (Map.Entry<String, Property> curEntry : properties.entrySet()) {
|
||||
String name = curEntry.getKey();
|
||||
Property property = curEntry.getValue();
|
||||
boolean ok = true;
|
||||
boolean differentValues = false;
|
||||
|
||||
if (!property.isCollectiveEditable()) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
for (int i = 1; i < getChildComponents().size(); i++) {
|
||||
ModelComponent followingModel = getChildComponents().get(i);
|
||||
if (!firstModel.getClass().equals(followingModel.getClass())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Property pendant = followingModel.getProperty(name);
|
||||
|
||||
if (pendant == null) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
else if ((!pendant.isCollectiveEditable())) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(property.getComparableValue() == null && pendant.getComparableValue() == null)
|
||||
&& (property.getComparableValue() != null && pendant.getComparableValue() == null
|
||||
|| property.getComparableValue() == null && pendant.getComparableValue() != null
|
||||
|| !property.getComparableValue().equals(pendant.getComparableValue()))) {
|
||||
differentValues = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
AbstractProperty clone = (AbstractProperty) property.clone();
|
||||
|
||||
if (differentValues) {
|
||||
clone.setValue(new MultipleDifferentValues());
|
||||
|
||||
clone.unmarkChanged();
|
||||
|
||||
clone.setDescription(property.getDescription());
|
||||
clone.setHelptext(property.getHelptext());
|
||||
clone.setModellingEditable(property.isModellingEditable());
|
||||
clone.setOperatingEditable(property.isOperatingEditable());
|
||||
setProperty(name, clone);
|
||||
}
|
||||
else {
|
||||
// TODO: clone() Methode ?
|
||||
clone.setDescription(property.getDescription());
|
||||
clone.setHelptext(property.getHelptext());
|
||||
clone.setModellingEditable(property.isModellingEditable());
|
||||
clone.setOperatingEditable(property.isOperatingEditable());
|
||||
setProperty(name, clone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the registered listeners about the changed properties.
|
||||
*
|
||||
* @param listener The listener that initiated the property change.
|
||||
*/
|
||||
@Override // AbstractModelComponent
|
||||
public void propertiesChanged(AttributesChangeListener listener) {
|
||||
for (ModelComponent model : getChildComponents()) {
|
||||
copyPropertiesToModel(model);
|
||||
model.propertiesChanged(listener);
|
||||
}
|
||||
|
||||
extractSameProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the properties to the model component.
|
||||
*
|
||||
* @param model The model component to copy properties to.
|
||||
*/
|
||||
protected void copyPropertiesToModel(ModelComponent model) {
|
||||
for (String name : getProperties().keySet()) {
|
||||
Property property = getProperty(name);
|
||||
if (property.hasChanged()) {
|
||||
Property modelProperty = model.getProperty(name);
|
||||
modelProperty.copyFrom(property);
|
||||
modelProperty.markChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("propertiesCollection.description");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model;
|
||||
|
||||
/**
|
||||
* The simplest form of a component in the system model that contains child elements.
|
||||
* SimpleFolder is used for plain folders.
|
||||
*/
|
||||
public class SimpleFolder
|
||||
extends
|
||||
CompositeModelComponent {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param name The name of the folder.
|
||||
*/
|
||||
public SimpleFolder(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeEvent;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.event.NullAttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.event.ConnectionChangeEvent;
|
||||
import org.opentcs.guing.base.event.ConnectionChangeListener;
|
||||
import org.opentcs.guing.base.model.AbstractConnectableModelComponent;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
import org.opentcs.guing.base.model.DrawnModelComponent;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
|
||||
/**
|
||||
* Abstract implementation for connections:
|
||||
* <ol>
|
||||
* <li>between two points {@link PathModel}</li>
|
||||
* <li>between a point and a location {@link LinkModel}</li>
|
||||
* </ol>
|
||||
*/
|
||||
public abstract class AbstractConnection
|
||||
extends
|
||||
AbstractModelComponent
|
||||
implements
|
||||
DrawnModelComponent,
|
||||
AttributesChangeListener {
|
||||
|
||||
/**
|
||||
* Key for the start component.
|
||||
*/
|
||||
public static final String START_COMPONENT = "startComponent";
|
||||
/**
|
||||
* Key for the end component.
|
||||
*/
|
||||
public static final String END_COMPONENT = "endComponent";
|
||||
/**
|
||||
* The start component (Location or Point).
|
||||
*/
|
||||
private transient ModelComponent fStartComponent;
|
||||
/**
|
||||
* The end component (Location or Point).
|
||||
*/
|
||||
private transient ModelComponent fEndComponent;
|
||||
/**
|
||||
* Listeners that are interested in changes of the connected objects.
|
||||
*/
|
||||
private transient List<ConnectionChangeListener> fConnectionChangeListeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public AbstractConnection() {
|
||||
// Do nada.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this connection's start component.
|
||||
*
|
||||
* @return The start component.
|
||||
*/
|
||||
public ModelComponent getStartComponent() {
|
||||
return fStartComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this connection's end component.
|
||||
*
|
||||
* @return The end component.
|
||||
*/
|
||||
public ModelComponent getEndComponent() {
|
||||
return fEndComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this connection's start and end component.
|
||||
*
|
||||
* @param startComponent The start component.
|
||||
* @param endComponent The end component.
|
||||
*/
|
||||
public void setConnectedComponents(
|
||||
ModelComponent startComponent,
|
||||
ModelComponent endComponent
|
||||
) {
|
||||
updateListenerRegistrations(startComponent, endComponent);
|
||||
updateComponents(startComponent, endComponent);
|
||||
|
||||
// TODO: Points and locations are still missing an implementation of equals().
|
||||
if (!Objects.equals(fStartComponent, startComponent)
|
||||
|| !Objects.equals(fEndComponent, endComponent)) {
|
||||
fStartComponent = startComponent;
|
||||
fEndComponent = endComponent;
|
||||
connectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this connection that it is being removed.
|
||||
*/
|
||||
public void removingConnection() {
|
||||
if (fStartComponent != null) {
|
||||
fStartComponent.removeAttributesChangeListener(this);
|
||||
|
||||
if (fStartComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) fStartComponent).removeConnection(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (fEndComponent != null) {
|
||||
fEndComponent.removeAttributesChangeListener(this);
|
||||
|
||||
if (fEndComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) fEndComponent).removeConnection(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener.
|
||||
*
|
||||
* @param listener The new listener.
|
||||
*/
|
||||
public void addConnectionChangeListener(ConnectionChangeListener listener) {
|
||||
if (fConnectionChangeListeners == null) {
|
||||
fConnectionChangeListeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (!fConnectionChangeListeners.contains(listener)) {
|
||||
fConnectionChangeListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener.
|
||||
*
|
||||
* @param listener The listener to remove.
|
||||
*/
|
||||
public void removeConnectionChangeListener(ConnectionChangeListener listener) {
|
||||
fConnectionChangeListeners.remove(listener);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyStartComponent() {
|
||||
return (StringProperty) getProperty(START_COMPONENT);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyEndComponent() {
|
||||
return (StringProperty) getProperty(END_COMPONENT);
|
||||
}
|
||||
|
||||
@Override // AttributesChangeListener
|
||||
public void propertiesChanged(AttributesChangeEvent e) {
|
||||
if (getStartComponent().getPropertyName().hasChanged()
|
||||
|| getEndComponent().getPropertyName().hasChanged()) {
|
||||
if (nameFulfillsConvention()) {
|
||||
updateName();
|
||||
}
|
||||
else {
|
||||
// Don't forget to update these properties.
|
||||
getPropertyStartComponent().setText(fStartComponent.getName());
|
||||
getPropertyEndComponent().setText(fEndComponent.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConnection clone()
|
||||
throws CloneNotSupportedException {
|
||||
AbstractConnection clone = (AbstractConnection) super.clone();
|
||||
clone.fConnectionChangeListeners = new ArrayList<>();
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the current start and end components and establishes this connection
|
||||
* between the given components.
|
||||
*
|
||||
* @param startComponent The new start component.
|
||||
* @param endComponent The new end component.
|
||||
*/
|
||||
private void updateComponents(
|
||||
ModelComponent startComponent,
|
||||
ModelComponent endComponent
|
||||
) {
|
||||
if (fStartComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) fStartComponent).removeConnection(this);
|
||||
}
|
||||
|
||||
if (fEndComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) fEndComponent).removeConnection(this);
|
||||
}
|
||||
|
||||
if (startComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) startComponent).addConnection(this);
|
||||
}
|
||||
|
||||
if (endComponent instanceof AbstractConnectableModelComponent) {
|
||||
((AbstractConnectableModelComponent) endComponent).addConnection(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all listener that the start and/or end component have changed.
|
||||
*/
|
||||
private void connectionChanged() {
|
||||
if (fConnectionChangeListeners == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ConnectionChangeListener listener : fConnectionChangeListeners) {
|
||||
listener.connectionChanged(new ConnectionChangeEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregistrates and reregistrates itself as a listener on the
|
||||
* connected components. This is important as the name of the connection
|
||||
* is dependant on the connected components.
|
||||
*
|
||||
* @param startComponent The new start component to register with.
|
||||
* @param endComponent The new end component to register with.
|
||||
*/
|
||||
private void updateListenerRegistrations(
|
||||
ModelComponent startComponent,
|
||||
ModelComponent endComponent
|
||||
) {
|
||||
if (fStartComponent != null) {
|
||||
fStartComponent.removeAttributesChangeListener(this);
|
||||
}
|
||||
|
||||
if (fEndComponent != null) {
|
||||
fEndComponent.removeAttributesChangeListener(this);
|
||||
}
|
||||
|
||||
startComponent.addAttributesChangeListener(this);
|
||||
endComponent.addAttributesChangeListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the name of this connection.
|
||||
*/
|
||||
public void updateName() {
|
||||
StringProperty property = getPropertyName();
|
||||
|
||||
if (property != null) {
|
||||
String oldName = property.getText();
|
||||
String newName = getStartComponent().getName() + " --- " + getEndComponent().getName();
|
||||
property.setText(newName);
|
||||
|
||||
if (!newName.equals(oldName)) {
|
||||
property.markChanged();
|
||||
}
|
||||
|
||||
propertiesChanged(new NullAttributesChangeListener());
|
||||
}
|
||||
getPropertyStartComponent().setText(fStartComponent.getName());
|
||||
getPropertyEndComponent().setText(fEndComponent.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the name of this connection follows a defined naming scheme.
|
||||
* Definition: {@literal <startComponent> --- <endComponent>}
|
||||
*
|
||||
* @return {@code true}, if the name fulfills the convention, otherwise {@code false}.
|
||||
*/
|
||||
private boolean nameFulfillsConvention() {
|
||||
StringProperty property = getPropertyName();
|
||||
if (property != null) {
|
||||
String name = property.getText();
|
||||
String nameByConvention = getPropertyStartComponent().getText() + " --- "
|
||||
+ getPropertyEndComponent().getText();
|
||||
|
||||
if (name.equals(nameByConvention)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.data.model.visualization.ElementPropKeys;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.BlockTypeProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.ColorProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SelectionProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringSetProperty;
|
||||
import org.opentcs.guing.base.event.BlockChangeEvent;
|
||||
import org.opentcs.guing.base.event.BlockChangeListener;
|
||||
import org.opentcs.guing.base.model.ModelComponent;
|
||||
import org.opentcs.guing.base.model.SimpleFolder;
|
||||
|
||||
/**
|
||||
* A block area. Contains figure components that are part of this block
|
||||
* area.
|
||||
*/
|
||||
public class BlockModel
|
||||
extends
|
||||
SimpleFolder {
|
||||
|
||||
/**
|
||||
* The key/name of the 'type' property.
|
||||
*/
|
||||
public static final String TYPE = "Type";
|
||||
/**
|
||||
* The key/name of the 'elements' property.
|
||||
*/
|
||||
public static final String ELEMENTS = "blockElements";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
/**
|
||||
* A list of change listeners for this object.
|
||||
*/
|
||||
private List<BlockChangeListener> fListeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public BlockModel() {
|
||||
super("");
|
||||
createProperties();
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getTreeViewName() {
|
||||
String treeViewName = getDescription() + " " + getName();
|
||||
|
||||
return treeViewName;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("blockModel.description");
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public void propertiesChanged(AttributesChangeListener listener) {
|
||||
if (getPropertyColor().hasChanged()) {
|
||||
colorChanged();
|
||||
}
|
||||
|
||||
super.propertiesChanged(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of this block area.
|
||||
*
|
||||
* @return The color.
|
||||
*/
|
||||
public Color getColor() {
|
||||
return getPropertyColor().getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an element to this block area.
|
||||
*
|
||||
* @param model The component to add.
|
||||
*/
|
||||
public void addCourseElement(ModelComponent model) {
|
||||
if (!contains(model)) {
|
||||
getChildComponents().add(model);
|
||||
String addedModelName = model.getName();
|
||||
if (!getPropertyElements().getItems().contains(addedModelName)) {
|
||||
getPropertyElements().addItem(addedModelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an element from this block area.
|
||||
*
|
||||
* @param model The component to remove.
|
||||
*/
|
||||
public void removeCourseElement(ModelComponent model) {
|
||||
if (contains(model)) {
|
||||
remove(model);
|
||||
getPropertyElements().getItems().remove(model.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all elements in this block area.
|
||||
*/
|
||||
public void removeAllCourseElements() {
|
||||
for (Object o : new ArrayList<>(getChildComponents())) {
|
||||
remove((ModelComponent) o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listeners that gets informed when this block members change.
|
||||
*
|
||||
* @param listener The new listener.
|
||||
*/
|
||||
public void addBlockChangeListener(BlockChangeListener listener) {
|
||||
if (fListeners == null) {
|
||||
fListeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (!fListeners.contains(listener)) {
|
||||
fListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener.
|
||||
*
|
||||
* @param listener The listener to remove.
|
||||
*/
|
||||
public void removeBlockChangeListener(BlockChangeListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all listeners that the block elements have changed.
|
||||
*/
|
||||
public void courseElementsChanged() {
|
||||
for (BlockChangeListener listener : fListeners) {
|
||||
listener.courseElementsChanged(new BlockChangeEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all listeners that the color of this block has changed.
|
||||
*/
|
||||
public void colorChanged() {
|
||||
for (BlockChangeListener listener : fListeners) {
|
||||
listener.colorChanged(new BlockChangeEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all listeners that this block was removed.
|
||||
*/
|
||||
public void blockRemoved() {
|
||||
for (BlockChangeListener listener : new ArrayList<>(fListeners)) {
|
||||
listener.blockRemoved(new BlockChangeEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
public ColorProperty getPropertyColor() {
|
||||
return (ColorProperty) getProperty(ElementPropKeys.BLOCK_COLOR);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Type> getPropertyType() {
|
||||
return (SelectionProperty<Type>) getProperty(TYPE);
|
||||
}
|
||||
|
||||
public StringSetProperty getPropertyElements() {
|
||||
return (StringSetProperty) getProperty(ELEMENTS);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("blockModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("blockModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
ColorProperty pColor = new ColorProperty(this, Color.red);
|
||||
pColor.setDescription(bundle.getString("blockModel.property_color.description"));
|
||||
pColor.setHelptext(bundle.getString("blockModel.property_color.helptext"));
|
||||
setProperty(ElementPropKeys.BLOCK_COLOR, pColor);
|
||||
|
||||
BlockTypeProperty pType = new BlockTypeProperty(
|
||||
this,
|
||||
Arrays.asList(Type.values()),
|
||||
Type.values()[0]
|
||||
);
|
||||
pType.setDescription(bundle.getString("blockModel.property_type.description"));
|
||||
pType.setHelptext(bundle.getString("blockModel.property_type.helptext"));
|
||||
pType.setCollectiveEditable(true);
|
||||
setProperty(TYPE, pType);
|
||||
|
||||
StringSetProperty pElements = new StringSetProperty(this);
|
||||
pElements.setDescription(bundle.getString("blockModel.property_elements.description"));
|
||||
pElements.setHelptext(bundle.getString("blockModel.property_elements.helptext"));
|
||||
pElements.setModellingEditable(false);
|
||||
pElements.setOperatingEditable(false);
|
||||
setProperty(ELEMENTS, pElements);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("blockModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(bundle.getString("blockModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported point types.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* Single vehicle only allowed.
|
||||
*/
|
||||
SINGLE_VEHICLE_ONLY(
|
||||
ResourceBundle.getBundle(BUNDLE_PATH)
|
||||
.getString("blockModel.type.singleVehicleOnly.description")),
|
||||
/**
|
||||
* Same direction only allowed.
|
||||
*/
|
||||
SAME_DIRECTION_ONLY(
|
||||
ResourceBundle.getBundle(BUNDLE_PATH)
|
||||
.getString("blockModel.type.sameDirectionOnly.description"));
|
||||
|
||||
private final String description;
|
||||
|
||||
Type(String description) {
|
||||
this.description = requireNonNull(description, "description");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerGroupsProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrappersProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.model.CompositeModelComponent;
|
||||
|
||||
/**
|
||||
* Basic implementation of a layout.
|
||||
*/
|
||||
public class LayoutModel
|
||||
extends
|
||||
CompositeModelComponent {
|
||||
|
||||
/**
|
||||
* The key/name of the 'scale X' property.
|
||||
*/
|
||||
public static final String SCALE_X = "scaleX";
|
||||
/**
|
||||
* The key/name of the 'scale Y' property.
|
||||
*/
|
||||
public static final String SCALE_Y = "scaleY";
|
||||
/**
|
||||
* The key/name of the 'layer wrappers' property.
|
||||
*/
|
||||
public static final String LAYERS_WRAPPERS = "layerWrappers";
|
||||
/**
|
||||
* The key/name of the 'layer groups' property.
|
||||
*/
|
||||
public static final String LAYER_GROUPS = "layerGroups";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public LayoutModel() {
|
||||
super(ResourceBundle.getBundle(BUNDLE_PATH).getString("layoutModel.treeViewName"));
|
||||
createProperties();
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("layoutModel.description");
|
||||
}
|
||||
|
||||
public LengthProperty getPropertyScaleX() {
|
||||
return (LengthProperty) getProperty(SCALE_X);
|
||||
}
|
||||
|
||||
public LengthProperty getPropertyScaleY() {
|
||||
return (LengthProperty) getProperty(SCALE_Y);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public LayerWrappersProperty getPropertyLayerWrappers() {
|
||||
return (LayerWrappersProperty) getProperty(LAYERS_WRAPPERS);
|
||||
}
|
||||
|
||||
public LayerGroupsProperty getPropertyLayerGroups() {
|
||||
return (LayerGroupsProperty) getProperty(LAYER_GROUPS);
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("layoutModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("layoutModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
LengthProperty pScaleX = new LengthProperty(this);
|
||||
pScaleX.setDescription(bundle.getString("layoutModel.property_scaleX.description"));
|
||||
pScaleX.setHelptext(bundle.getString("layoutModel.property_scaleX.helptext"));
|
||||
setProperty(SCALE_X, pScaleX);
|
||||
|
||||
LengthProperty pScaleY = new LengthProperty(this);
|
||||
pScaleY.setDescription(bundle.getString("layoutModel.property_scaleY.description"));
|
||||
pScaleY.setHelptext(bundle.getString("layoutModel.property_scaleY.helptext"));
|
||||
setProperty(SCALE_Y, pScaleY);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("layoutModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(bundle.getString("layoutModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
|
||||
LayerWrappersProperty pLayerWrappers = new LayerWrappersProperty(this, new HashMap<>());
|
||||
pLayerWrappers.setDescription(
|
||||
bundle.getString("layoutModel.property_layerWrappers.description")
|
||||
);
|
||||
pLayerWrappers.setHelptext(bundle.getString("layoutModel.property_layerWrappers.helptext"));
|
||||
pLayerWrappers.setModellingEditable(false);
|
||||
setProperty(LAYERS_WRAPPERS, pLayerWrappers);
|
||||
|
||||
LayerGroupsProperty pLayerGroups = new LayerGroupsProperty(this, new HashMap<>());
|
||||
pLayerGroups.setDescription(bundle.getString("layoutModel.property_layerGroups.description"));
|
||||
pLayerGroups.setHelptext(bundle.getString("layoutModel.property_layerGroups.helptext"));
|
||||
pLayerGroups.setModellingEditable(false);
|
||||
setProperty(LAYER_GROUPS, pLayerGroups);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.guing.base.components.layer.NullLayerWrapper;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrapperProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LinkActionsProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringSetProperty;
|
||||
|
||||
/**
|
||||
* Basic implementation of link between a point and a location.
|
||||
*/
|
||||
public class LinkModel
|
||||
extends
|
||||
AbstractConnection {
|
||||
|
||||
/**
|
||||
* The key for the possible actions on the location.
|
||||
*/
|
||||
public static final String ALLOWED_OPERATIONS = "AllowedOperations";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public LinkModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connected point.
|
||||
*
|
||||
* @return The model of the connected Point.
|
||||
*/
|
||||
public PointModel getPoint() {
|
||||
if (getStartComponent() instanceof PointModel) {
|
||||
return (PointModel) getStartComponent();
|
||||
}
|
||||
|
||||
if (getEndComponent() instanceof PointModel) {
|
||||
return (PointModel) getEndComponent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connected location.
|
||||
*
|
||||
* @return The model of the connected Location.
|
||||
*/
|
||||
public LocationModel getLocation() {
|
||||
if (getStartComponent() instanceof LocationModel) {
|
||||
return (LocationModel) getStartComponent();
|
||||
}
|
||||
|
||||
if (getEndComponent() instanceof LocationModel) {
|
||||
return (LocationModel) getEndComponent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("linkModel.description");
|
||||
}
|
||||
|
||||
public StringSetProperty getPropertyAllowedOperations() {
|
||||
return (StringSetProperty) getProperty(ALLOWED_OPERATIONS);
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("linkModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("linkModel.property_name.helptext"));
|
||||
// The name of a link cannot be changed because it is not stored in the kernel model
|
||||
pName.setModellingEditable(false);
|
||||
setProperty(NAME, pName);
|
||||
|
||||
StringSetProperty pOperations = new LinkActionsProperty(this);
|
||||
pOperations.setDescription(bundle.getString("linkModel.property_operations.description"));
|
||||
pOperations.setHelptext(bundle.getString("linkModel.property_operations.helptext"));
|
||||
setProperty(ALLOWED_OPERATIONS, pOperations);
|
||||
|
||||
StringProperty startComponent = new StringProperty(this);
|
||||
startComponent.setDescription(
|
||||
bundle.getString("linkModel.property_startComponent.description")
|
||||
);
|
||||
startComponent.setModellingEditable(false);
|
||||
startComponent.setOperatingEditable(false);
|
||||
setProperty(START_COMPONENT, startComponent);
|
||||
|
||||
StringProperty endComponent = new StringProperty(this);
|
||||
endComponent.setDescription(bundle.getString("linkModel.property_endComponent.description"));
|
||||
endComponent.setModellingEditable(false);
|
||||
endComponent.setOperatingEditable(false);
|
||||
setProperty(END_COMPONENT, endComponent);
|
||||
|
||||
LayerWrapperProperty pLayerWrapper = new LayerWrapperProperty(this, new NullLayerWrapper());
|
||||
pLayerWrapper.setDescription(bundle.getString("linkModel.property_layerWrapper.description"));
|
||||
pLayerWrapper.setHelptext(bundle.getString("linkModel.property_layerWrapper.helptext"));
|
||||
pLayerWrapper.setModellingEditable(false);
|
||||
setProperty(LAYER_WRAPPER, pLayerWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import org.opentcs.data.ObjectPropConstants;
|
||||
import org.opentcs.data.model.Location;
|
||||
import org.opentcs.data.model.visualization.ElementPropKeys;
|
||||
import org.opentcs.data.model.visualization.LocationRepresentation;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.components.layer.NullLayerWrapper;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeEvent;
|
||||
import org.opentcs.guing.base.components.properties.event.AttributesChangeListener;
|
||||
import org.opentcs.guing.base.components.properties.type.BooleanProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.CoordinateProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrapperProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LocationTypeProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SymbolProperty;
|
||||
import org.opentcs.guing.base.model.AbstractConnectableModelComponent;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
import org.opentcs.guing.base.model.FigureDecorationDetails;
|
||||
import org.opentcs.guing.base.model.PositionableModelComponent;
|
||||
|
||||
/**
|
||||
* Basic implementation for every kind of location.
|
||||
*/
|
||||
public class LocationModel
|
||||
extends
|
||||
AbstractConnectableModelComponent
|
||||
implements
|
||||
AttributesChangeListener,
|
||||
PositionableModelComponent,
|
||||
FigureDecorationDetails {
|
||||
|
||||
/**
|
||||
* The property key for the location's type.
|
||||
*/
|
||||
public static final String TYPE = "Type";
|
||||
/**
|
||||
* Key for the locked state.
|
||||
*/
|
||||
public static final String LOCKED = "locked";
|
||||
/**
|
||||
* Key for the reservation token.
|
||||
*/
|
||||
public static final String PERIPHERAL_RESERVATION_TOKEN = "peripheralReservationToken";
|
||||
/**
|
||||
* Key for the peripheral state.
|
||||
*/
|
||||
public static final String PERIPHERAL_STATE = "peripheralState";
|
||||
/**
|
||||
* Key for the peripheral processing state.
|
||||
*/
|
||||
public static final String PERIPHERAL_PROC_STATE = "peripheralProcState";
|
||||
/**
|
||||
* Key for the peripheral job.
|
||||
*/
|
||||
public static final String PERIPHERAL_JOB = "peripheralJob";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
/**
|
||||
* The map of vehicle models to allocations states for which this model component's figure is to
|
||||
* be decorated to indicate that it is part of the route of the respective vehicles.
|
||||
*/
|
||||
private Map<VehicleModel, AllocationState> allocationStates
|
||||
= new TreeMap<>(Comparator.comparing(VehicleModel::getName));
|
||||
/**
|
||||
* The set of block models for which this model component's figure is to be decorated to indicate
|
||||
* that it is part of the respective block.
|
||||
*/
|
||||
private Set<BlockModel> blocks
|
||||
= new TreeSet<>(Comparator.comparing(BlockModel::getName));
|
||||
/**
|
||||
* The model of the type.
|
||||
*/
|
||||
private transient LocationTypeModel fLocationType;
|
||||
/**
|
||||
* The location for this model.
|
||||
*/
|
||||
private Location location;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public LocationModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location type.
|
||||
*
|
||||
* @param type The model of the type.
|
||||
*/
|
||||
public void setLocationType(LocationTypeModel type) {
|
||||
if (fLocationType != null) {
|
||||
fLocationType.removeAttributesChangeListener(this);
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
fLocationType = type;
|
||||
fLocationType.addAttributesChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location type.
|
||||
*
|
||||
* @return The type.
|
||||
*/
|
||||
public LocationTypeModel getLocationType() {
|
||||
return fLocationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the name of this location.
|
||||
*/
|
||||
protected void updateName() {
|
||||
StringProperty property = getPropertyName();
|
||||
String oldName = property.getText();
|
||||
String newName = getName();
|
||||
property.setText(newName);
|
||||
|
||||
if (!newName.equals(oldName)) {
|
||||
property.markChanged();
|
||||
}
|
||||
|
||||
propertiesChanged(this);
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("locationModel.description");
|
||||
}
|
||||
|
||||
@Override // AttributesChangeListener
|
||||
public void propertiesChanged(AttributesChangeEvent e) {
|
||||
if (fLocationType.getPropertyName().hasChanged()) {
|
||||
updateName();
|
||||
}
|
||||
|
||||
if (fLocationType.getPropertyDefaultRepresentation().hasChanged()) {
|
||||
propertiesChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTypeProperty(List<LocationTypeModel> types) {
|
||||
requireNonNull(types, "types");
|
||||
|
||||
List<String> possibleValues = new ArrayList<>();
|
||||
String value = null;
|
||||
|
||||
for (LocationTypeModel type : types) {
|
||||
possibleValues.add(type.getName());
|
||||
|
||||
if (type == fLocationType) {
|
||||
value = type.getName();
|
||||
}
|
||||
}
|
||||
|
||||
getPropertyType().setPossibleValues(possibleValues);
|
||||
getPropertyType().setValue(value);
|
||||
getPropertyType().markChanged();
|
||||
}
|
||||
|
||||
public CoordinateProperty getPropertyModelPositionX() {
|
||||
return (CoordinateProperty) getProperty(MODEL_X_POSITION);
|
||||
}
|
||||
|
||||
public CoordinateProperty getPropertyModelPositionY() {
|
||||
return (CoordinateProperty) getProperty(MODEL_Y_POSITION);
|
||||
}
|
||||
|
||||
public LocationTypeProperty getPropertyType() {
|
||||
return (LocationTypeProperty) getProperty(TYPE);
|
||||
}
|
||||
|
||||
public BooleanProperty getPropertyLocked() {
|
||||
return (BooleanProperty) getProperty(LOCKED);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public SymbolProperty getPropertyDefaultRepresentation() {
|
||||
return (SymbolProperty) getProperty(ObjectPropConstants.LOC_DEFAULT_REPRESENTATION);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLayoutPositionX() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.LOC_POS_X);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLayoutPositionY() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.LOC_POS_Y);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLabelOffsetX() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.LOC_LABEL_OFFSET_X);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLabelOffsetY() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.LOC_LABEL_OFFSET_Y);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLabelOrientationAngle() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.LOC_LABEL_ORIENTATION_ANGLE);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPeripheralReservationToken() {
|
||||
return (StringProperty) getProperty(PERIPHERAL_RESERVATION_TOKEN);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPeripheralState() {
|
||||
return (StringProperty) getProperty(PERIPHERAL_STATE);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPeripheralProcState() {
|
||||
return (StringProperty) getProperty(PERIPHERAL_PROC_STATE);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPeripheralJob() {
|
||||
return (StringProperty) getProperty(PERIPHERAL_JOB);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<VehicleModel, AllocationState> getAllocationStates() {
|
||||
return allocationStates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllocationState(VehicleModel model, AllocationState allocationState) {
|
||||
requireNonNull(model, "model");
|
||||
requireNonNull(allocationStates, "allocationStates");
|
||||
|
||||
allocationStates.put(model, allocationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllocationState(
|
||||
@Nonnull
|
||||
VehicleModel model
|
||||
) {
|
||||
requireNonNull(model, "model");
|
||||
|
||||
allocationStates.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockModel(BlockModel model) {
|
||||
blocks.add(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBlockModel(BlockModel model) {
|
||||
blocks.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BlockModel> getBlockModels() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "checkstyle:LineLength"})
|
||||
public AbstractModelComponent clone()
|
||||
throws CloneNotSupportedException {
|
||||
LocationModel clone = (LocationModel) super.clone();
|
||||
clone.setAllocationStates(
|
||||
(Map<VehicleModel, AllocationState>) ((TreeMap<VehicleModel, AllocationState>) allocationStates)
|
||||
.clone()
|
||||
);
|
||||
clone.setBlockModels((Set<BlockModel>) ((TreeSet<BlockModel>) blocks).clone());
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("locationModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("locationModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
CoordinateProperty pPosX = new CoordinateProperty(this);
|
||||
pPosX.setDescription(bundle.getString("locationModel.property_modelPositionX.description"));
|
||||
pPosX.setHelptext(bundle.getString("locationModel.property_modelPositionX.helptext"));
|
||||
setProperty(MODEL_X_POSITION, pPosX);
|
||||
|
||||
CoordinateProperty pPosY = new CoordinateProperty(this);
|
||||
pPosY.setDescription(bundle.getString("locationModel.property_modelPositionY.description"));
|
||||
pPosY.setHelptext(bundle.getString("locationModel.property_modelPositionY.helptext"));
|
||||
setProperty(MODEL_Y_POSITION, pPosY);
|
||||
|
||||
LocationTypeProperty pType = new LocationTypeProperty(this);
|
||||
pType.setDescription(bundle.getString("locationModel.property_type.description"));
|
||||
pType.setHelptext(bundle.getString("locationModel.property_type.helptext"));
|
||||
setProperty(TYPE, pType);
|
||||
|
||||
BooleanProperty pLocked = new BooleanProperty(this);
|
||||
pLocked.setDescription(bundle.getString("locationModel.property_locked.description"));
|
||||
pLocked.setHelptext(bundle.getString("locationModel.property_locked.helptext"));
|
||||
pLocked.setCollectiveEditable(true);
|
||||
pLocked.setOperatingEditable(true);
|
||||
setProperty(LOCKED, pLocked);
|
||||
|
||||
SymbolProperty pSymbol = new SymbolProperty(this);
|
||||
pSymbol.setLocationRepresentation(LocationRepresentation.DEFAULT);
|
||||
pSymbol.setDescription(bundle.getString("locationModel.property_symbol.description"));
|
||||
pSymbol.setHelptext(bundle.getString("locationModel.property_symbol.helptext"));
|
||||
pSymbol.setCollectiveEditable(true);
|
||||
setProperty(ObjectPropConstants.LOC_DEFAULT_REPRESENTATION, pSymbol);
|
||||
|
||||
StringProperty pLocPosX = new StringProperty(this);
|
||||
pLocPosX.setDescription(bundle.getString("locationModel.property_positionX.description"));
|
||||
pLocPosX.setHelptext(bundle.getString("locationModel.property_positionX.helptext"));
|
||||
pLocPosX.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.LOC_POS_X, pLocPosX);
|
||||
|
||||
StringProperty pLocPosY = new StringProperty(this);
|
||||
pLocPosY.setDescription(bundle.getString("locationModel.property_positionY.description"));
|
||||
pLocPosY.setHelptext(bundle.getString("locationModel.property_positionY.helptext"));
|
||||
pLocPosY.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.LOC_POS_Y, pLocPosY);
|
||||
|
||||
StringProperty pLocLabelOffsetX = new StringProperty(this);
|
||||
pLocLabelOffsetX.setDescription(
|
||||
bundle.getString("locationModel.property_labelOffsetX.description")
|
||||
);
|
||||
pLocLabelOffsetX.setHelptext(bundle.getString("locationModel.property_labelOffsetX.helptext"));
|
||||
pLocLabelOffsetX.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.LOC_LABEL_OFFSET_X, pLocLabelOffsetX);
|
||||
|
||||
StringProperty pLocLabelOffsetY = new StringProperty(this);
|
||||
pLocLabelOffsetY.setDescription(
|
||||
bundle.getString("locationModel.property_labelOffsetY.description")
|
||||
);
|
||||
pLocLabelOffsetY.setHelptext(bundle.getString("locationModel.property_labelOffsetY.helptext"));
|
||||
pLocLabelOffsetY.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.LOC_LABEL_OFFSET_Y, pLocLabelOffsetY);
|
||||
|
||||
StringProperty pLocLabelOrientationAngle = new StringProperty(this);
|
||||
pLocLabelOrientationAngle.setDescription(
|
||||
bundle.getString("locationModel.property_labelOrientationAngle.description")
|
||||
);
|
||||
pLocLabelOrientationAngle.setHelptext(
|
||||
bundle.getString("locationModel.property_labelOrientationAngle.helptext")
|
||||
);
|
||||
pLocLabelOrientationAngle.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.LOC_LABEL_ORIENTATION_ANGLE, pLocLabelOrientationAngle);
|
||||
|
||||
LayerWrapperProperty pLayerWrapper = new LayerWrapperProperty(this, new NullLayerWrapper());
|
||||
pLayerWrapper.setDescription(
|
||||
bundle.getString("locationModel.property_layerWrapper.description")
|
||||
);
|
||||
pLayerWrapper.setHelptext(bundle.getString("locationModel.property_layerWrapper.helptext"));
|
||||
pLayerWrapper.setModellingEditable(false);
|
||||
setProperty(LAYER_WRAPPER, pLayerWrapper);
|
||||
|
||||
StringProperty peripheralReservationTokenProperty = new StringProperty(this);
|
||||
peripheralReservationTokenProperty.setDescription(
|
||||
bundle.getString("locationModel.property_peripheralReservationToken.description")
|
||||
);
|
||||
peripheralReservationTokenProperty.setHelptext(
|
||||
bundle.getString("locationModel.property_peripheralReservationToken.helptext")
|
||||
);
|
||||
peripheralReservationTokenProperty.setOperatingEditable(false);
|
||||
peripheralReservationTokenProperty.setModellingEditable(false);
|
||||
setProperty(PERIPHERAL_RESERVATION_TOKEN, peripheralReservationTokenProperty);
|
||||
|
||||
StringProperty peripheralStateProperty = new StringProperty(this);
|
||||
peripheralStateProperty.setDescription(
|
||||
bundle.getString("locationModel.property_peripheralState.description")
|
||||
);
|
||||
peripheralStateProperty.setHelptext(
|
||||
bundle.getString("locationModel.property_peripheralState.helptext")
|
||||
);
|
||||
peripheralStateProperty.setOperatingEditable(false);
|
||||
peripheralStateProperty.setModellingEditable(false);
|
||||
setProperty(PERIPHERAL_STATE, peripheralStateProperty);
|
||||
|
||||
StringProperty peripheralProcState = new StringProperty(this);
|
||||
peripheralProcState.setDescription(
|
||||
bundle.getString("locationModel.property_peripheralProcState.description")
|
||||
);
|
||||
peripheralProcState.setHelptext(
|
||||
bundle.getString("locationModel.property_peripheralProcState.helptext")
|
||||
);
|
||||
peripheralProcState.setOperatingEditable(false);
|
||||
peripheralProcState.setModellingEditable(false);
|
||||
setProperty(PERIPHERAL_PROC_STATE, peripheralProcState);
|
||||
|
||||
StringProperty peripheralJob = new StringProperty(this);
|
||||
peripheralJob.setDescription(
|
||||
bundle.getString("locationModel.property_peripheralJob.description")
|
||||
);
|
||||
peripheralJob.setHelptext(bundle.getString("locationModel.property_peripheralJob.helptext"));
|
||||
peripheralJob.setOperatingEditable(false);
|
||||
peripheralJob.setModellingEditable(false);
|
||||
setProperty(PERIPHERAL_JOB, peripheralJob);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("locationModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(bundle.getString("locationModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
}
|
||||
|
||||
private void setAllocationStates(Map<VehicleModel, AllocationState> allocationStates) {
|
||||
this.allocationStates = allocationStates;
|
||||
}
|
||||
|
||||
private void setBlockModels(Set<BlockModel> blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
public void setLocation(
|
||||
@Nonnull
|
||||
Location location
|
||||
) {
|
||||
this.location = requireNonNull(location, "location");
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.data.ObjectPropConstants;
|
||||
import org.opentcs.data.model.LocationType;
|
||||
import org.opentcs.data.model.visualization.LocationRepresentation;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LocationTypeActionsProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SymbolProperty;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* Basic implementation of a location type.
|
||||
*/
|
||||
public class LocationTypeModel
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
|
||||
/**
|
||||
* The key for the possible actions on this type.
|
||||
*/
|
||||
public static final String ALLOWED_OPERATIONS = "AllowedOperations";
|
||||
/**
|
||||
* The key fo the poissible peripheral actions on this type.
|
||||
*/
|
||||
public static final String ALLOWED_PERIPHERAL_OPERATIONS = "AllowedPeripheralOperations";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
/**
|
||||
* Reference to the LocationType object.
|
||||
*/
|
||||
private LocationType locationType;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public LocationTypeModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return bundle.getString("locationTypeModel.description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTreeViewName() {
|
||||
String treeViewName = getDescription() + " " + getName();
|
||||
|
||||
return treeViewName;
|
||||
}
|
||||
|
||||
public StringSetProperty getPropertyAllowedOperations() {
|
||||
return (StringSetProperty) getProperty(ALLOWED_OPERATIONS);
|
||||
}
|
||||
|
||||
public StringSetProperty getPropertyAllowedPeripheralOperations() {
|
||||
return (StringSetProperty) getProperty(ALLOWED_PERIPHERAL_OPERATIONS);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public SymbolProperty getPropertyDefaultRepresentation() {
|
||||
return (SymbolProperty) getProperty(ObjectPropConstants.LOCTYPE_DEFAULT_REPRESENTATION);
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("locationTypeModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("locationTypeModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
StringSetProperty pOperations = new LocationTypeActionsProperty(this);
|
||||
pOperations.setDescription(
|
||||
bundle.getString("locationTypeModel.property_allowedOperations.description")
|
||||
);
|
||||
pOperations.setHelptext(
|
||||
bundle.getString("locationTypeModel.property_allowedOperations.helptext")
|
||||
);
|
||||
setProperty(ALLOWED_OPERATIONS, pOperations);
|
||||
|
||||
StringSetProperty pPeripheralOperations = new LocationTypeActionsProperty(this);
|
||||
pPeripheralOperations.setDescription(
|
||||
bundle.getString("locationTypeModel.property_allowedPeripheralOperations.description")
|
||||
);
|
||||
pPeripheralOperations.setHelptext(
|
||||
bundle.getString("locationTypeModel.property_allowedPeripheralOperations.helptext")
|
||||
);
|
||||
setProperty(ALLOWED_PERIPHERAL_OPERATIONS, pPeripheralOperations);
|
||||
|
||||
SymbolProperty pSymbol = new SymbolProperty(this);
|
||||
pSymbol.setLocationRepresentation(LocationRepresentation.NONE);
|
||||
pSymbol.setDescription(bundle.getString("locationTypeModel.property_symbol.description"));
|
||||
pSymbol.setHelptext(bundle.getString("locationTypeModel.property_symbol.helptext"));
|
||||
setProperty(ObjectPropConstants.LOCTYPE_DEFAULT_REPRESENTATION, pSymbol);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("locationTypeModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(
|
||||
bundle.getString("locationTypeModel.property_miscellaneous.helptext")
|
||||
);
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
}
|
||||
|
||||
public LocationType getLocationType() {
|
||||
return locationType;
|
||||
}
|
||||
|
||||
public void setLocationType(LocationType locationType) {
|
||||
this.locationType = locationType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* A graphical component with illustrating effect, but without any impact
|
||||
* on the driving course.
|
||||
*/
|
||||
public class OtherGraphicalElement
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
|
||||
/**
|
||||
* Creates a new instance of OtherGraphicalElement.
|
||||
*/
|
||||
public OtherGraphicalElement() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ResourceBundle.getBundle(BUNDLE_PATH)
|
||||
.getString("otherGraphicalElement.description");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import org.opentcs.data.model.visualization.ElementPropKeys;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.components.layer.NullLayerWrapper;
|
||||
import org.opentcs.guing.base.components.properties.type.BooleanProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.EnvelopesProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrapperProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LinerTypeProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.PeripheralOperationsProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SelectionProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SpeedProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.model.FigureDecorationDetails;
|
||||
|
||||
/**
|
||||
* A connection between two points.
|
||||
*/
|
||||
public class PathModel
|
||||
extends
|
||||
AbstractConnection
|
||||
implements
|
||||
FigureDecorationDetails {
|
||||
|
||||
/**
|
||||
* Key for the length.
|
||||
*/
|
||||
public static final String LENGTH = "length";
|
||||
/**
|
||||
* Key for maximum forward velocity.
|
||||
*/
|
||||
public static final String MAX_VELOCITY = "maxVelocity";
|
||||
/**
|
||||
* Key for maximum reverse velocity.
|
||||
*/
|
||||
public static final String MAX_REVERSE_VELOCITY = "maxReverseVelocity";
|
||||
/**
|
||||
* Key for the locked state.
|
||||
*/
|
||||
public static final String LOCKED = "locked";
|
||||
/**
|
||||
* Key for the peripheral operations on this path.
|
||||
*/
|
||||
public static final String PERIPHERAL_OPERATIONS = "peripheralOperations";
|
||||
/**
|
||||
* Key for the vehicle envelopes on this path.
|
||||
*/
|
||||
public static final String VEHICLE_ENVELOPES = "vehicleEnvelopes";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
/**
|
||||
* The map of vehicle models to allocations states for which this model component's figure is to
|
||||
* be decorated to indicate that it is part of the route of the respective vehicles.
|
||||
*/
|
||||
private Map<VehicleModel, AllocationState> allocationStates
|
||||
= new TreeMap<>(Comparator.comparing(VehicleModel::getName));
|
||||
/**
|
||||
* The set of block models for which this model component's figure is to be decorated to indicate
|
||||
* that it is part of the respective block.
|
||||
*/
|
||||
private Set<BlockModel> blocks = new TreeSet<>(Comparator.comparing(BlockModel::getName));
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public PathModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return bundle.getString("pathModel.description");
|
||||
}
|
||||
|
||||
public LengthProperty getPropertyLength() {
|
||||
return (LengthProperty) getProperty(LENGTH);
|
||||
}
|
||||
|
||||
public SpeedProperty getPropertyMaxVelocity() {
|
||||
return (SpeedProperty) getProperty(MAX_VELOCITY);
|
||||
}
|
||||
|
||||
public SpeedProperty getPropertyMaxReverseVelocity() {
|
||||
return (SpeedProperty) getProperty(MAX_REVERSE_VELOCITY);
|
||||
}
|
||||
|
||||
public BooleanProperty getPropertyLocked() {
|
||||
return (BooleanProperty) getProperty(LOCKED);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Type> getPropertyPathConnType() {
|
||||
return (SelectionProperty<Type>) getProperty(ElementPropKeys.PATH_CONN_TYPE);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPathControlPoints() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.PATH_CONTROL_POINTS);
|
||||
}
|
||||
|
||||
public EnvelopesProperty getPropertyVehicleEnvelopes() {
|
||||
return (EnvelopesProperty) getProperty(VEHICLE_ENVELOPES);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public PeripheralOperationsProperty getPropertyPeripheralOperations() {
|
||||
return (PeripheralOperationsProperty) getProperty(PERIPHERAL_OPERATIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<VehicleModel, AllocationState> getAllocationStates() {
|
||||
return allocationStates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllocationState(VehicleModel model, AllocationState allocationState) {
|
||||
requireNonNull(model, "model");
|
||||
requireNonNull(allocationStates, "allocationStates");
|
||||
|
||||
allocationStates.put(model, allocationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllocationState(
|
||||
@Nonnull
|
||||
VehicleModel model
|
||||
) {
|
||||
requireNonNull(model, "model");
|
||||
|
||||
allocationStates.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockModel(BlockModel model) {
|
||||
blocks.add(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBlockModel(BlockModel model) {
|
||||
blocks.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BlockModel> getBlockModels() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "checkstyle:LineLength"})
|
||||
public AbstractConnection clone()
|
||||
throws CloneNotSupportedException {
|
||||
PathModel clone = (PathModel) super.clone();
|
||||
clone.setAllocationStates(
|
||||
(Map<VehicleModel, AllocationState>) ((TreeMap<VehicleModel, AllocationState>) allocationStates)
|
||||
.clone()
|
||||
);
|
||||
clone.setBlockModels((Set<BlockModel>) ((TreeSet<BlockModel>) blocks).clone());
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("pathModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("pathModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
LengthProperty pLength = new LengthProperty(this);
|
||||
pLength.setDescription(bundle.getString("pathModel.property_length.description"));
|
||||
pLength.setHelptext(bundle.getString("pathModel.property_length.helptext"));
|
||||
setProperty(LENGTH, pLength);
|
||||
|
||||
SpeedProperty pMaxVelocity = new SpeedProperty(this, 1.0, SpeedProperty.Unit.M_S);
|
||||
pMaxVelocity.setDescription(bundle.getString("pathModel.property_maximumVelocity.description"));
|
||||
pMaxVelocity.setHelptext(bundle.getString("pathModel.property_maximumVelocity.helptext"));
|
||||
setProperty(MAX_VELOCITY, pMaxVelocity);
|
||||
|
||||
SpeedProperty pMaxReverseVelocity = new SpeedProperty(this, 0.0, SpeedProperty.Unit.M_S);
|
||||
pMaxReverseVelocity.setDescription(
|
||||
bundle.getString("pathModel.property_maximumReverseVelocity.description")
|
||||
);
|
||||
pMaxReverseVelocity.setHelptext(
|
||||
bundle.getString("pathModel.property_maximumReverseVelocity.helptext")
|
||||
);
|
||||
setProperty(MAX_REVERSE_VELOCITY, pMaxReverseVelocity);
|
||||
|
||||
LinerTypeProperty pPathConnType
|
||||
= new LinerTypeProperty(this, Arrays.asList(Type.values()), Type.values()[0]);
|
||||
pPathConnType.setDescription(
|
||||
bundle.getString("pathModel.property_pathConnectionType.description")
|
||||
);
|
||||
pPathConnType.setHelptext(bundle.getString("pathModel.property_pathConnectionType.helptext"));
|
||||
pPathConnType.setCollectiveEditable(true);
|
||||
setProperty(ElementPropKeys.PATH_CONN_TYPE, pPathConnType);
|
||||
|
||||
StringProperty pPathControlPoints = new StringProperty(this);
|
||||
pPathControlPoints.setDescription(
|
||||
bundle.getString("pathModel.property_pathControlPoints.description")
|
||||
);
|
||||
pPathControlPoints.setHelptext(
|
||||
bundle.getString("pathModel.property_pathControlPoints.helptext")
|
||||
);
|
||||
// Control points may only be moved in the drawing.
|
||||
pPathControlPoints.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.PATH_CONTROL_POINTS, pPathControlPoints);
|
||||
|
||||
StringProperty startComponent = new StringProperty(this);
|
||||
startComponent.setDescription(
|
||||
bundle.getString("pathModel.property_startComponent.description")
|
||||
);
|
||||
startComponent.setModellingEditable(false);
|
||||
startComponent.setOperatingEditable(false);
|
||||
setProperty(START_COMPONENT, startComponent);
|
||||
StringProperty endComponent = new StringProperty(this);
|
||||
endComponent.setDescription(bundle.getString("pathModel.property_endComponent.description"));
|
||||
endComponent.setModellingEditable(false);
|
||||
endComponent.setOperatingEditable(false);
|
||||
setProperty(END_COMPONENT, endComponent);
|
||||
|
||||
LayerWrapperProperty pLayerWrapper = new LayerWrapperProperty(this, new NullLayerWrapper());
|
||||
pLayerWrapper.setDescription(bundle.getString("pathModel.property_layerWrapper.description"));
|
||||
pLayerWrapper.setHelptext(bundle.getString("pathModel.property_layerWrapper.helptext"));
|
||||
pLayerWrapper.setModellingEditable(false);
|
||||
setProperty(LAYER_WRAPPER, pLayerWrapper);
|
||||
|
||||
BooleanProperty pLocked = new BooleanProperty(this);
|
||||
pLocked.setDescription(bundle.getString("pathModel.property_locked.description"));
|
||||
pLocked.setHelptext(bundle.getString("pathModel.property_locked.helptext"));
|
||||
pLocked.setCollectiveEditable(true);
|
||||
pLocked.setOperatingEditable(true);
|
||||
setProperty(LOCKED, pLocked);
|
||||
|
||||
PeripheralOperationsProperty pOperations
|
||||
= new PeripheralOperationsProperty(this, new ArrayList<>());
|
||||
pOperations.setDescription(
|
||||
bundle.getString("pathModel.property_peripheralOperations.description")
|
||||
);
|
||||
pOperations.setHelptext(bundle.getString("pathModel.property_peripheralOperations.helptext"));
|
||||
setProperty(PERIPHERAL_OPERATIONS, pOperations);
|
||||
|
||||
EnvelopesProperty pEnvelope = new EnvelopesProperty(this, new ArrayList<>());
|
||||
pEnvelope.setDescription(bundle.getString("pathModel.property_vehicleEnvelopes.description"));
|
||||
pEnvelope.setHelptext(bundle.getString("pathModel.property_vehicleEnvelopes.helptext"));
|
||||
pEnvelope.setModellingEditable(true);
|
||||
setProperty(VEHICLE_ENVELOPES, pEnvelope);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(bundle.getString("pathModel.property_miscellaneous.description"));
|
||||
pMiscellaneous.setHelptext(bundle.getString("pathModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
}
|
||||
|
||||
private void setAllocationStates(Map<VehicleModel, AllocationState> allocationStates) {
|
||||
this.allocationStates = allocationStates;
|
||||
}
|
||||
|
||||
private void setBlockModels(Set<BlockModel> blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported liner types for connections.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* A direct connection.
|
||||
*/
|
||||
DIRECT(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.direct.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.direct.helptext")),
|
||||
/**
|
||||
* An elbow connection.
|
||||
*/
|
||||
ELBOW(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.elbow.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.elbow.helptext")),
|
||||
/**
|
||||
* A slanted connection.
|
||||
*/
|
||||
SLANTED(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.slanted.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.slanted.helptext")),
|
||||
/**
|
||||
* A polygon path with any number of vertecies.
|
||||
*/
|
||||
POLYPATH(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.polypath.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.polypath.helptext")),
|
||||
|
||||
/**
|
||||
* A bezier curve with 2 control points.
|
||||
*/
|
||||
BEZIER(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.bezier.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.bezier.helptext")),
|
||||
/**
|
||||
* A bezier curve with 3 control points.
|
||||
*/
|
||||
BEZIER_3(ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.bezier3.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pathModel.type.bezier3.helptext"));
|
||||
|
||||
private final String description;
|
||||
|
||||
private final String helptext;
|
||||
|
||||
Type(String description, String helptext) {
|
||||
this.description = requireNonNull(description, "description");
|
||||
this.helptext = requireNonNull(helptext, "helptext");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getHelptext() {
|
||||
return helptext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>Type</code> constant matching the name in the
|
||||
* given input. This method permits extraneous whitespace around the name
|
||||
* and is case insensitive, which makes it a bit more liberal than the
|
||||
* default <code>valueOf</code> that all enums provide.
|
||||
*
|
||||
* @param input The name of the enum constant to return.
|
||||
* @return The enum constant matching the given name.
|
||||
* @throws IllegalArgumentException If this enum has no constant with the
|
||||
* given name.
|
||||
*/
|
||||
public static Type valueOfNormalized(String input)
|
||||
throws IllegalArgumentException {
|
||||
String normalizedInput = requireNonNull(input, "input is null").trim();
|
||||
|
||||
for (Type curType : values()) {
|
||||
if (normalizedInput.equalsIgnoreCase(curType.name())) {
|
||||
return curType;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("No match for '" + input + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import org.opentcs.data.model.Couple;
|
||||
import org.opentcs.data.model.visualization.ElementPropKeys;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.components.layer.NullLayerWrapper;
|
||||
import org.opentcs.guing.base.components.properties.type.AngleProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.BoundingBoxProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.CoordinateProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.EnvelopesProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LayerWrapperProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.PointTypeProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SelectionProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.model.AbstractConnectableModelComponent;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
import org.opentcs.guing.base.model.BoundingBoxModel;
|
||||
import org.opentcs.guing.base.model.FigureDecorationDetails;
|
||||
import org.opentcs.guing.base.model.PositionableModelComponent;
|
||||
|
||||
/**
|
||||
* Basic implementation of a point.
|
||||
*/
|
||||
public class PointModel
|
||||
extends
|
||||
AbstractConnectableModelComponent
|
||||
implements
|
||||
PositionableModelComponent,
|
||||
FigureDecorationDetails {
|
||||
|
||||
/**
|
||||
* Key for the prefered angle of a vehicle on this point.
|
||||
*/
|
||||
public static final String VEHICLE_ORIENTATION_ANGLE = "vehicleOrientationAngle";
|
||||
/**
|
||||
* Key for the type.
|
||||
*/
|
||||
public static final String TYPE = "Type";
|
||||
/**
|
||||
* Key for the vehicle envelopes at this point.
|
||||
*/
|
||||
public static final String VEHICLE_ENVELOPES = "vehicleEnvelopes";
|
||||
/**
|
||||
* Key for the maximum bounding box that a vehicle at this point is allowed to have.
|
||||
*/
|
||||
public static final String MAX_VEHICLE_BOUNDING_BOX = "maxVehicleBoundingBox";
|
||||
/**
|
||||
* The point's default position for both axes.
|
||||
*/
|
||||
private static final int DEFAULT_XY_POSITION = 0;
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
/**
|
||||
* The map of vehicle models to allocations states for which this model component's figure is to
|
||||
* be decorated to indicate that it is part of the route of the respective vehicles.
|
||||
*/
|
||||
private Map<VehicleModel, AllocationState> allocationStates
|
||||
= new TreeMap<>(Comparator.comparing(VehicleModel::getName));
|
||||
/**
|
||||
* The set of block models for which this model component's figure is to be decorated to indicate
|
||||
* that it is part of the respective block.
|
||||
*/
|
||||
private Set<BlockModel> blocks = new TreeSet<>(Comparator.comparing(BlockModel::getName));
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public PointModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("pointModel.description");
|
||||
}
|
||||
|
||||
public CoordinateProperty getPropertyModelPositionX() {
|
||||
return (CoordinateProperty) getProperty(MODEL_X_POSITION);
|
||||
}
|
||||
|
||||
public CoordinateProperty getPropertyModelPositionY() {
|
||||
return (CoordinateProperty) getProperty(MODEL_Y_POSITION);
|
||||
}
|
||||
|
||||
public AngleProperty getPropertyVehicleOrientationAngle() {
|
||||
return (AngleProperty) getProperty(VEHICLE_ORIENTATION_ANGLE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Type> getPropertyType() {
|
||||
return (SelectionProperty<Type>) getProperty(TYPE);
|
||||
}
|
||||
|
||||
public EnvelopesProperty getPropertyVehicleEnvelopes() {
|
||||
return (EnvelopesProperty) getProperty(VEHICLE_ENVELOPES);
|
||||
}
|
||||
|
||||
public BoundingBoxProperty getPropertyMaxVehicleBoundingBox() {
|
||||
return (BoundingBoxProperty) getProperty(MAX_VEHICLE_BOUNDING_BOX);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLayoutPosX() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.POINT_POS_X);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyLayoutPosY() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.POINT_POS_Y);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPointLabelOffsetX() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.POINT_LABEL_OFFSET_X);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPointLabelOffsetY() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.POINT_LABEL_OFFSET_Y);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPointLabelOrientationAngle() {
|
||||
return (StringProperty) getProperty(ElementPropKeys.POINT_LABEL_ORIENTATION_ANGLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<VehicleModel, AllocationState> getAllocationStates() {
|
||||
return allocationStates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllocationState(VehicleModel model, AllocationState allocationState) {
|
||||
requireNonNull(model, "model");
|
||||
requireNonNull(allocationStates, "allocationStates");
|
||||
|
||||
allocationStates.put(model, allocationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllocationState(
|
||||
@Nonnull
|
||||
VehicleModel model
|
||||
) {
|
||||
requireNonNull(model, "model");
|
||||
|
||||
allocationStates.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlockModel(BlockModel model) {
|
||||
blocks.add(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBlockModel(BlockModel model) {
|
||||
blocks.remove(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<BlockModel> getBlockModels() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "checkstyle:LineLength"})
|
||||
public AbstractModelComponent clone()
|
||||
throws CloneNotSupportedException {
|
||||
PointModel clone = (PointModel) super.clone();
|
||||
clone.setAllocationStates(
|
||||
(Map<VehicleModel, AllocationState>) ((TreeMap<VehicleModel, AllocationState>) allocationStates)
|
||||
.clone()
|
||||
);
|
||||
clone.setBlockModels((Set<BlockModel>) ((TreeSet<BlockModel>) blocks).clone());
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("pointModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("pointModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
CoordinateProperty pPosX = new CoordinateProperty(
|
||||
this,
|
||||
DEFAULT_XY_POSITION,
|
||||
LengthProperty.Unit.MM
|
||||
);
|
||||
pPosX.setDescription(bundle.getString("pointModel.property_modelPositionX.description"));
|
||||
pPosX.setHelptext(bundle.getString("pointModel.property_modelPositionX.helptext"));
|
||||
setProperty(MODEL_X_POSITION, pPosX);
|
||||
|
||||
CoordinateProperty pPosY = new CoordinateProperty(
|
||||
this,
|
||||
DEFAULT_XY_POSITION,
|
||||
LengthProperty.Unit.MM
|
||||
);
|
||||
pPosY.setDescription(bundle.getString("pointModel.property_modelPositionY.description"));
|
||||
pPosY.setHelptext(bundle.getString("pointModel.property_modelPositionY.helptext"));
|
||||
setProperty(MODEL_Y_POSITION, pPosY);
|
||||
|
||||
AngleProperty pPhi = new AngleProperty(this);
|
||||
pPhi.setDescription(bundle.getString("pointModel.property_angle.description"));
|
||||
pPhi.setHelptext(bundle.getString("pointModel.property_angle.helptext"));
|
||||
setProperty(VEHICLE_ORIENTATION_ANGLE, pPhi);
|
||||
|
||||
PointTypeProperty pType = new PointTypeProperty(
|
||||
this,
|
||||
Arrays.asList(Type.values()),
|
||||
Type.values()[0]
|
||||
);
|
||||
pType.setDescription(bundle.getString("pointModel.property_type.description"));
|
||||
pType.setHelptext(bundle.getString("pointModel.property_type.helptext"));
|
||||
pType.setCollectiveEditable(true);
|
||||
setProperty(TYPE, pType);
|
||||
|
||||
EnvelopesProperty pEnvelope = new EnvelopesProperty(this, new ArrayList<>());
|
||||
pEnvelope.setDescription(bundle.getString("pointModel.property_vehicleEnvelopes.description"));
|
||||
pEnvelope.setHelptext(bundle.getString("pointModel.property_vehicleEnvelopes.helptext"));
|
||||
pEnvelope.setModellingEditable(true);
|
||||
setProperty(VEHICLE_ENVELOPES, pEnvelope);
|
||||
|
||||
BoundingBoxProperty pMaxVehicleBoundingBox = new BoundingBoxProperty(
|
||||
this,
|
||||
new BoundingBoxModel(1000, 1000, 1000, new Couple(0, 0))
|
||||
);
|
||||
pMaxVehicleBoundingBox.setDescription(
|
||||
bundle.getString("pointModel.property_maxVehicleBoundingBox.description")
|
||||
);
|
||||
pMaxVehicleBoundingBox.setHelptext(
|
||||
bundle.getString("pointModel.property_maxVehicleBoundingBox.helptext")
|
||||
);
|
||||
setProperty(MAX_VEHICLE_BOUNDING_BOX, pMaxVehicleBoundingBox);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("pointModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(bundle.getString("pointModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
|
||||
StringProperty pPointPosX = new StringProperty(this, String.valueOf(DEFAULT_XY_POSITION));
|
||||
pPointPosX.setDescription(bundle.getString("pointModel.property_positionX.description"));
|
||||
pPointPosX.setHelptext(bundle.getString("pointModel.property_positionX.helptext"));
|
||||
// The position can only be changed in the drawing.
|
||||
pPointPosX.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.POINT_POS_X, pPointPosX);
|
||||
|
||||
StringProperty pPointPosY = new StringProperty(this, String.valueOf(DEFAULT_XY_POSITION));
|
||||
pPointPosY.setDescription(bundle.getString("pointModel.property_positionY.description"));
|
||||
pPointPosY.setHelptext(bundle.getString("pointModel.property_positionY.helptext"));
|
||||
// The position can only be changed in the drawing.
|
||||
pPointPosY.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.POINT_POS_Y, pPointPosY);
|
||||
|
||||
StringProperty pPointLabelOffsetX = new StringProperty(this);
|
||||
pPointLabelOffsetX.setDescription(
|
||||
bundle.getString("pointModel.property_labelOffsetX.description")
|
||||
);
|
||||
pPointLabelOffsetX.setHelptext(bundle.getString("pointModel.property_labelOffsetX.helptext"));
|
||||
pPointLabelOffsetX.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.POINT_LABEL_OFFSET_X, pPointLabelOffsetX);
|
||||
|
||||
StringProperty pPointLabelOffsetY = new StringProperty(this);
|
||||
pPointLabelOffsetY.setDescription(
|
||||
bundle.getString("pointModel.property_labelOffsetY.description")
|
||||
);
|
||||
pPointLabelOffsetY.setHelptext(bundle.getString("pointModel.property_labelOffsetY.helptext"));
|
||||
pPointLabelOffsetY.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.POINT_LABEL_OFFSET_Y, pPointLabelOffsetY);
|
||||
|
||||
StringProperty pPointLabelOrientationAngle = new StringProperty(this);
|
||||
pPointLabelOrientationAngle.setDescription(
|
||||
bundle.getString("pointModel.property_labelOrientationAngle.description")
|
||||
);
|
||||
pPointLabelOrientationAngle.setHelptext(
|
||||
bundle.getString("pointModel.property_labelOrientationAngle.helptext")
|
||||
);
|
||||
pPointLabelOrientationAngle.setModellingEditable(false);
|
||||
setProperty(ElementPropKeys.POINT_LABEL_ORIENTATION_ANGLE, pPointLabelOrientationAngle);
|
||||
|
||||
LayerWrapperProperty pLayerWrapper = new LayerWrapperProperty(this, new NullLayerWrapper());
|
||||
pLayerWrapper.setDescription(bundle.getString("pointModel.property_layerWrapper.description"));
|
||||
pLayerWrapper.setHelptext(bundle.getString("pointModel.property_layerWrapper.helptext"));
|
||||
pLayerWrapper.setModellingEditable(false);
|
||||
setProperty(LAYER_WRAPPER, pLayerWrapper);
|
||||
}
|
||||
|
||||
private void setAllocationStates(Map<VehicleModel, AllocationState> allocationStates) {
|
||||
this.allocationStates = allocationStates;
|
||||
}
|
||||
|
||||
private void setBlockModels(Set<BlockModel> blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported point types.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* A halting position.
|
||||
*/
|
||||
HALT(ResourceBundle.getBundle(BUNDLE_PATH).getString("pointModel.type.halt.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pointModel.type.halt.helptext")),
|
||||
/**
|
||||
* A parking position.
|
||||
*/
|
||||
PARK(ResourceBundle.getBundle(BUNDLE_PATH).getString("pointModel.type.park.description"),
|
||||
ResourceBundle.getBundle(BUNDLE_PATH).getString("pointModel.type.park.helptext"));
|
||||
|
||||
private final String description;
|
||||
private final String helptext;
|
||||
|
||||
Type(String description, String helptext) {
|
||||
this.description = requireNonNull(description, "description");
|
||||
this.helptext = requireNonNull(helptext, "helptext");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getHelptext() {
|
||||
return helptext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,693 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.opentcs.guing.base.I18nPlantOverviewBase.BUNDLE_PATH;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.ResourceBundle;
|
||||
import org.opentcs.data.model.Couple;
|
||||
import org.opentcs.data.model.Triple;
|
||||
import org.opentcs.data.model.Vehicle;
|
||||
import org.opentcs.data.model.visualization.ElementPropKeys;
|
||||
import org.opentcs.data.order.TransportOrder;
|
||||
import org.opentcs.guing.base.components.properties.type.AngleProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.BooleanProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.BoundingBoxProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.ColorProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.EnergyLevelThresholdSetModel;
|
||||
import org.opentcs.guing.base.components.properties.type.EnergyLevelThresholdSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.KeyValueSetProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.OrderTypesProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.PercentProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.ResourceProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SelectionProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SpeedProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.StringProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.TripleProperty;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
import org.opentcs.guing.base.model.BoundingBoxModel;
|
||||
import org.opentcs.guing.base.model.DrawnModelComponent;
|
||||
|
||||
/**
|
||||
* Basic implementation of a vehicle. A vehicle has an unique number.
|
||||
*/
|
||||
public class VehicleModel
|
||||
extends
|
||||
AbstractModelComponent
|
||||
implements
|
||||
DrawnModelComponent {
|
||||
|
||||
/**
|
||||
* The name/key of the 'bounding box' property.
|
||||
*/
|
||||
public static final String BOUNDING_BOX = "BoundingBox";
|
||||
/**
|
||||
* The name/key of the 'energyLevelThresholdSet' property.
|
||||
*/
|
||||
public static final String ENERGY_LEVEL_THRESHOLD_SET = "EnergyLevelThresholdSet";
|
||||
/**
|
||||
* The name/key of the 'loaded' property.
|
||||
*/
|
||||
public static final String LOADED = "Loaded";
|
||||
/**
|
||||
* The name/key of the 'state' property.
|
||||
*/
|
||||
public static final String STATE = "State";
|
||||
/**
|
||||
* The name/key of the 'proc state' property.
|
||||
*/
|
||||
public static final String PROC_STATE = "ProcState";
|
||||
/**
|
||||
* The name/key of the 'integration level' property.
|
||||
*/
|
||||
public static final String INTEGRATION_LEVEL = "IntegrationLevel";
|
||||
/**
|
||||
* The name/key of the 'paused' property.
|
||||
*/
|
||||
public static final String PAUSED = "Paused";
|
||||
/**
|
||||
* The name/key of the 'point' property.
|
||||
*/
|
||||
public static final String POINT = "Point";
|
||||
/**
|
||||
* The name/key of the 'next point' property.
|
||||
*/
|
||||
public static final String NEXT_POINT = "NextPoint";
|
||||
/**
|
||||
* The name/key of the 'precise position' property.
|
||||
*/
|
||||
public static final String PRECISE_POSITION = "PrecisePosition";
|
||||
/**
|
||||
* The name/key of the 'orientation angle' property.
|
||||
*/
|
||||
public static final String ORIENTATION_ANGLE = "OrientationAngle";
|
||||
/**
|
||||
* The name/key of the 'energy level' property.
|
||||
*/
|
||||
public static final String ENERGY_LEVEL = "EnergyLevel";
|
||||
/**
|
||||
* The name/key of the 'current transport order name' property.
|
||||
*/
|
||||
public static final String CURRENT_TRANSPORT_ORDER_NAME = "currentTransportOrderName";
|
||||
/**
|
||||
* The name/key of the 'current order sequence name' property.
|
||||
*/
|
||||
public static final String CURRENT_SEQUENCE_NAME = "currentOrderSequenceName";
|
||||
/**
|
||||
* The name/key of the 'maximum velocity' property.
|
||||
*/
|
||||
public static final String MAXIMUM_VELOCITY = "MaximumVelocity";
|
||||
/**
|
||||
* The name/key of the 'maximum reverse velocity' property.
|
||||
*/
|
||||
public static final String MAXIMUM_REVERSE_VELOCITY = "MaximumReverseVelocity";
|
||||
/**
|
||||
* The name/key of the 'allowed order types' property.
|
||||
*/
|
||||
public static final String ALLOWED_ORDER_TYPES = "AllowedOrderTypes";
|
||||
/**
|
||||
* The name/key of the 'allocated resources' property.
|
||||
*/
|
||||
public static final String ALLOCATED_RESOURCES = "AllocatedResources";
|
||||
/**
|
||||
* The name/key of the 'claimed resources' property.
|
||||
*/
|
||||
public static final String CLAIMED_RESOURCES = "ClaimedResources";
|
||||
/**
|
||||
* The name/key of the 'envelope key' property.
|
||||
*/
|
||||
public static final String ENVELOPE_KEY = "EnvelopeKey";
|
||||
/**
|
||||
* This class's resource bundle.
|
||||
*/
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_PATH);
|
||||
|
||||
/**
|
||||
* The point the vehicle currently remains on.
|
||||
*/
|
||||
private PointModel fPoint;
|
||||
/**
|
||||
* The point the vehicle will drive to next.
|
||||
*/
|
||||
private PointModel fNextPoint;
|
||||
/**
|
||||
* The current position (x,y,z) the vehicle driver reported.
|
||||
*/
|
||||
private Triple fPrecisePosition;
|
||||
/**
|
||||
* The current vehicle orientation.
|
||||
*/
|
||||
private double fOrientationAngle;
|
||||
/**
|
||||
* The state of the drive order.
|
||||
*/
|
||||
private TransportOrder.State fDriveOrderState;
|
||||
/**
|
||||
* Flag whether the drive order will be displayed.
|
||||
*/
|
||||
private boolean fDisplayDriveOrders;
|
||||
/**
|
||||
* Flag whether the view follows this vehicle as it drives.
|
||||
*/
|
||||
private boolean fViewFollows;
|
||||
/**
|
||||
* A reference to the vehicle.
|
||||
*/
|
||||
private Vehicle vehicle = new Vehicle("Dummy");
|
||||
/**
|
||||
* The current or next path in a drive order.
|
||||
*/
|
||||
private PathModel currentDriveOrderPath;
|
||||
/**
|
||||
* The destination for the current drive order.
|
||||
*/
|
||||
private PointModel driveOrderDestination;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public VehicleModel() {
|
||||
createProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the point the vehicle currently remains on.
|
||||
*
|
||||
* @param point The point.
|
||||
*/
|
||||
public void placeOnPoint(PointModel point) {
|
||||
fPoint = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point the vehicle currently remains on.
|
||||
*
|
||||
* @return The current point.
|
||||
*/
|
||||
public PointModel getPoint() {
|
||||
return fPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point the vehicle will drive to next.
|
||||
*
|
||||
* @return The next point.
|
||||
*/
|
||||
public PointModel getNextPoint() {
|
||||
return fNextPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the point the vehicle will drive to next.
|
||||
*
|
||||
* @param point The next point.
|
||||
*/
|
||||
public void setNextPoint(PointModel point) {
|
||||
fNextPoint = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current position.
|
||||
*
|
||||
* @return The position (x,y,z).
|
||||
*/
|
||||
public Triple getPrecisePosition() {
|
||||
return fPrecisePosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current position.
|
||||
*
|
||||
* @param position A triple containing the position.
|
||||
*/
|
||||
public void setPrecisePosition(Triple position) {
|
||||
fPrecisePosition = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current orientation angle.
|
||||
*
|
||||
* @return The orientation angle.
|
||||
*/
|
||||
public double getOrientationAngle() {
|
||||
return fOrientationAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the orientation angle.
|
||||
*
|
||||
* @param angle The new angle.
|
||||
*/
|
||||
public void setOrientationAngle(double angle) {
|
||||
fOrientationAngle = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color the drive order is painted in.
|
||||
*
|
||||
* @return The color.
|
||||
*/
|
||||
public Color getDriveOrderColor() {
|
||||
return getPropertyRouteColor().getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the drive order.
|
||||
*
|
||||
* @return The state.
|
||||
*/
|
||||
public TransportOrder.State getDriveOrderState() {
|
||||
return fDriveOrderState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drive order state.
|
||||
*
|
||||
* @param driveOrderState The new state.
|
||||
*/
|
||||
public void setDriveOrderState(TransportOrder.State driveOrderState) {
|
||||
fDriveOrderState = driveOrderState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the drive order shall be displayed or not.
|
||||
*
|
||||
* @param state <code>true</code> to display the drive order.
|
||||
*/
|
||||
public void setDisplayDriveOrders(boolean state) {
|
||||
fDisplayDriveOrders = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the drive order is displayed.
|
||||
*
|
||||
* @return <code>true</code>, if it displayed.
|
||||
*/
|
||||
public boolean getDisplayDriveOrders() {
|
||||
return fDisplayDriveOrders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the view follows this vehicle as it drives.
|
||||
*
|
||||
* @return <code>true</code> if it follows.
|
||||
*/
|
||||
public boolean isViewFollows() {
|
||||
return fViewFollows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the view follows this vehicle as it drives.
|
||||
*
|
||||
* @param viewFollows <code>true</code> if it follows.
|
||||
*/
|
||||
public void setViewFollows(boolean viewFollows) {
|
||||
this.fViewFollows = viewFollows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the kernel object.
|
||||
*
|
||||
* @return The kernel object.
|
||||
*/
|
||||
@Nonnull
|
||||
public Vehicle getVehicle() {
|
||||
return vehicle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the kernel object.
|
||||
*
|
||||
* @param vehicle The kernel object.
|
||||
*/
|
||||
public void setVehicle(
|
||||
@Nonnull
|
||||
Vehicle vehicle
|
||||
) {
|
||||
this.vehicle = requireNonNull(vehicle, "vehicle");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current path for the drive order.
|
||||
*
|
||||
* @return Path for the drive order.
|
||||
*/
|
||||
public PathModel getCurrentDriveOrderPath() {
|
||||
return currentDriveOrderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current drive order path.
|
||||
*
|
||||
* @param path the current drive order path.
|
||||
*/
|
||||
public void setCurrentDriveOrderPath(PathModel path) {
|
||||
currentDriveOrderPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the destination for the current drive order.
|
||||
*
|
||||
* @return the destination for the current drive order.
|
||||
*/
|
||||
public PointModel getDriveOrderDestination() {
|
||||
return driveOrderDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the destination for the current drive order.
|
||||
*
|
||||
* @param driveOrderDestination destination for the current drive order.
|
||||
*/
|
||||
public void setDriveOrderDestination(PointModel driveOrderDestination) {
|
||||
this.driveOrderDestination = driveOrderDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the last reported processing state of the vehicle would allow it to be assigned
|
||||
* an order.
|
||||
*
|
||||
* @return {@code true} if, and only if, the vehicle's integration level is TO_BE_UTILIZED.
|
||||
*/
|
||||
public boolean isAvailableForOrder() {
|
||||
return vehicle != null
|
||||
&& vehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_UTILIZED;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getTreeViewName() {
|
||||
String treeViewName = getDescription() + " " + getName();
|
||||
|
||||
return treeViewName;
|
||||
}
|
||||
|
||||
@Override // AbstractModelComponent
|
||||
public String getDescription() {
|
||||
return bundle.getString("vehicleModel.description");
|
||||
}
|
||||
|
||||
public BoundingBoxProperty getPropertyBoundingBox() {
|
||||
return (BoundingBoxProperty) getProperty(BOUNDING_BOX);
|
||||
}
|
||||
|
||||
public ColorProperty getPropertyRouteColor() {
|
||||
return (ColorProperty) getProperty(ElementPropKeys.VEHICLE_ROUTE_COLOR);
|
||||
}
|
||||
|
||||
public SpeedProperty getPropertyMaxVelocity() {
|
||||
return (SpeedProperty) getProperty(MAXIMUM_VELOCITY);
|
||||
}
|
||||
|
||||
public SpeedProperty getPropertyMaxReverseVelocity() {
|
||||
return (SpeedProperty) getProperty(MAXIMUM_REVERSE_VELOCITY);
|
||||
}
|
||||
|
||||
public EnergyLevelThresholdSetProperty getPropertyEnergyLevelThresholdSet() {
|
||||
return (EnergyLevelThresholdSetProperty) getProperty(ENERGY_LEVEL_THRESHOLD_SET);
|
||||
}
|
||||
|
||||
public PercentProperty getPropertyEnergyLevel() {
|
||||
return (PercentProperty) getProperty(ENERGY_LEVEL);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Vehicle.State> getPropertyState() {
|
||||
return (SelectionProperty<Vehicle.State>) getProperty(STATE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Vehicle.ProcState> getPropertyProcState() {
|
||||
return (SelectionProperty<Vehicle.ProcState>) getProperty(PROC_STATE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectionProperty<Vehicle.IntegrationLevel> getPropertyIntegrationLevel() {
|
||||
return (SelectionProperty<Vehicle.IntegrationLevel>) getProperty(INTEGRATION_LEVEL);
|
||||
}
|
||||
|
||||
public BooleanProperty getPropertyPaused() {
|
||||
return (BooleanProperty) getProperty(PAUSED);
|
||||
}
|
||||
|
||||
public AngleProperty getPropertyOrientationAngle() {
|
||||
return (AngleProperty) getProperty(ORIENTATION_ANGLE);
|
||||
}
|
||||
|
||||
public TripleProperty getPropertyPrecisePosition() {
|
||||
return (TripleProperty) getProperty(PRECISE_POSITION);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyPoint() {
|
||||
return (StringProperty) getProperty(POINT);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyNextPoint() {
|
||||
return (StringProperty) getProperty(NEXT_POINT);
|
||||
}
|
||||
|
||||
public BooleanProperty getPropertyLoaded() {
|
||||
return (BooleanProperty) getProperty(LOADED);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyCurrentOrderName() {
|
||||
return (StringProperty) getProperty(CURRENT_TRANSPORT_ORDER_NAME);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyCurrentSequenceName() {
|
||||
return (StringProperty) getProperty(CURRENT_SEQUENCE_NAME);
|
||||
}
|
||||
|
||||
public OrderTypesProperty getPropertyAllowedOrderTypes() {
|
||||
return (OrderTypesProperty) getProperty(ALLOWED_ORDER_TYPES);
|
||||
}
|
||||
|
||||
public StringProperty getPropertyEnvelopeKey() {
|
||||
return (StringProperty) getProperty(ENVELOPE_KEY);
|
||||
}
|
||||
|
||||
public KeyValueSetProperty getPropertyMiscellaneous() {
|
||||
return (KeyValueSetProperty) getProperty(MISCELLANEOUS);
|
||||
}
|
||||
|
||||
public ResourceProperty getAllocatedResources() {
|
||||
return (ResourceProperty) getProperty(ALLOCATED_RESOURCES);
|
||||
}
|
||||
|
||||
public ResourceProperty getClaimedResources() {
|
||||
return (ResourceProperty) getProperty(CLAIMED_RESOURCES);
|
||||
}
|
||||
|
||||
private void createProperties() {
|
||||
StringProperty pName = new StringProperty(this);
|
||||
pName.setDescription(bundle.getString("vehicleModel.property_name.description"));
|
||||
pName.setHelptext(bundle.getString("vehicleModel.property_name.helptext"));
|
||||
setProperty(NAME, pName);
|
||||
|
||||
BoundingBoxProperty pBoundingBox = new BoundingBoxProperty(
|
||||
this,
|
||||
new BoundingBoxModel(1000, 1000, 1000, new Couple(0, 0))
|
||||
);
|
||||
pBoundingBox.setDescription(bundle.getString("vehicleModel.property_boundingBox.description"));
|
||||
pBoundingBox.setHelptext(bundle.getString("vehicleModel.property_boundingBox.helptext"));
|
||||
setProperty(BOUNDING_BOX, pBoundingBox);
|
||||
|
||||
ColorProperty pColor = new ColorProperty(this, Color.red);
|
||||
pColor.setDescription(bundle.getString("vehicleModel.property_routeColor.description"));
|
||||
pColor.setHelptext(bundle.getString("vehicleModel.property_routeColor.helptext"));
|
||||
setProperty(ElementPropKeys.VEHICLE_ROUTE_COLOR, pColor);
|
||||
|
||||
SpeedProperty pMaximumVelocity = new SpeedProperty(this, 1000, SpeedProperty.Unit.MM_S);
|
||||
pMaximumVelocity.setDescription(
|
||||
bundle.getString("vehicleModel.property_maximumVelocity.description")
|
||||
);
|
||||
pMaximumVelocity.setHelptext(
|
||||
bundle.getString("vehicleModel.property_maximumVelocity.helptext")
|
||||
);
|
||||
setProperty(MAXIMUM_VELOCITY, pMaximumVelocity);
|
||||
|
||||
SpeedProperty pMaximumReverseVelocity = new SpeedProperty(this, 1000, SpeedProperty.Unit.MM_S);
|
||||
pMaximumReverseVelocity.setDescription(
|
||||
bundle.getString("vehicleModel.property_maximumReverseVelocity.description")
|
||||
);
|
||||
pMaximumReverseVelocity.setHelptext(
|
||||
bundle.getString("vehicleModel.property_maximumReverseVelocity.helptext")
|
||||
);
|
||||
setProperty(MAXIMUM_REVERSE_VELOCITY, pMaximumReverseVelocity);
|
||||
|
||||
EnergyLevelThresholdSetProperty pEnergyLevelThresholdSet = new EnergyLevelThresholdSetProperty(
|
||||
this, new EnergyLevelThresholdSetModel(30, 90, 40, 95)
|
||||
);
|
||||
pEnergyLevelThresholdSet.setDescription(
|
||||
bundle.getString("vehicleModel.property_energyLevelThresholdSet.description")
|
||||
);
|
||||
pEnergyLevelThresholdSet.setHelptext(
|
||||
bundle.getString("vehicleModel.property_energyLevelThresholdSet.helptext")
|
||||
);
|
||||
pEnergyLevelThresholdSet.setModellingEditable(true);
|
||||
pEnergyLevelThresholdSet.setOperatingEditable(true);
|
||||
setProperty(ENERGY_LEVEL_THRESHOLD_SET, pEnergyLevelThresholdSet);
|
||||
|
||||
PercentProperty pEnergyLevel = new PercentProperty(this, true);
|
||||
pEnergyLevel.setDescription(bundle.getString("vehicleModel.property_energyLevel.description"));
|
||||
pEnergyLevel.setHelptext(bundle.getString("vehicleModel.property_energyLevel.helptext"));
|
||||
pEnergyLevel.setModellingEditable(false);
|
||||
setProperty(ENERGY_LEVEL, pEnergyLevel);
|
||||
|
||||
BooleanProperty pLoaded = new BooleanProperty(this);
|
||||
pLoaded.setDescription(bundle.getString("vehicleModel.property_loaded.description"));
|
||||
pLoaded.setHelptext(bundle.getString("vehicleModel.property_loaded.helptext"));
|
||||
pLoaded.setModellingEditable(false);
|
||||
setProperty(LOADED, pLoaded);
|
||||
|
||||
SelectionProperty<Vehicle.State> pState
|
||||
= new SelectionProperty<>(
|
||||
this,
|
||||
Arrays.asList(Vehicle.State.values()),
|
||||
Vehicle.State.UNKNOWN
|
||||
);
|
||||
pState.setDescription(bundle.getString("vehicleModel.property_state.description"));
|
||||
pState.setHelptext(bundle.getString("vehicleModel.property_state.helptext"));
|
||||
pState.setModellingEditable(false);
|
||||
setProperty(STATE, pState);
|
||||
|
||||
SelectionProperty<Vehicle.ProcState> pProcState
|
||||
= new SelectionProperty<>(
|
||||
this,
|
||||
Arrays.asList(Vehicle.ProcState.values()),
|
||||
Vehicle.ProcState.IDLE
|
||||
);
|
||||
pProcState.setDescription(
|
||||
bundle.getString("vehicleModel.property_processingState.description")
|
||||
);
|
||||
pProcState.setHelptext(bundle.getString("vehicleModel.property_processingState.helptext"));
|
||||
pProcState.setModellingEditable(false);
|
||||
setProperty(PROC_STATE, pProcState);
|
||||
|
||||
SelectionProperty<Vehicle.IntegrationLevel> pIntegrationLevel
|
||||
= new SelectionProperty<>(
|
||||
this,
|
||||
Arrays.asList(Vehicle.IntegrationLevel.values()),
|
||||
Vehicle.IntegrationLevel.TO_BE_RESPECTED
|
||||
);
|
||||
pIntegrationLevel.setDescription(
|
||||
bundle.getString("vehicleModel.property_integrationLevel.description")
|
||||
);
|
||||
pIntegrationLevel.setHelptext(
|
||||
bundle.getString("vehicleModel.property_integrationLevel.helptext")
|
||||
);
|
||||
pIntegrationLevel.setModellingEditable(false);
|
||||
setProperty(INTEGRATION_LEVEL, pIntegrationLevel);
|
||||
|
||||
BooleanProperty pPaused = new BooleanProperty(this);
|
||||
pPaused.setDescription(bundle.getString("vehicleModel.property_paused.description"));
|
||||
pPaused.setHelptext(bundle.getString("vehicleModel.property_paused.helptext"));
|
||||
pPaused.setModellingEditable(false);
|
||||
pPaused.setOperatingEditable(true);
|
||||
setProperty(PAUSED, pPaused);
|
||||
|
||||
StringProperty pPoint = new StringProperty(this);
|
||||
pPoint.setDescription(bundle.getString("vehicleModel.property_currentPoint.description"));
|
||||
pPoint.setHelptext(bundle.getString("vehicleModel.property_currentPoint.helptext"));
|
||||
pPoint.setModellingEditable(false);
|
||||
setProperty(POINT, pPoint);
|
||||
|
||||
StringProperty pNextPoint = new StringProperty(this);
|
||||
pNextPoint.setDescription(bundle.getString("vehicleModel.property_nextPoint.description"));
|
||||
pNextPoint.setHelptext(bundle.getString("vehicleModel.property_nextPoint.helptext"));
|
||||
pNextPoint.setModellingEditable(false);
|
||||
setProperty(NEXT_POINT, pNextPoint);
|
||||
|
||||
TripleProperty pPrecisePosition = new TripleProperty(this);
|
||||
pPrecisePosition.setDescription(
|
||||
bundle.getString("vehicleModel.property_precisePosition.description")
|
||||
);
|
||||
pPrecisePosition.setHelptext(
|
||||
bundle.getString("vehicleModel.property_precisePosition.helptext")
|
||||
);
|
||||
pPrecisePosition.setModellingEditable(false);
|
||||
setProperty(PRECISE_POSITION, pPrecisePosition);
|
||||
|
||||
AngleProperty pOrientationAngle = new AngleProperty(this);
|
||||
pOrientationAngle.setDescription(
|
||||
bundle.getString("vehicleModel.property_orientationAngle.description")
|
||||
);
|
||||
pOrientationAngle.setHelptext(
|
||||
bundle.getString("vehicleModel.property_orientationAngle.helptext")
|
||||
);
|
||||
pOrientationAngle.setModellingEditable(false);
|
||||
setProperty(ORIENTATION_ANGLE, pOrientationAngle);
|
||||
|
||||
StringProperty pEnvelopeKey = new StringProperty(this);
|
||||
pEnvelopeKey.setDescription(bundle.getString("vehicleModel.property_envelopeKey.description"));
|
||||
pEnvelopeKey.setHelptext(bundle.getString("vehicleModel.property_envelopeKey.helptext"));
|
||||
pEnvelopeKey.setModellingEditable(true);
|
||||
pEnvelopeKey.setOperatingEditable(false);
|
||||
setProperty(ENVELOPE_KEY, pEnvelopeKey);
|
||||
|
||||
KeyValueSetProperty pMiscellaneous = new KeyValueSetProperty(this);
|
||||
pMiscellaneous.setDescription(
|
||||
bundle.getString("vehicleModel.property_miscellaneous.description")
|
||||
);
|
||||
pMiscellaneous.setHelptext(bundle.getString("vehicleModel.property_miscellaneous.helptext"));
|
||||
pMiscellaneous.setOperatingEditable(true);
|
||||
setProperty(MISCELLANEOUS, pMiscellaneous);
|
||||
|
||||
StringProperty curTransportOrderName = new StringProperty(this);
|
||||
curTransportOrderName.setDescription(
|
||||
bundle.getString("vehicleModel.property_currentTransportOrder.description")
|
||||
);
|
||||
curTransportOrderName.setHelptext(
|
||||
bundle.getString("vehicleModel.property_currentTransportOrder.helptext")
|
||||
);
|
||||
curTransportOrderName.setModellingEditable(false);
|
||||
setProperty(CURRENT_TRANSPORT_ORDER_NAME, curTransportOrderName);
|
||||
|
||||
StringProperty curOrderSequenceName = new StringProperty(this);
|
||||
curOrderSequenceName.setDescription(
|
||||
bundle.getString("vehicleModel.property_currentOrderSequence.description")
|
||||
);
|
||||
curOrderSequenceName.setHelptext(
|
||||
bundle.getString("vehicleModel.property_currentOrderSequence.helptext")
|
||||
);
|
||||
curOrderSequenceName.setModellingEditable(false);
|
||||
setProperty(CURRENT_SEQUENCE_NAME, curOrderSequenceName);
|
||||
|
||||
OrderTypesProperty pAllowedOrderTypes = new OrderTypesProperty(this);
|
||||
pAllowedOrderTypes.setDescription(
|
||||
bundle.getString("vehicleModel.property_allowedOrderTypes.description")
|
||||
);
|
||||
pAllowedOrderTypes.setHelptext(
|
||||
bundle.getString("vehicleModel.property_allowedOrderTypes.helptext")
|
||||
);
|
||||
pAllowedOrderTypes.setModellingEditable(false);
|
||||
pAllowedOrderTypes.setOperatingEditable(true);
|
||||
setProperty(ALLOWED_ORDER_TYPES, pAllowedOrderTypes);
|
||||
|
||||
ResourceProperty allocatedResources = new ResourceProperty(this);
|
||||
allocatedResources.setDescription(
|
||||
bundle.getString("vehicleModel.property_allocatedResources.description")
|
||||
);
|
||||
allocatedResources.setHelptext(
|
||||
bundle.getString("vehicleModel.property_allocatedResources.helptext")
|
||||
);
|
||||
allocatedResources.setModellingEditable(false);
|
||||
allocatedResources.setOperatingEditable(true);
|
||||
setProperty(ALLOCATED_RESOURCES, allocatedResources);
|
||||
|
||||
ResourceProperty claimedResources = new ResourceProperty(this);
|
||||
claimedResources.setDescription(
|
||||
bundle.getString("vehicleModel.property_claimedResources.description")
|
||||
);
|
||||
claimedResources.setHelptext(
|
||||
bundle.getString("vehicleModel.property_claimedResources.helptext")
|
||||
);
|
||||
claimedResources.setModellingEditable(false);
|
||||
claimedResources.setOperatingEditable(true);
|
||||
setProperty(CLAIMED_RESOURCES, claimedResources);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
# SPDX-FileCopyrightText: The openTCS Authors
|
||||
# SPDX-License-Identifier: CC-BY-4.0
|
||||
|
||||
blockModel.description=Block
|
||||
blockModel.property_color.description=Block color
|
||||
blockModel.property_color.helptext=Color of the block's elements
|
||||
blockModel.property_elements.description=Block members
|
||||
blockModel.property_elements.helptext=The members of this block
|
||||
blockModel.property_miscellaneous.description=Miscellaneous
|
||||
blockModel.property_miscellaneous.helptext=Miscellaneous properties of this block
|
||||
blockModel.property_name.description=Name
|
||||
blockModel.property_name.helptext=The name of this block
|
||||
blockModel.property_type.description=Type
|
||||
blockModel.property_type.helptext=The type of this block
|
||||
blockModel.type.sameDirectionOnly.description=Same direction only
|
||||
blockModel.type.singleVehicleOnly.description=Single vehicle only
|
||||
groupModel.description=Group
|
||||
groupModel.property_elements.description=Group members
|
||||
groupModel.property_miscellaneous.description=Miscellaneous
|
||||
groupModel.property_miscellaneous.helptext=Miscellaneous properties of this group
|
||||
groupModel.property_name.description=Name
|
||||
groupModel.property_name.helptext=The name of this group
|
||||
layoutModel.description=Layout
|
||||
layoutModel.property_layerGroups.description=Layer groups
|
||||
layoutModel.property_layerGroups.helptext=The layer groups of the model.
|
||||
layoutModel.property_layerWrappers.description=Layers
|
||||
layoutModel.property_layerWrappers.helptext=The layers of the model.
|
||||
layoutModel.property_miscellaneous.description=Miscellaneous
|
||||
layoutModel.property_miscellaneous.helptext=All miscellaneous properties can be placed here
|
||||
layoutModel.property_name.description=Name
|
||||
layoutModel.property_name.helptext=The name of this layout
|
||||
layoutModel.property_scaleX.description=Scale of x-axis
|
||||
layoutModel.property_scaleX.helptext=Length per pixel in x direction
|
||||
layoutModel.property_scaleY.description=Scale of y-axis
|
||||
layoutModel.property_scaleY.helptext=Length per pixel in y direction
|
||||
layoutModel.treeViewName=Layout
|
||||
linkModel.description=Link
|
||||
linkModel.property_endComponent.description=End Component
|
||||
linkModel.property_layerWrapper.description=Layer
|
||||
linkModel.property_layerWrapper.helptext=The layer on which the point is drawn.
|
||||
linkModel.property_name.description=Name
|
||||
linkModel.property_name.helptext=Name of the link
|
||||
linkModel.property_operations.description=Actions
|
||||
linkModel.property_operations.helptext=Action ...
|
||||
linkModel.property_startComponent.description=Start Component
|
||||
locationModel.description=Location
|
||||
locationModel.property_labelOffsetX.description=Label x offset
|
||||
locationModel.property_labelOffsetX.helptext=X offset of the location's Label
|
||||
locationModel.property_labelOffsetY.description=Label y offset
|
||||
locationModel.property_labelOffsetY.helptext=Y offset of the location's Label
|
||||
locationModel.property_labelOrientationAngle.description=Label orientation angle
|
||||
locationModel.property_labelOrientationAngle.helptext=Angle orientation of the location's Label
|
||||
locationModel.property_layerWrapper.description=Layer
|
||||
locationModel.property_layerWrapper.helptext=The layer on which the location is drawn.
|
||||
locationModel.property_locked.description=Locked
|
||||
locationModel.property_locked.helptext=Indicates whether the location is locked and therefore cannot be used by vehicles.
|
||||
locationModel.property_miscellaneous.description=Miscellaneous
|
||||
locationModel.property_miscellaneous.helptext=Miscelleneous properties of this location
|
||||
locationModel.property_modelPositionX.description=x-Position (model)
|
||||
locationModel.property_modelPositionX.helptext=The x coordinate of the location in the kernel model
|
||||
locationModel.property_modelPositionY.description=y-Position (model)
|
||||
locationModel.property_modelPositionY.helptext=The y coordinate of the location in the kernel model
|
||||
locationModel.property_name.description=Name
|
||||
locationModel.property_name.helptext=The name of this location
|
||||
locationModel.property_peripheralJob.description=Peripheral job
|
||||
locationModel.property_peripheralJob.helptext=The current peripheral job
|
||||
locationModel.property_peripheralReservationToken.description=Reservation token
|
||||
locationModel.property_peripheralReservationToken.helptext=The reservation token for this location
|
||||
locationModel.property_peripheralState.description=Peripheral state
|
||||
locationModel.property_peripheralState.helptext=The current state of the peripheral
|
||||
locationModel.property_peripheralProcState.description=Processing state
|
||||
locationModel.property_peripheralProcState.helptext=The current processing state for this peripheral
|
||||
locationModel.property_positionX.description=Location x position
|
||||
locationModel.property_positionX.helptext=X coordinate of the location
|
||||
locationModel.property_positionY.description=Location y position
|
||||
locationModel.property_positionY.helptext=Y coordinate of the location
|
||||
locationModel.property_symbol.description=Symbol
|
||||
locationModel.property_symbol.helptext=The graphical symbol for this location
|
||||
locationModel.property_type.description=Type
|
||||
locationModel.property_type.helptext=The type of this location
|
||||
locationTypeModel.description=Location type
|
||||
locationTypeModel.property_allowedOperations.description=Supported vehicle operations
|
||||
locationTypeModel.property_allowedOperations.helptext=The actions that are allowed at locations of this type
|
||||
locationTypeModel.property_allowedPeripheralOperations.description=Supported peripheral operations
|
||||
locationTypeModel.property_allowedPeripheralOperations.helptext=The peripheral operations that are allowed at locations of this type
|
||||
locationTypeModel.property_miscellaneous.description=Miscellaneous
|
||||
locationTypeModel.property_miscellaneous.helptext=All miscellaneous properties can be placed here
|
||||
locationTypeModel.property_name.description=Name
|
||||
locationTypeModel.property_name.helptext=The description of the location type
|
||||
locationTypeModel.property_symbol.description=Symbol
|
||||
locationTypeModel.property_symbol.helptext=The graphical symbol for locations of this type
|
||||
multipleDifferentValues.description=<Different Values>
|
||||
multipleDifferentValues.helptext=This value is not uniform. Changes will be applied to all selected objects.
|
||||
otherGraphicalElement.description=Graphical Object
|
||||
pathModel.description=Path
|
||||
pathModel.property_endComponent.description=End Component
|
||||
pathModel.property_layerWrapper.description=Layer
|
||||
pathModel.property_layerWrapper.helptext=The layer on which the path is drawn.
|
||||
pathModel.property_length.description=Length
|
||||
pathModel.property_length.helptext=The length of this path in the kernel model
|
||||
pathModel.property_locked.description=Locked
|
||||
pathModel.property_locked.helptext=Shows if an element is locked and therefore cannot be used by vehicles.
|
||||
pathModel.property_maximumReverseVelocity.description=Maxmimum reverse velocity
|
||||
pathModel.property_maximumReverseVelocity.helptext=The maximum reverse velocity vehicles are allow to drive on this course segment.
|
||||
pathModel.property_maximumVelocity.description=Maximum velocity
|
||||
pathModel.property_maximumVelocity.helptext=The maximum velocity vehicles are allow to drive on this course segment.
|
||||
pathModel.property_miscellaneous.description=Miscellaneous
|
||||
pathModel.property_miscellaneous.helptext=All miscellaneous properties can of the course can be placed here
|
||||
pathModel.property_name.description=Name
|
||||
pathModel.property_name.helptext=The name of this path segment
|
||||
pathModel.property_pathConnectionType.description=Path connection type
|
||||
pathModel.property_pathConnectionType.helptext=Connection type of this path
|
||||
pathModel.property_pathControlPoints.description=Path control points
|
||||
pathModel.property_pathControlPoints.helptext=Bezier control points of this path
|
||||
pathModel.property_peripheralOperations.description=Peripheral operations
|
||||
pathModel.property_peripheralOperations.helptext=The peripheral operations that are to be executed at this path.
|
||||
pathModel.property_startComponent.description=Start Component
|
||||
pathModel.property_vehicleEnvelopes.description=Vehicle envelopes
|
||||
pathModel.property_vehicleEnvelopes.helptext=The vehicle envelopes for this path
|
||||
pathModel.type.bezier.description=2-Bezier
|
||||
pathModel.type.bezier.helptext=Creates a bezier path with two control points
|
||||
pathModel.type.bezier3.description=3-Bezier
|
||||
pathModel.type.bezier3.helptext=Creates a bezier path with three control points
|
||||
pathModel.type.direct.description=Direct
|
||||
pathModel.type.direct.helptext=Creates a direct path
|
||||
pathModel.type.elbow.description=Elbow
|
||||
pathModel.type.elbow.helptext=Creates an elbow path
|
||||
pathModel.type.polypath.description=Poly-Path
|
||||
pathModel.type.polypath.helptext=Creates a path with multiple conrol points. ('CTRL+double click' adds a control point, 'CTRL+ALT+double click' removes a control point)
|
||||
pathModel.type.slanted.description=Slanted
|
||||
pathModel.type.slanted.helptext=Creates a slanted path
|
||||
pointModel.description=Point
|
||||
pointModel.property_angle.description=Angle
|
||||
pointModel.property_angle.helptext=The angle orientation of a vehicle on this point
|
||||
pointModel.property_labelOffsetX.description=Label x offset
|
||||
pointModel.property_labelOffsetX.helptext=X offset of the point's label
|
||||
pointModel.property_labelOffsetY.description=Label y offset
|
||||
pointModel.property_labelOffsetY.helptext=Y offset of the point's label
|
||||
pointModel.property_labelOrientationAngle.description=Label orientation angle
|
||||
pointModel.property_labelOrientationAngle.helptext=Angle orientation of the point's Label
|
||||
pointModel.property_layerWrapper.description=Layer
|
||||
pointModel.property_layerWrapper.helptext=The layer on which the point is drawn.
|
||||
pointModel.property_maxVehicleBoundingBox.description=Maximum vehicle bounding box
|
||||
pointModel.property_maxVehicleBoundingBox.helptext=The maximum bounding box that a vehicle at this point is allowed to have
|
||||
pointModel.property_miscellaneous.description=Miscellaneous
|
||||
pointModel.property_miscellaneous.helptext=All miscellaneous properties of the point can be placed here
|
||||
pointModel.property_modelPositionX.description=x-position (model)
|
||||
pointModel.property_modelPositionX.helptext=The x coordinate of the point in the kernel model
|
||||
pointModel.property_modelPositionY.description=y-position (model)
|
||||
pointModel.property_modelPositionY.helptext=The y coordinate of the point in the kernel model
|
||||
pointModel.property_name.description=Name
|
||||
pointModel.property_name.helptext=The description of the point
|
||||
pointModel.property_positionX.description=Point x position
|
||||
pointModel.property_positionX.helptext=X coordinate of the point
|
||||
pointModel.property_positionY.description=Point y position
|
||||
pointModel.property_positionY.helptext=Y coordinate of the point
|
||||
pointModel.property_type.description=Type
|
||||
pointModel.property_type.helptext=The type of the point
|
||||
pointModel.property_vehicleEnvelopes.description=Vehicle envelopes
|
||||
pointModel.property_vehicleEnvelopes.helptext=The vehicle envelopes for this point
|
||||
pointModel.type.halt.description=Halt point
|
||||
pointModel.type.halt.helptext=Creates a point where a vehicle can stop
|
||||
pointModel.type.park.description=Park point
|
||||
pointModel.type.park.helptext=Creates a point where a vehicle can park
|
||||
propertiesCollection.description=Multiple objects selected
|
||||
vehicleModel.description=Vehicle
|
||||
vehicleModel.property_allocatedResources.description=Allocated resources
|
||||
vehicleModel.property_allocatedResources.helptext=Resources allocated by this vehicle
|
||||
vehicleModel.property_allowedOrderTypes.description=Allowed order types
|
||||
vehicleModel.property_allowedOrderTypes.helptext=The types of transport orders the vehicle is allowed to process
|
||||
vehicleModel.property_boundingBox.description=Bounding box
|
||||
vehicleModel.property_boundingBox.helptext=The vehicle's bounding box
|
||||
vehicleModel.property_claimedResources.description=Claimed resources
|
||||
vehicleModel.property_claimedResources.helptext=Resources claimed by this vehicle
|
||||
vehicleModel.property_currentOrderSequence.description=Current order sequence
|
||||
vehicleModel.property_currentOrderSequence.helptext=Current order sequence
|
||||
vehicleModel.property_currentPoint.description=Current point
|
||||
vehicleModel.property_currentPoint.helptext=Current point reported by the kernel
|
||||
vehicleModel.property_currentTransportOrder.description=Current transport order
|
||||
vehicleModel.property_currentTransportOrder.helptext=Current transport order
|
||||
vehicleModel.property_energyLevel.description=Current energy level
|
||||
vehicleModel.property_energyLevel.helptext=Current energy level reported by the kernel
|
||||
vehicleModel.property_energyLevelThresholdSet.description= Energy level threshold set
|
||||
vehicleModel.property_energyLevelThresholdSet.helptext= Energy level threshold set
|
||||
vehicleModel.property_envelopeKey.description=Envelope key
|
||||
vehicleModel.property_envelopeKey.helptext=The vehicle's envelope key
|
||||
vehicleModel.property_integrationLevel.description=Integration level
|
||||
vehicleModel.property_integrationLevel.helptext=The vehicle's integration level
|
||||
vehicleModel.property_loaded.description=Loaded
|
||||
vehicleModel.property_loaded.helptext=Displays if this vehicle has accepted load.
|
||||
vehicleModel.property_maximumReverseVelocity.description=Maximum reverse velocity
|
||||
vehicleModel.property_maximumReverseVelocity.helptext =The maximum reverse velocity of the vehicle
|
||||
vehicleModel.property_maximumVelocity.description=Maximum velocity
|
||||
vehicleModel.property_maximumVelocity.helptext =The maximum forward velocity of the vehicle
|
||||
vehicleModel.property_miscellaneous.description=Miscellaneous
|
||||
vehicleModel.property_miscellaneous.helptext=Miscellaneous properties of the vehicle.
|
||||
vehicleModel.property_name.description=Name
|
||||
vehicleModel.property_name.helptext=The name of the vehicle
|
||||
vehicleModel.property_nextPoint.description=Next point
|
||||
vehicleModel.property_nextPoint.helptext=Next point reported by the kernel
|
||||
vehicleModel.property_orientationAngle.description=Vehicle orientation
|
||||
vehicleModel.property_orientationAngle.helptext=Vehicle orientation reported by the kernel
|
||||
vehicleModel.property_paused.description=Paused
|
||||
vehicleModel.property_paused.helptext=Indicates whether the vehicle is paused.
|
||||
vehicleModel.property_precisePosition.description=Exact position
|
||||
vehicleModel.property_precisePosition.helptext=Exact position reported by the kernel
|
||||
vehicleModel.property_processingState.description=Processing state
|
||||
vehicleModel.property_processingState.helptext=Processing state reported by the kernel
|
||||
vehicleModel.property_routeColor.description=Route color
|
||||
vehicleModel.property_routeColor.helptext=The color the vehicle routes are emphasised
|
||||
vehicleModel.property_state.description=State
|
||||
vehicleModel.property_state.helptext=State reported by the kernel
|
||||
@@ -0,0 +1,211 @@
|
||||
# SPDX-FileCopyrightText: The openTCS Authors
|
||||
# SPDX-License-Identifier: CC-BY-4.0
|
||||
|
||||
blockModel.description=Block
|
||||
blockModel.property_color.description=Farbe
|
||||
blockModel.property_color.helptext=Die Farbe, in der die Elemente des Blockbereichs dargestellt werden
|
||||
blockModel.property_elements.description=Block Elemente
|
||||
blockModel.property_elements.helptext=Die Mitglieder dieses Blocks
|
||||
blockModel.property_miscellaneous.description=Die \u00dcbrigen
|
||||
blockModel.property_miscellaneous.helptext=Die \u00dcbrigen Eigenschaften dieses Blocks
|
||||
blockModel.property_name.description=Name
|
||||
blockModel.property_name.helptext=Der Name dieses Blocks
|
||||
blockModel.property_type.description=Typ
|
||||
blockModel.property_type.helptext=Der Typ dieses Blocks
|
||||
blockModel.type.sameDirectionOnly.description=Nur selbe Richtung
|
||||
blockModel.type.singleVehicleOnly.description=Nur ein Fahrzeug
|
||||
groupModel.description=Gruppe
|
||||
groupModel.property_elements.description=Gruppenmitglieder
|
||||
groupModel.property_miscellaneous.description=Sonstiges
|
||||
groupModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften der Gruppe eingetragen werden
|
||||
groupModel.property_name.description=Gruppe
|
||||
groupModel.property_name.helptext=Die Bezeichnung der Gruppe
|
||||
layoutModel.description=Layout
|
||||
layoutModel.property_layerGroups.description=Ebenengruppen
|
||||
layoutModel.property_layerGroups.helptext=Die Ebenengruppen des Modells.
|
||||
layoutModel.property_layerWrappers.description=Ebenen
|
||||
layoutModel.property_layerWrappers.helptext=Die Ebenen des Modells.
|
||||
layoutModel.property_miscellaneous.description=Sonstiges
|
||||
layoutModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften des Layouts eingetragen werden
|
||||
layoutModel.property_name.description=Name
|
||||
layoutModel.property_name.helptext=Die Bezeichnung des Layouts
|
||||
layoutModel.property_scaleX.description=Ma\u00dfstab x-Achse
|
||||
layoutModel.property_scaleX.helptext=L\u00e4nge pro Pixel in Richtung der x-Achse
|
||||
layoutModel.property_scaleY.description=Ma\u00dfstab y-Achse
|
||||
layoutModel.property_scaleY.helptext=L\u00e4nge pro Pixel in Richtung der y-Achse
|
||||
layoutModel.treeViewName=Layout
|
||||
linkModel.description=Link
|
||||
linkModel.property_endComponent.description=Endkomponente
|
||||
linkModel.property_layerWrapper.description=Ebene
|
||||
linkModel.property_layerWrapper.helptext=Die Ebene, auf welcher der Link gezeichnet wird.
|
||||
linkModel.property_name.description=Name
|
||||
linkModel.property_name.helptext=Die Bezeichnung der Referenz
|
||||
linkModel.property_operations.description=Aktionen
|
||||
linkModel.property_operations.helptext=Die Aktion, die in Abh\u00e4ngigkeit vom Meldepunkt an der Station ausgef\u00fchrt werden kann.
|
||||
linkModel.property_startComponent.description=Startkomponente
|
||||
locationModel.description=Station
|
||||
locationModel.property_labelOffsetX.description=X Offset Beschriftung
|
||||
locationModel.property_labelOffsetX.helptext=X Offset der Beschriftung der Station
|
||||
locationModel.property_labelOffsetY.description=Y Offset Beschriftung
|
||||
locationModel.property_labelOffsetY.helptext=Y Offset der Beschriftung der Station
|
||||
locationModel.property_labelOrientationAngle.description=Winkelsausrichtung der Beschriftung
|
||||
locationModel.property_labelOrientationAngle.helptext=Winkelausrichtung der Stations-Beschriftung
|
||||
locationModel.property_layerWrapper.description=Ebene
|
||||
locationModel.property_layerWrapper.helptext=Die Ebene, auf welcher die Station gezeichnet wird.
|
||||
locationModel.property_locked.description=Gesperrt
|
||||
locationModel.property_locked.helptext=Zeigt an, ob die Station gesperrt ist und somit nicht von Fahrzeugen benutzt werden kann.
|
||||
locationModel.property_miscellaneous.description=Sonstiges
|
||||
locationModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften der Station eingetragen werden
|
||||
locationModel.property_modelPositionX.description=x-Position (Modell)
|
||||
locationModel.property_modelPositionX.helptext=Die x-Koordinate der Station im Kernel-Modell
|
||||
locationModel.property_modelPositionY.description=y-Position (Modell)
|
||||
locationModel.property_modelPositionY.helptext=Die y-Koordinate der Station im Kernel-Modell
|
||||
locationModel.property_name.description=Name
|
||||
locationModel.property_name.helptext=Die Bezeichnung der Station
|
||||
locationModel.property_peripheralJob.description=Peripherieauftrag
|
||||
locationModel.property_peripheralJob.helptext=Der Peripherieauftrag der zurzeit ausgef\u00fchrt wird
|
||||
locationModel.property_peripheralReservationToken.description=Reservierungstoken
|
||||
locationModel.property_peripheralReservationToken.helptext=Der Reservierungstoken f\u00fcr diese Station
|
||||
locationModel.property_peripheralState.description=Peripheriestatus
|
||||
locationModel.property_peripheralState.helptext=Der Status dieser Peripherie
|
||||
locationModel.property_peripheralProcState.description=Ausf\u00fchrungsstatus
|
||||
locationModel.property_peripheralProcState.helptext=Der Ausf\u00fchrungsstatus dieser Peripherie
|
||||
locationModel.property_positionX.description=x-Position (Layout)
|
||||
locationModel.property_positionX.helptext=Die x-Koordinate der Station im Layout
|
||||
locationModel.property_positionY.description=y-Position (Layout)
|
||||
locationModel.property_positionY.helptext=Die y-Koordinate der Station im Layout
|
||||
locationModel.property_symbol.description=Symbol
|
||||
locationModel.property_symbol.helptext=Das grafische Symbol f\u00fcr diese Station
|
||||
locationModel.property_type.description=Typ
|
||||
locationModel.property_type.helptext=Der Typ der Station
|
||||
locationTypeModel.description=Stationstyp
|
||||
locationTypeModel.property_allowedOperations.description=Unterst\u00fctzte Fahrzeugoperationen
|
||||
locationTypeModel.property_allowedOperations.helptext=Die Aktionen, die an Stationen dieses Typs ausgef\u00fchrt werden k\u00f6nnen
|
||||
locationTypeModel.property_allowedPeripheralOperations.description=Unterst\u00fctzte Peripherieoperationen
|
||||
locationTypeModel.property_allowedPeripheralOperations.helptext=Die Peripherieoperationen, die an Stationen dieses Typs ausgef\u00fchrt werden k\u00f6nnen
|
||||
locationTypeModel.property_miscellaneous.description=Sonstiges
|
||||
locationTypeModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften des Stationstyps eingetragen werden
|
||||
locationTypeModel.property_name.description=Name
|
||||
locationTypeModel.property_name.helptext=Die Bezeichnung des Stationstyps
|
||||
locationTypeModel.property_symbol.description=Symbol
|
||||
locationTypeModel.property_symbol.helptext=Das grafische Symbol f\u00fcr Stationen dieses Typs
|
||||
multipleDifferentValues.description=<Unterschiedliche Werte>
|
||||
multipleDifferentValues.helptext=Dieser Wert ist nicht einheitlich. \u00c4nderungen werden auf alle selektieren Objekte angewandt.
|
||||
otherGraphicalElement.description=Grafisches Objekt
|
||||
pathModel.description=Strecke
|
||||
pathModel.property_endComponent.description=Endkomponente
|
||||
pathModel.property_layerWrapper.description=Ebene
|
||||
pathModel.property_layerWrapper.helptext=Die Ebene, auf welcher der Pfad gezeichnet wird.
|
||||
pathModel.property_length.description=L\u00e4nge
|
||||
pathModel.property_length.helptext=Die L\u00e4nge des Streckensegments im Kernel-Modell
|
||||
pathModel.property_locked.description=Gesperrt
|
||||
pathModel.property_locked.helptext=Zeigt an, ob das Steckensegment gesperrt ist und somit nicht von Fahrzeugen benutzt werden kann.
|
||||
pathModel.property_maximumReverseVelocity.description=H\u00f6chstgeschwindigkeit r\u00fcckw\u00e4rts
|
||||
pathModel.property_maximumReverseVelocity.helptext=Die H\u00f6chstgeschwindigkeit, mit der Fahrzeuge auf diesem Streckensegment r\u00fcckw\u00e4rts unterwegs sein d\u00fcrfen.
|
||||
pathModel.property_maximumVelocity.description=H\u00f6chstgeschwindigkeit vorw\u00e4rts
|
||||
pathModel.property_maximumVelocity.helptext=Die H\u00f6chstgeschwindigkeit, mit der Fahrzeuge auf diesem Streckensegment vorw\u00e4rts unterwegs sein d\u00fcrfen.
|
||||
pathModel.property_miscellaneous.description=Sonstiges
|
||||
pathModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften der Strecke eingetragen werden
|
||||
pathModel.property_name.description=Name
|
||||
pathModel.property_name.helptext=Die Bezeichnung des Streckensegments
|
||||
pathModel.property_pathConnectionType.description=Verbinder-Typ
|
||||
pathModel.property_pathConnectionType.helptext=Die Art der Verbinder-Linie
|
||||
pathModel.property_pathControlPoints.description=Kontrollpunkte
|
||||
pathModel.property_pathControlPoints.helptext=2 Kontrollpunkte (nur f\u00fcr Bezier-Verbinder)
|
||||
pathModel.property_peripheralOperations.description=Peripherieoperationen
|
||||
pathModel.property_peripheralOperations.helptext=Die Peripherieoperationen die auf diesem Pfad ausgef\u00fchrt werden.
|
||||
pathModel.property_startComponent.description=Startkomponente
|
||||
pathModel.property_vehicleEnvelopes.description=Fahrzeugh\u00fcllkurven
|
||||
pathModel.property_vehicleEnvelopes.helptext=Die H\u00fcllkurven von Fahrzeugen auf diesem Pfad
|
||||
pathModel.type.bezier.description=2-Bezier
|
||||
pathModel.type.bezier.helptext=Erstellt einen Bezier-Pfad mit zwei Kontrollpunkten
|
||||
pathModel.type.bezier3.description=3-Bezier
|
||||
pathModel.type.bezier3.helptext=Erstellt einen Bezier-Pfad mit drei Kontrollpunkten
|
||||
pathModel.type.direct.description=Direkt
|
||||
pathModel.type.direct.helptext=Erstellt eine direkte Verbindung
|
||||
pathModel.type.elbow.description=Abgewinkelt
|
||||
pathModel.type.elbow.helptext=Erstellt eine abgewinkelte Verbindung
|
||||
pathModel.type.polypath.helptext=Erstellt eine Pfad mit mehreren Kontrollpunkten.('STRG+Doppelklick' erstellt einen Kontrollpuntk, 'STRG+ALT+Doppelklick' l\u00f6scht einen Kontrollpuntk)
|
||||
pathModel.type.slanted.description=Abgeschr\u00e4gt
|
||||
pathModel.type.slanted.helptext=Erstellt eine abgeschr\\u00e4gte Verbindung
|
||||
pointModel.description=Punkt
|
||||
pointModel.property_angle.description=Winkel
|
||||
pointModel.property_angle.helptext=Die Winkelausrichtung eines Fahrzeugs auf diesem Punkt
|
||||
pointModel.property_labelOffsetX.description=X Offset Beschriftung
|
||||
pointModel.property_labelOffsetX.helptext=X Offset der Beschriftung des Punktes
|
||||
pointModel.property_labelOffsetY.description=Y Offset Beschriftung
|
||||
pointModel.property_labelOffsetY.helptext=Y Offset der Beschriftung des Punktes
|
||||
pointModel.property_labelOrientationAngle.description=Winkelausrichtung der Beschriftung
|
||||
pointModel.property_labelOrientationAngle.helptext=Winkelausrichtung der Beschriftung des Punktes
|
||||
pointModel.property_layerWrapper.description=Ebene
|
||||
pointModel.property_layerWrapper.helptext=Die Ebene, auf welcher der Punkt gezeichnet wird.
|
||||
pointModel.property_maxVehicleBoundingBox.description=Maximale Fahrzeug-Bounding-Box
|
||||
pointModel.property_maxVehicleBoundingBox.helptext=Die maximale Bounding-Box, die ein Fahrzeug an diesem Punkt haben darf
|
||||
pointModel.property_miscellaneous.description=Sonstiges
|
||||
pointModel.property_miscellaneous.helptext=Hier k\u00f6nnen alle sonstigen Eigenschaften des Punktes eingetragen werden
|
||||
pointModel.property_modelPositionX.description=x-Position (Modell)
|
||||
pointModel.property_modelPositionX.helptext=Die x-Koordinate des Punktes im Kernel-Modell
|
||||
pointModel.property_modelPositionY.description=y-Position (Modell)
|
||||
pointModel.property_modelPositionY.helptext=Die y-Koordinate des Punktes im Kernel-Modell
|
||||
pointModel.property_name.description=Name
|
||||
pointModel.property_name.helptext=Die Bezeichnung des Punktes
|
||||
pointModel.property_positionX.description=x-Position (Layout)
|
||||
pointModel.property_positionX.helptext=Die x-Koordinate des Punktes im Layout
|
||||
pointModel.property_positionY.description=y-Position (Layout)
|
||||
pointModel.property_positionY.helptext=Die y-Koordinate des Punktes im Layout
|
||||
pointModel.property_type.description=Typ
|
||||
pointModel.property_type.helptext=Der Typ des Punktes
|
||||
pointModel.property_vehicleEnvelopes.description=Fahrzeugh\u00fcllkurven
|
||||
pointModel.property_vehicleEnvelopes.helptext=Die H\u00fcllkurven von Fahrzeugen an diesem Punkt
|
||||
pointModel.type.halt.description=Haltepunkt
|
||||
pointModel.type.halt.helptext=Erstellt ein Punkt an dem ein Fahrzeug stoppen kann
|
||||
pointModel.type.park.description=Parkposition
|
||||
pointModel.type.park.helptext=Erstellt einen Punkt wo ein Fahrzeug parken kann
|
||||
propertiesCollection.description=Mehrere Objekte ausgew\u00e4hlt
|
||||
vehicleModel.description=Fahrzeug
|
||||
vehicleModel.property_allocatedResources.description=Zugewiesene Ressourcen
|
||||
vehicleModel.property_allocatedResources.helptext=Ressourcen die zu diesem Fahrzeug zugewiesen sind
|
||||
vehicleModel.property_allowedOrderTypes.description=Erlaubte Auftragstypen
|
||||
vehicleModel.property_allowedOrderTypes.helptext=Typen von Transportauftr\u00e4gen die das Fahrzeug ausf\u00fchren darf
|
||||
vehicleModel.property_boundingBox.description=Bounding-Box
|
||||
vehicleModel.property_boundingBox.helptext=Die Bounding-Box des Fahrzeugs
|
||||
vehicleModel.property_claimedResources.description=Beanspruchte Ressourcen
|
||||
vehicleModel.property_claimedResources.helptext=Ressourcen die von diesem Fahrzeug beansprucht sind
|
||||
vehicleModel.property_currentOrderSequence.description=Aktuelle Auftragssequenz
|
||||
vehicleModel.property_currentOrderSequence.helptext=Aktuelle Auftragssequenz
|
||||
vehicleModel.property_currentPoint.description=Aktueller Punkt
|
||||
vehicleModel.property_currentPoint.helptext=Vom Kernel gemeldeter aktueller Punkt
|
||||
vehicleModel.property_currentTransportOrder.description=Aktueller Transportauftrag
|
||||
vehicleModel.property_currentTransportOrder.helptext=Aktueller Transportauftrag
|
||||
vehicleModel.property_energyLevel.description=Aktueller Ladezustand
|
||||
vehicleModel.property_energyLevel.helptext=Vom Kernel gemeldeter aktueller Ladezustand
|
||||
vehicleModel.property_energyLevelThresholdSet.description= Energieschwellwerte
|
||||
vehicleModel.property_energyLevelThresholdSet.helptext= Energieschwellwerte
|
||||
vehicleModel.property_envelopeKey.description=H\u00fcllkurvenschl\u00fcssel
|
||||
vehicleModel.property_envelopeKey.helptext=Der H\u00fcllkurvenschl\u00fcssel des Fahrzeugs
|
||||
vehicleModel.property_integrationLevel.description=Integrationsstufe
|
||||
vehicleModel.property_integrationLevel.helptext=Die Integrationsstufe des Fahrzeugs
|
||||
vehicleModel.property_loaded.description=Beladen
|
||||
vehicleModel.property_loaded.helptext=Zeigt an, ob das Fahrzeug eine Last aufgenommen hat.
|
||||
vehicleModel.property_maximumReverseVelocity.description=Maximale r\u00fcckw\u00e4rts Geschwindigkeit
|
||||
vehicleModel.property_maximumReverseVelocity.helptext =Die maximale Geschwindigkeit mit der das Fahrzeug r\u00fcckw\u00e4rts fahren kann.
|
||||
vehicleModel.property_maximumVelocity.description=Maximale Geschwindigkeit
|
||||
vehicleModel.property_maximumVelocity.helptext =Die maximale Geschwindigkeit mit der das Fahrzeug vorw\u00e4rts fahren kann.
|
||||
vehicleModel.property_miscellaneous.description=Sonstiges
|
||||
vehicleModel.property_miscellaneous.helptext=Sonstige Attribute des Fahrzeugs
|
||||
vehicleModel.property_name.description=Name
|
||||
vehicleModel.property_name.helptext=Die Bezeichnung des Fahrzeugs
|
||||
vehicleModel.property_nextPoint.description=N\u00e4chster Punkt
|
||||
vehicleModel.property_nextPoint.helptext=Vom Kernel gemeldeter n\u00e4chster Punkt
|
||||
vehicleModel.property_orientationAngle.description=Fahrzeugausrichtung
|
||||
vehicleModel.property_orientationAngle.helptext=Vom Kernel gemeldete Fahrzeugausrichtung
|
||||
vehicleModel.property_paused.description=Pausiert
|
||||
vehicleModel.property_paused.helptext=Zeigt, ob das Fahrzeug pausiert ist.
|
||||
vehicleModel.property_precisePosition.description=Exakte Position
|
||||
vehicleModel.property_precisePosition.helptext=Vom Kernel gemeldete exakte Position
|
||||
vehicleModel.property_processingState.description=Bearbeitungszustand
|
||||
vehicleModel.property_processingState.helptext=Vom Kernel gemeldeter Bearbeitungszustand
|
||||
vehicleModel.property_routeColor.description=Routenfarbe
|
||||
vehicleModel.property_routeColor.helptext=Die Farbe in der abzufahrende Routen dargestellt werden
|
||||
vehicleModel.property_state.description=Zustand
|
||||
vehicleModel.property_state.helptext=Vom Kernel gemeldeter Zustand
|
||||
@@ -0,0 +1,73 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.opentcs.guing.base.components.properties.type.AngleProperty.Unit;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* A test for an angle property.
|
||||
* For Degrees, min value is 0 and max value is 360.
|
||||
* For Radians, min value is 0 and max value is 2*PI ~ 6.283185
|
||||
*/
|
||||
class AnglePropertyTest {
|
||||
|
||||
private AngleProperty property;
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"deg", "rad"})
|
||||
void testValidUnits(String unit) {
|
||||
property = new AngleProperty(new DummyComponent());
|
||||
assertTrue(property.isPossibleUnit(unit));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertyConversionDegToRad() {
|
||||
// 180 deg = PI rad
|
||||
property = new AngleProperty(new DummyComponent(), 180, Unit.DEG);
|
||||
property.convertTo(Unit.RAD);
|
||||
assertEquals(Math.PI, (double) property.getValue(), 0);
|
||||
assertEquals(Unit.RAD, property.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertyConversionRadToDeg() {
|
||||
// 3.7168 rad ~ 212.96 deg
|
||||
property = new AngleProperty(new DummyComponent(), 3.7168, Unit.RAD);
|
||||
property.convertTo(Unit.DEG);
|
||||
assertEquals(212.96, (double) property.getValue(), 0.01);
|
||||
assertEquals(Unit.DEG, property.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertyRange() {
|
||||
property = new AngleProperty(new DummyComponent());
|
||||
assertEquals(0, property.getValidRange().getMin(), 0);
|
||||
assertEquals(Double.MAX_VALUE, property.getValidRange().getMax(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldStayInRangeDeg() {
|
||||
property = new AngleProperty(new DummyComponent(), 540, Unit.DEG);
|
||||
assertEquals(180.0, property.getValue());
|
||||
assertEquals(Unit.DEG, property.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldStayInRangeRad() {
|
||||
property = new AngleProperty(new DummyComponent(), 10, Unit.RAD);
|
||||
assertEquals(3.716, (double) property.getValue(), 0.001);
|
||||
assertEquals(AngleProperty.Unit.RAD, property.getUnit());
|
||||
}
|
||||
|
||||
private class DummyComponent
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty.Unit;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* A test for a length property.
|
||||
*/
|
||||
class LengthPropertyTest {
|
||||
|
||||
private LengthProperty property;
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"mm", "cm", "m", "km"})
|
||||
void testValidUnits(String unit) {
|
||||
property = new LengthProperty(new DummyComponent());
|
||||
assertTrue(property.isPossibleUnit(unit));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("paramsFactory")
|
||||
void testPropertyConversion(Unit unit, Object result) {
|
||||
property = new LengthProperty(new DummyComponent(), 10, Unit.CM);
|
||||
property.convertTo(unit);
|
||||
assertEquals(result, property.getValue());
|
||||
assertEquals(unit, property.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertyRange() {
|
||||
property = new LengthProperty(new DummyComponent());
|
||||
assertEquals(0, property.getValidRange().getMin(), 0);
|
||||
assertEquals(Double.MAX_VALUE, property.getValidRange().getMax(), 0);
|
||||
}
|
||||
|
||||
static Object[][] paramsFactory() {
|
||||
return new Object[][]{{Unit.MM, 100.0},
|
||||
{Unit.CM, 10.0},
|
||||
{Unit.M, 0.1},
|
||||
{Unit.KM, 0.0001}};
|
||||
}
|
||||
|
||||
private class DummyComponent
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* A test for a percent property.
|
||||
*/
|
||||
class PercentPropertyTest {
|
||||
|
||||
private PercentProperty property;
|
||||
|
||||
@Test
|
||||
void testPropertyRange() {
|
||||
property = new PercentProperty(new DummyComponent());
|
||||
assertEquals(0, property.getValidRange().getMin(), 0);
|
||||
assertEquals(100, property.getValidRange().getMax(), 0);
|
||||
}
|
||||
|
||||
private class DummyComponent
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.components.properties.type;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.opentcs.guing.base.components.properties.type.SpeedProperty.Unit;
|
||||
import org.opentcs.guing.base.model.AbstractModelComponent;
|
||||
|
||||
/**
|
||||
* A test for a speed property.
|
||||
*/
|
||||
class SpeedPropertyTest {
|
||||
|
||||
private SpeedProperty property;
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"mm/s", "m/s", "km/h"})
|
||||
void testValidUnits(String unit) {
|
||||
property = new SpeedProperty(new DummyComponent());
|
||||
assertTrue(property.isPossibleUnit(unit));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("paramsFactory")
|
||||
void testPropertyConversion(Unit unit, Object result) {
|
||||
property = new SpeedProperty(new DummyComponent(), 10000.0, Unit.MM_S);
|
||||
property.convertTo(unit);
|
||||
assertEquals(result, property.getValue());
|
||||
assertEquals(unit, property.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertyRange() {
|
||||
property = new SpeedProperty(new DummyComponent());
|
||||
assertEquals(0, property.getValidRange().getMin(), 0);
|
||||
assertEquals(Double.MAX_VALUE, property.getValidRange().getMax(), 0);
|
||||
}
|
||||
|
||||
static Object[][] paramsFactory() {
|
||||
return new Object[][]{{Unit.MM_S, 10000.0},
|
||||
{Unit.M_S, 10.0},
|
||||
{Unit.KM_H, 36.0}};
|
||||
}
|
||||
|
||||
private class DummyComponent
|
||||
extends
|
||||
AbstractModelComponent {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.aMapWithSize;
|
||||
import static org.hamcrest.Matchers.anEmptyMap;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty;
|
||||
import org.opentcs.guing.base.components.properties.type.SpeedProperty;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PathModel}.
|
||||
*/
|
||||
class PathModelTest {
|
||||
|
||||
private PathModel pathModel;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
pathModel = new PathModel();
|
||||
}
|
||||
|
||||
@Test
|
||||
void setLength() {
|
||||
pathModel.getPropertyLength().setValueAndUnit(4321.0, LengthProperty.Unit.MM);
|
||||
|
||||
assertThat(
|
||||
pathModel.getPropertyLength().getValueByUnit(LengthProperty.Unit.MM),
|
||||
is(4321.0)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setMaxVelocity() {
|
||||
pathModel.getPropertyMaxVelocity().setValueAndUnit(900.0, SpeedProperty.Unit.MM_S);
|
||||
|
||||
assertThat(
|
||||
pathModel.getPropertyMaxVelocity().getValueByUnit(SpeedProperty.Unit.MM_S),
|
||||
is(900.0)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setMaxReverseVelocity() {
|
||||
pathModel.getPropertyMaxReverseVelocity().setValueAndUnit(900.0, SpeedProperty.Unit.MM_S);
|
||||
|
||||
assertThat(
|
||||
pathModel.getPropertyMaxReverseVelocity().getValueByUnit(SpeedProperty.Unit.MM_S),
|
||||
is(900.0)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void manageVehicleModels() {
|
||||
assertThat(pathModel.getAllocationStates(), is(anEmptyMap()));
|
||||
|
||||
VehicleModel vehicleModel1 = new VehicleModel();
|
||||
vehicleModel1.setName("vehicle-1");
|
||||
VehicleModel vehicleModel2 = new VehicleModel();
|
||||
vehicleModel2.setName("vehicle-2");
|
||||
|
||||
pathModel.updateAllocationState(vehicleModel1, AllocationState.ALLOCATED);
|
||||
pathModel.updateAllocationState(vehicleModel2, AllocationState.CLAIMED);
|
||||
|
||||
assertThat(pathModel.getAllocationStates(), is(aMapWithSize(2)));
|
||||
Assertions.assertThat(pathModel.getAllocationStates())
|
||||
.contains(entry(vehicleModel1, AllocationState.ALLOCATED))
|
||||
.contains(entry(vehicleModel2, AllocationState.CLAIMED));
|
||||
|
||||
pathModel.clearAllocationState(vehicleModel1);
|
||||
|
||||
assertThat(pathModel.getAllocationStates(), is(aMapWithSize(1)));
|
||||
Assertions.assertThat(pathModel.getAllocationStates())
|
||||
.contains(entry(vehicleModel2, AllocationState.CLAIMED));
|
||||
}
|
||||
|
||||
@Test
|
||||
void manageBlockModels() {
|
||||
assertThat(pathModel.getBlockModels(), is(empty()));
|
||||
|
||||
BlockModel blockModel1 = new BlockModel();
|
||||
blockModel1.setName("block-1");
|
||||
BlockModel blockModel2 = new BlockModel();
|
||||
blockModel2.setName("block-2");
|
||||
|
||||
pathModel.addBlockModel(blockModel1);
|
||||
pathModel.addBlockModel(blockModel2);
|
||||
|
||||
assertThat(pathModel.getBlockModels(), hasSize(2));
|
||||
assertThat(pathModel.getBlockModels(), containsInAnyOrder(blockModel1, blockModel2));
|
||||
|
||||
pathModel.removeBlockModel(blockModel1);
|
||||
|
||||
assertThat(pathModel.getBlockModels(), hasSize(1));
|
||||
assertThat(pathModel.getBlockModels(), containsInAnyOrder(blockModel2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// SPDX-FileCopyrightText: The openTCS Authors
|
||||
// SPDX-License-Identifier: MIT
|
||||
package org.opentcs.guing.base.model.elements;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.aMapWithSize;
|
||||
import static org.hamcrest.Matchers.anEmptyMap;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opentcs.guing.base.AllocationState;
|
||||
import org.opentcs.guing.base.components.properties.type.LengthProperty;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PointModel}.
|
||||
*/
|
||||
class PointModelTest {
|
||||
|
||||
private PointModel pointModel;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
pointModel = new PointModel();
|
||||
}
|
||||
|
||||
@Test
|
||||
void setModelPositionX() {
|
||||
pointModel.getPropertyModelPositionX().setValueAndUnit(1234.0, LengthProperty.Unit.MM);
|
||||
|
||||
assertThat(
|
||||
pointModel.getPropertyModelPositionX().getValueByUnit(LengthProperty.Unit.MM),
|
||||
is(1234.0)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setModelPositionY() {
|
||||
pointModel.getPropertyModelPositionY().setValueAndUnit(1234.0, LengthProperty.Unit.MM);
|
||||
|
||||
assertThat(
|
||||
pointModel.getPropertyModelPositionY().getValueByUnit(LengthProperty.Unit.MM),
|
||||
is(1234.0)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void manageVehicleModels() {
|
||||
assertThat(pointModel.getAllocationStates(), is(anEmptyMap()));
|
||||
|
||||
VehicleModel vehicleModel1 = new VehicleModel();
|
||||
vehicleModel1.setName("vehicle-1");
|
||||
VehicleModel vehicleModel2 = new VehicleModel();
|
||||
vehicleModel2.setName("vehicle-2");
|
||||
|
||||
pointModel.updateAllocationState(vehicleModel1, AllocationState.ALLOCATED);
|
||||
pointModel.updateAllocationState(vehicleModel2, AllocationState.CLAIMED);
|
||||
|
||||
assertThat(pointModel.getAllocationStates(), is(aMapWithSize(2)));
|
||||
Assertions.assertThat(pointModel.getAllocationStates())
|
||||
.contains(entry(vehicleModel1, AllocationState.ALLOCATED))
|
||||
.contains(entry(vehicleModel2, AllocationState.CLAIMED));
|
||||
|
||||
pointModel.clearAllocationState(vehicleModel1);
|
||||
|
||||
assertThat(pointModel.getAllocationStates(), is(aMapWithSize(1)));
|
||||
Assertions.assertThat(pointModel.getAllocationStates())
|
||||
.contains(entry(vehicleModel2, AllocationState.CLAIMED));
|
||||
}
|
||||
|
||||
@Test
|
||||
void manageBlockModels() {
|
||||
assertThat(pointModel.getBlockModels(), is(empty()));
|
||||
|
||||
BlockModel blockModel1 = new BlockModel();
|
||||
blockModel1.setName("block-1");
|
||||
BlockModel blockModel2 = new BlockModel();
|
||||
blockModel2.setName("block-2");
|
||||
|
||||
pointModel.addBlockModel(blockModel1);
|
||||
pointModel.addBlockModel(blockModel2);
|
||||
|
||||
assertThat(pointModel.getBlockModels(), hasSize(2));
|
||||
assertThat(pointModel.getBlockModels(), containsInAnyOrder(blockModel1, blockModel2));
|
||||
|
||||
pointModel.removeBlockModel(blockModel1);
|
||||
|
||||
assertThat(pointModel.getBlockModels(), hasSize(1));
|
||||
assertThat(pointModel.getBlockModels(), containsInAnyOrder(blockModel2));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user