X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fsubmodels%2FSubmodelComponent.java;h=45c36bfb236df5a3018c2518f3461ad9172356b8;hb=a25f554756e1bc9a1f842293aefe60a220d8b950;hp=b5c1762b3bb50b89785769ed2319bc6d9e80b810;hpb=d333df14f718d96b419d751c6b2c64c6375726a8;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java index b5c1762b..45c36bfb 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java @@ -15,6 +15,7 @@ import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.components.GUIComponent; import net.mograsim.logic.model.model.wires.MovablePin; import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.snippets.Renderer; /** * A {@link GUIComponent} consisting of another model. A SubmodelComponent can have so-called "interface pins" connecting the @@ -80,6 +81,15 @@ public abstract class SubmodelComponent extends GUIComponent */ private final LogicUIRenderer renderer; + /** + * The {@link Renderer} used to render the symbol of this SubmodelCoponent. + */ + private Renderer symbolRenderer; + /** + * The {@link Renderer} used to render the outline of this SubmodelCoponent. + */ + private Renderer outlineRenderer; + // creation and destruction public SubmodelComponent(ViewModelModifiable model, String name) @@ -269,6 +279,48 @@ public abstract class SubmodelComponent extends GUIComponent return submodelScale; } + /** + * @see #renderSymbol(GeneralGC, Rectangle) + * + * @author Daniel Kirschten + */ + protected void setSymbolRenderer(Renderer symbolRenderer) + { + this.symbolRenderer = symbolRenderer; + requestRedraw(); + } + + /** + * @see #renderSymbol(GeneralGC, Rectangle) + * + * @author Daniel Kirschten + */ + public Renderer getSymbolRenderer() + { + return symbolRenderer; + } + + /** + * @see #renderOutline(GeneralGC, Rectangle) + * + * @author Daniel Kirschten + */ + protected void setOutlineRenderer(Renderer outlineRenderer) + { + this.outlineRenderer = outlineRenderer; + requestRedraw(); + } + + /** + * @see #renderOutline(GeneralGC, Rectangle) + * + * @author Daniel Kirschten + */ + public Renderer getOutlineRenderer() + { + return outlineRenderer; + } + @Override public void render(GeneralGC gc, Rectangle visibleRegion) { @@ -297,20 +349,27 @@ public abstract class SubmodelComponent extends GUIComponent renderOutline(gc, visibleRegion); } - // TODO make this a path /** - * Render the outline of this {@link SubmodelComponent}, e.g. the graphical elements that should stay visible if the submodel is drawn. + * Render the symbol of this {@link SubmodelComponent}, e.g. the things that should be hidden if the submodel is drawn. * * @author Daniel Kirschten */ - protected abstract void renderOutline(GeneralGC gc, Rectangle visibleRegion); + protected void renderSymbol(GeneralGC gc, Rectangle visibleRegion) + { + if (symbolRenderer != null) + symbolRenderer.render(gc, visibleRegion); + } /** - * Render the symbol of this {@link SubmodelComponent}, e.g. the things that should be hidden if the submodel is drawn. + * Render the outline of this {@link SubmodelComponent}, e.g. the graphical elements that should stay visible if the submodel is drawn. * * @author Daniel Kirschten */ - protected abstract void renderSymbol(GeneralGC gc, Rectangle visibleRegion); + protected void renderOutline(GeneralGC gc, Rectangle visibleRegion) + { + if (outlineRenderer != null) + outlineRenderer.render(gc, visibleRegion); + } private static double map(double val, double valMin, double valMax, double mapMin, double mapMax) {