/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ import java.awt.Color; import java.io.IOException; import ilog.views.io.IlvFieldNotFoundException; import ilog.views.io.IlvInputStream; import ilog.views.io.IlvOutputStream; import ilog.views.io.IlvPersistentObject; import ilog.views.io.IlvReadFileException; /** * A configuration class for <code>IlvRailroad</code>. */ public class IlvRailroadAttributes implements IlvPersistentObject { private float _tieWidth = 7f; private float _tieSpacing = 5f; private float _railSpacing = 3f; private float _maximumRailSpacing = 7f; private float _maximumTieWidth = 10f; private Color _tieColor = new Color(139, 35, 35); private Color _railColor = new Color(25, 25, 112); private float _scale = 1f; private boolean _oneLine = false; private float _slantingLimit = 7f; private boolean _drawTies = true; private float _tieThickness = 0f; private float _railThickness = 0f; private Color _background = null; private boolean _doCenterLine = false; private Color _centerLineColor; private float _centerLineWidth; public IlvRailroadAttributes() { } public IlvRailroadAttributes(IlvInputStream stream) throws IlvReadFileException { _tieWidth = stream.readFloat("tieWidth"); _tieSpacing = stream.readFloat("tieSpacing"); _railSpacing = stream.readFloat("railSpacing"); _maximumRailSpacing = stream.readFloat("maximumRailSpacing"); _maximumTieWidth = stream.readFloat("maximumTieWidth"); _tieColor = stream.readColor("tieColor"); _railColor = stream.readColor("railColor"); _scale = stream.readFloat("scale"); _oneLine = stream.readBoolean("oneLine"); _slantingLimit = stream.readFloat("slantingLimit"); _drawTies = stream.readBoolean("drawTies"); _tieThickness = stream.readFloat("tieThickness"); _railThickness = stream.readFloat("railThickness"); try { _background = stream.readColor("background"); } catch (IlvFieldNotFoundException e) { } _doCenterLine = stream.readBoolean("doCenterLine"); try { _centerLineColor = stream.readColor("centerLineColor"); } catch (IlvFieldNotFoundException e) { } _centerLineWidth = stream.readFloat("centerLineWidth"); } Override public void write(IlvOutputStream stream) throws IOException { stream.write("tieWidth", _tieWidth); stream.write("tieSpacing", _tieSpacing); stream.write("railSpacing", _railSpacing); stream.write("maximumRailSpacing", _maximumRailSpacing); stream.write("maximumTieWidth", _maximumTieWidth); stream.write("tieColor", _tieColor); stream.write("railColor", _railColor); stream.write("scale", _scale); stream.write("oneLine", _oneLine); stream.write("slantingLimit", _slantingLimit); stream.write("drawTies", _drawTies); stream.write("tieThickness", _tieThickness); stream.write("railThickness", _railThickness); if (_background != null) stream.write("background", _background); stream.write("doCenterLine", _doCenterLine); if (_centerLineColor != null) stream.write("centerLineColor", _centerLineColor); stream.write("centerLineWidth", _centerLineWidth); } public IlvRailroadAttributes(IlvRailroadAttributes source) { _tieWidth = source._tieWidth; _tieSpacing = source._tieSpacing; _railSpacing = source._railSpacing; _maximumRailSpacing = source._maximumRailSpacing; _tieColor = source._tieColor; _railColor = source._railColor; _scale = source._scale; _oneLine = source._oneLine; _slantingLimit = source._slantingLimit; _drawTies = source._drawTies; _tieThickness = source._tieThickness; _railThickness = source._railThickness; _background = source._background; _doCenterLine = source._doCenterLine; _centerLineColor = source._centerLineColor; } public float getTieSpacing() { return _tieSpacing; } public float getRailSpacing() { return _railSpacing; } public float getScale() { return _scale; } public void setScale(float scale) { _scale = scale; } public float getMaximumRailSpacing() { return _maximumRailSpacing; } public float getMaximumTieWidth() { return _maximumTieWidth; } public float getTieWidth() { return _tieWidth; } public Color getRailColor() { return _railColor; } public Color getTieColor() { return _tieColor; } public void setTieSpacing(float tieSpacing) { _tieSpacing = tieSpacing; } public void setRailSpacing(float railSpacing) { _railSpacing = railSpacing; } public void setMaximumRailSpacing(float maximumRailSpacing) { _maximumRailSpacing = maximumRailSpacing; } public void setMaximumTieWidth(float maximumTieWidth) { _maximumTieWidth = maximumTieWidth; } public void setTieWidth(float tieWidth) { _tieWidth = tieWidth; } public void setRailColor(Color railColor) { _railColor = railColor; } public void setTieColor(Color tieColor) { _tieColor = tieColor; } public void setDrawingOneLine(boolean oneLine) { _oneLine = oneLine; } public boolean isDrawingOneLine() { return _oneLine; } public void setSlantingLimit(float slantingLimit) { _slantingLimit = slantingLimit; } public float getSlantingLimit() { return _slantingLimit; } public void setDrawingTies(boolean drawTies) { _drawTies = drawTies; } public boolean isDrawingTies() { return _drawTies; } public float getTieThickness() { return _tieThickness; } public void setTieThickness(float tieThickness) { _tieThickness = tieThickness; } public float getRailThickness() { return _railThickness; } public void setRailThickness(float railThickness) { _railThickness = railThickness; } public Color getBackground() { return _background; } public void setBackground(Color background) { _background = background; } public boolean isDoingCenterLine() { return _doCenterLine; } public void setDoingCenterLine(boolean doCenterLine) { _doCenterLine = doCenterLine; } public Color getCenterLineColor() { return _centerLineColor; } public void setCenterLineColor(Color centerLineColor) { _centerLineColor = centerLineColor; } public void setCenterLineWidth(float width) { _centerLineWidth = width; } public float getCenterLineWidth() { return _centerLineWidth; } public IlvRailroadAttributes copy() { return new IlvRailroadAttributes(this); } }