Interface ModelingLookAndFeel
public interface ModelingLookAndFeel
This interface can be implemented to allow some degree of control
of the behavior and "look" of models. This can be used as a complement
of DrawableFactory.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<T>
findPrio
(List<ModelingLookAndFeel> lafs, ModelType type, Function<ModelingLookAndFeel, T> mapper) Finds the look and feel that should have priority for the given model type and returns the result of mapping that look and feel to a T using the function mapper.getDefaultSize
(MTCompleteModel model, SymbolVariant variant) Optionally returns a default size for a vertex.default Optional<ModelFilter>
getFilter
(MTCompleteModel model) Returns an optional filter for content shown in a model.getMethodSupport
(MTCompleteModel model) Returns the method support for the model type or null if no method support is available.getPasteBounds
(MTCompleteModel sourceModel, MTCompleteVertex pastedVertex) If only vertices are pasted into a model the LAF can decide the bounds of the pasted vertices, to allow setting a default size not equal to the size in the source model.getPattern
(ModelType type, SymbolVariant start, SymbolVariant end) Returns a pattern of symbol variants or an empty list if no pattern exists.getPlaceAction
(MTCompleteVertex vertex) Returns a function that takes a vertex and initializes the vertex if needed.isLabelHideable
(MTCompleteVertex vertex) Return true if labels should be hideable, false if not, and null to let other LAF:s decide.isLabelVisible
(MTCompleteVertex vertex) Return true to show label, false to hide it and null to let other LAF:s decide.default Boolean
isMovable
(MTCompleteEdge edge) Return true to allow moving an edge, false to disable it.default Boolean
isMovable
(MTCompleteVertex vertex) Return true to allow moving a vertex, false to disable it.isSizeEditable
(MTCompleteVertex vertex) Return true to allow resizing of a vertex, false to disable it.boolean
supportsModel
(ModelType modelType) Returns true if this LAF should be applied to a given model type.
-
Method Details
-
findPrio
static <T> Optional<T> findPrio(List<ModelingLookAndFeel> lafs, ModelType type, Function<ModelingLookAndFeel, T> mapper) Finds the look and feel that should have priority for the given model type and returns the result of mapping that look and feel to a T using the function mapper. This is useful for example to get the default size of a vertex in a given model, e.g:MTCompleteVertex vertex = ...someVertex...; MTCompleteModel model = vertex.getModel(); SymbolVariant variant = vertex.getSymbol().getVariant(); ModelType modelTyp = model.getType(); ModelingLookAndFeel.findPrio(allLafsInSystem, type, laf -> laf.getDefaultSize(model, variant)) .orElse(variant.getDefaultSize());
- Type Parameters:
T
- The type captured by the optional and the return type of the mapper.- Parameters:
lafs
- A list of ModelingLookAndFeels to find the prioritised laf in.type
- The type of model to find the priority laf for.mapper
- The mapping function to apply to the priority laf (will potentially be applied to ALL lafs in lafs).- Returns:
- An optional containing the result of applying the mapper to the prioritised laf or an empty optional if no prioritised laf is found.
-
getPattern
Returns a pattern of symbol variants or an empty list if no pattern exists. The pattern can be the same on each call, disregarding the parameters. It is up to the implementation to interpret the parameters, but a likely interpretation is to create different patterns depending on the model type at least. The start and end variants can be used to create patterns with more context than the type of the model alone. For example, the start and end variant can be interpreted as "what is the most common pattern of symbol variants between a variant 'start' and a variant 'end'".- Parameters:
type
- the model type contextstart
- the start variant context, or nullend
- the end variant context, or null- Returns:
- a pattern of symbol variants or an empty list
-
supportsModel
Returns true if this LAF should be applied to a given model type. -
isLabelVisible
Return true to show label, false to hide it and null to let other LAF:s decide. -
isLabelHideable
Return true if labels should be hideable, false if not, and null to let other LAF:s decide. -
getDefaultSize
Optionally returns a default size for a vertex. Return null to to let the size be determined by the default variant size or the last placed symbol of the same type, or other LAF:s. -
isSizeEditable
Return true to allow resizing of a vertex, false to disable it. Returning null will let the default configuration or other LAF:s decide. -
isMovable
Return true to allow moving a vertex, false to disable it. Returning null will let the default configuration or other LAF:s decide. -
isMovable
Return true to allow moving an edge, false to disable it. Returning null will let the default configuration or other LAF:s decide. -
getMethodSupport
Returns the method support for the model type or null if no method support is available. -
getFilter
Returns an optional filter for content shown in a model. -
getPasteBounds
If only vertices are pasted into a model the LAF can decide the bounds of the pasted vertices, to allow setting a default size not equal to the size in the source model. If edges are included the original size will always be retained to keep the edges valid. -
getPlaceAction
Returns a function that takes a vertex and initializes the vertex if needed. The returned function is only called if this laf is considered the priority laf.- Parameters:
vertex
- The vertex to return an action for- Returns:
-