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.
  • 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());
       
      Returns an empty optional if the prioritised laf returns null or if the list is empty. The mapper must be side-effect free and referentially transparent.
      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 context
      start - the start variant context, or null
      end - the end variant context, or null
      Returns:
      a pattern of symbol variants or an empty list
    • supportsModel

      boolean supportsModel(ModelType modelType)
      Returns true if this LAF should be applied to a given model type.
    • isLabelVisible

      Boolean isLabelVisible(MTCompleteVertex vertex)
      Return true to show label, false to hide it and null to let other LAF:s decide.
    • isLabelHideable

      Boolean isLabelHideable(MTCompleteVertex vertex)
      Return true if labels should be hideable, false if not, and null to let other LAF:s decide.
    • getDefaultSize

      Dimension getDefaultSize(MTCompleteModel model, SymbolVariant variant)
      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

      Boolean isSizeEditable(MTCompleteVertex vertex)
      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

      default Boolean isMovable(MTCompleteVertex vertex)
      Return true to allow moving a vertex, false to disable it. Returning null will let the default configuration or other LAF:s decide.
    • isMovable

      default Boolean isMovable(MTCompleteEdge edge)
      Return true to allow moving an edge, false to disable it. Returning null will let the default configuration or other LAF:s decide.
    • getMethodSupport

      MethodSupport getMethodSupport(MTCompleteModel model)
      Returns the method support for the model type or null if no method support is available.
    • getFilter

      default Optional<ModelFilter> getFilter(MTCompleteModel model)
      Returns an optional filter for content shown in a model.
    • getPasteBounds

      Rectangle 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. If edges are included the original size will always be retained to keep the edges valid.
    • getPlaceAction

      Runnable getPlaceAction(MTCompleteVertex vertex)
      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: