001package jmri.jmrit.display.layoutEditor;
002
003// This class may not important any others.
004
005/**
006 * LayoutEditorViewContext is a memo object containing
007 * the graphical View context information for a {@link LayoutEditor} MVC instance.
008 * <p>
009 * As a memo class, this may contain methods, but the class cannot include
010 * references to other classes, and ideally the methods won't use references
011 * to other classes. Just data, and operations on that data.
012 * <p>
013 * This should map to a subset of the variables stored and loaded by
014 * {@link jmri.jmrit.display.layoutEditor.configurexml.LayoutEditorXml}
015 * and the XML Schema for the LayoutEditor element.
016 * <p>
017 * This holds <u>graphical View</u> context information.
018 * It should <u>not</u> include Model (e.g. layout hardware, even global values)
019 * or Control (e.g. options affecting the operation of the editor) information.
020 * <p>
021 * It's OK for this to hold startup default values for the quantities.
022 * <p>
023 * This may be a temporary class, only existing to help
024 * build a better structure into this package.
025 *
026 * @author Bob Jacobsen Copyright (C) 2020
027 */
028final public class LayoutEditorViewContext {
029
030    LayoutEditorViewContext() {}  // intentionally package-protected to limit exposure
031
032    // -----------------------------------
033    // Sides and positions
034    // -----------------------------------
035
036    final public void setLayoutWidth(int width) {
037        panelWidth = width;
038    }
039    final public int getLayoutWidth() {
040        return panelWidth;
041    }
042    private int panelWidth = 0;
043
044    final public void setLayoutHeight(int height) {
045        panelHeight = height;
046    }
047    final public int getLayoutHeight() {
048        return panelHeight;
049    }
050    private int panelHeight = 0;
051
052    final public void setWindowWidth(int width) {
053        windowWidth = width;
054    }
055    final public int getWindowWidth() {
056        return windowWidth;
057    }
058    private int windowWidth = 0;
059
060    final public void setWindowHeight(int height) {
061        windowHeight = height;
062    }
063    final public int getWindowHeight() {
064        return windowHeight;
065    }
066    private int windowHeight = 0;
067
068    // Window upper left x, not panel upper left x
069    final public int getUpperLeftX() {
070        return upperLeftX;
071    }
072    final public void setUpperLeftX(int x) {
073        upperLeftX = x;
074    }
075    private int upperLeftX = 0;
076
077    // Window upper left y, not panel upper left y
078    final public int getUpperLeftY() {
079        return upperLeftY;
080    }
081    final public void setUpperLeftY(int y) {
082        upperLeftY = y;
083    }
084    private int upperLeftY = 0; // (not panel)
085
086    final public int setGridSize(int newSize) {
087        gridSize1st = newSize;
088        return gridSize1st;
089    }
090
091    /**
092     * Get the width drawing the grid; 10 is the
093     * default/initial value.
094     * @return current value
095     */
096    final public int getGridSize() {
097        return gridSize1st;
098    }
099    private int gridSize1st = 10;
100
101    final public int setGridSize2nd(int newSize) {
102        gridSize2nd = newSize;
103        return gridSize2nd;
104    }
105
106    /**
107     * Get the width for 2nd drawing of the grid; 10 is the
108     * default/initial value.
109     * @return current value
110     */
111    final public int getGridSize2nd() {
112        return gridSize2nd;
113    }
114    private int gridSize2nd = 10;
115
116    // also found in LayoutTrackDrawingOptions?
117    // why is this a float?  Needed for Graphics2D arguments?
118    final public void setMainlineTrackWidth(float width) {
119        mainlineTrackWidth = (int)width;
120    }
121
122    /**
123     * Get the width for drawing mainline track; 4 is the
124     * default/initial value.
125     * @return current value
126     */
127    final public int getMainlineTrackWidth() {
128        return (int) mainlineTrackWidth;
129    }
130    private float mainlineTrackWidth = 4.0F;
131
132    /**
133     * Set the width for sideline track; note
134     * that the stored and retrievable value is an integer.
135     * @param width Value to store; will be cast to (int)
136     */
137    // also found in LayoutTrackDrawingOptions? (temporary?)
138    // why is this a float? (temporary?)
139    final public void setSidelineTrackWidth(float width) {
140        sidelineTrackWidth = (int)width;
141    }
142
143    /**
144     * Get the width for drawing sideline track; 2 is the
145     * default/initial value.
146     * @return current value
147     */
148    final public int getSidelineTrackWidth() {
149        return (int) sidelineTrackWidth;
150    }
151    private float sidelineTrackWidth = 2.0F;
152
153    // also found in LayoutTrackDrawingOptions?
154    // why is this a float?  Needed for Graphics2D arguments?
155    final public void setMainlineBlockWidth(float width) {
156        mainlineBlockWidth = (int)width;
157    }
158
159    /**
160     * Get the width for drawing mainline Block; 4 is the
161     * default/initial value.
162     * @return current value
163     */
164    final public int getMainlineBlockWidth() {
165        return (int) mainlineBlockWidth;
166    }
167    private float mainlineBlockWidth = 4.0F;
168
169    /**
170     * Set the width for sideline Block; note
171     * that the stored and retrievable value is an integer.
172     * @param width Value to store; will be cast to (int)
173     */
174    // also found in LayoutBlockDrawingOptions? (temporary?)
175    // why is this a float? (temporary?)
176    final public void setSidelineBlockWidth(float width) {
177        sidelineBlockWidth = (int)width;
178    }
179
180    /**
181     * Get the width for drawing sideline Block; 2 is the
182     * default/initial value.
183     * @return current value
184     */
185    final public int getSidelineBlockWidth() {
186        return (int) sidelineBlockWidth;
187    }
188    private float sidelineBlockWidth = 2.0F;
189
190    /**
191     * Get the X-axis scaling value; 1.0 is the
192     * default/initial value.
193     * @return current value
194     */
195    final public double getXScale() {
196        return xScale;
197    }
198    final public void setXScale(double scale) {
199        xScale = scale;
200    }
201    private double xScale = 1.0;
202
203    /**
204     * Get the Y-axis scaling value; 1.0 is the
205     * default/initial value.
206     * @return current value
207     */
208    final public double getYScale() {
209        return yScale;
210    }
211    final public void setYScale(double scale) {
212        yScale = scale;
213    }
214    private double yScale = 1.0;
215
216
217    // initialize logging
218    // private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LayoutEditor.class);
219
220}
221
222/* ***************************************************
223
224      <xs:attribute name="sliders" type="yesNoType" default="yes"/>
225      <xs:attribute name="drawgrid" type="yesNoType" default="yes" />
226      <xs:attribute name="antialiasing" type="yesNoType" default="yes" />
227      <xs:attribute name="turnoutcircles" type="yesNoType" default="yes" />
228
229      <xs:attribute name="defaulttrackcolor" type="screenColorType" use="required" /> Default about display?
230      <xs:attribute name="defaultalternativetrackcolor" type="screenColorType"/>      Or more Controller?
231      <xs:attribute name="defaultoccupiedtrackcolor" type="screenColorType"/>
232      <xs:attribute name="defaulttextcolor" type="screenColorType"/>
233
234      <xs:attribute name="turnoutcirclecolor" type="turnoutCircleColourType"/>
235      <xs:attribute name="turnoutcirclethrowncolor" type="turnoutCircleColourType"/>
236
237      <xs:attribute name="turnoutfillcontrolcircles" type="yesNoType" default="no"/>
238      <xs:attribute name="turnoutcirclesize" type="xs:integer"/>
239      <xs:attribute name="turnoutdrawunselectedleg" type="yesNoType" default="yes"/>
240
241      <xs:attribute name="turnoutbx" type="xs:float"/>
242      <xs:attribute name="turnoutcx" type="xs:float"/>
243      <xs:attribute name="turnoutwid" type="xs:float"/>
244      <xs:attribute name="xoverlong" type="xs:float"/>
245      <xs:attribute name="xoverhwid" type="xs:float"/>
246      <xs:attribute name="xovershort" type="xs:float"/>
247
248      <xs:attribute name="redBackground" type="xs:integer"/>
249      <xs:attribute name="greenBackground" type="xs:integer"/>
250      <xs:attribute name="blueBackground" type="xs:integer"/>
251
252      <xs:attribute name="zoom" type="xs:float" default="1.0"/>
253
254
255Probably not View graphical:
256      <xs:attribute name="name" type="xs:string"/> Is that graphical? Not sure
257
258      <xs:attribute name="scrollable" type="scrollableType" default="both" />
259      <xs:attribute name="editable" type="yesNoType" default="yes" />
260      <xs:attribute name="positionable" type="yesNoType" default="yes" />
261      <xs:attribute name="controlling" type="yesNoType" default="yes" />
262      <xs:attribute name="animating" type="yesNoType" default="yes" />
263      <xs:attribute name="showhelpbar" type="yesNoType" default="yes" />
264
265      <xs:attribute name="snaponadd" type="yesNoType" default="yes" />
266      <xs:attribute name="snaponmove" type="yesNoType" default="yes" />
267
268      <xs:attribute name="tooltipsnotedit" type="yesNoType" default="yes" />
269      <xs:attribute name="tooltipsinedit" type="yesNoType" default="yes" />
270
271      <xs:attribute name="autoblkgenerate" type="yesNoType" default="yes"/>
272
273      <xs:attribute name="openDispatcher" type="yesNoType" default="no"/>
274      <xs:attribute name="useDirectTurnoutControl" type="yesNoType" default="no"/>
275
276 */
277