/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.component;
import javolution37.javolution.xml.XmlElement;
import javolution37.javolution.xml.XmlFormat;
import com.jstatcom.model.JSCInt;
import com.jstatcom.model.JSCNArray;
import com.jstatcom.project.ProjectManager;
import com.jstatcom.project.SettingsElement;
/**
* Holds all settings of the TopFrame class that should be stored
* between application runs.
*
* @author Markus Kraetzig
*/
public final class TopFrameSettings implements SettingsElement {
private JSCNArray frameBounds = new JSCNArray("bounds", new double[] {
100.0, 100.0, 1000.0, 800.0, });
private JSCInt splitLocation = new JSCInt("split", 120);
private JSCInt isOutputOn = new JSCInt("output", 1);
/**
* XML format field for (de)serialization.
*/
public static final XmlFormat TopFrameSettings_XML = new XmlFormat(
TopFrameSettings.class) {
public void format(TopFrameSettings data, XmlElement xml) {
xml.add(data.frameBounds);
xml.add(data.splitLocation);
xml.add(data.isOutputOn);
}
public TopFrameSettings parse(XmlElement xml) {
TopFrameSettings settings = new TopFrameSettings();
if (xml.hasNext()) {
JSCNArray bounds = (JSCNArray) xml.getNext();
settings.setFrameBounds(bounds);
}
if (xml.hasNext()) {
JSCInt pos = (JSCInt) xml.getNext();
settings.setSplitLocation(pos);
}
if (xml.hasNext()) {
JSCInt out = (JSCInt) xml.getNext();
settings.setIsOutputOn(out);
}
return settings;
}
};
/*
* (non-Javadoc)
*
* @see com.jstatcom.project.SettingsElement#setElement()
*/
public void setElement() {
TopFrame topFrame = ProjectManager.getInstance().getTopFrame();
if (topFrame != null)
topFrame.setTopFrameSettings(this);
}
/**
* Gets the 4x1 array holding location and size of the frame.
*
* @return bounds array
*/
public JSCNArray getFrameBounds() {
return frameBounds;
}
/**
* Sets the 4x1 array holding location and size of the frame.
*
* @param frameBounds
* @throws IllegalArgumentException
* if (frameBounds == null)
*/
public void setFrameBounds(JSCNArray frameBounds) {
if (frameBounds == null)
throw new IllegalArgumentException("Argument was null.");
this.frameBounds = frameBounds;
}
/**
* Gets the position of the splitpane divider.
*
* @return position of divider
*/
public JSCInt getSplitLocation() {
return splitLocation;
}
/**
* Sets the position of the splitpane divider.
*
* @param splitLocation
* as integer
* @throws IllegalArgumentException
* if (splitLocation == null)
*/
public void setSplitLocation(JSCInt splitLocation) {
if (splitLocation == null)
throw new IllegalArgumentException("Argument was null.");
this.splitLocation = splitLocation;
}
/**
* Gets JSCInt indicating whether output is on.
*
* @return JSCInt
*/
public JSCInt getIsOutputOn() {
return isOutputOn;
}
/**
* Sets whether output is on.
*
* @param isOutputOn
* as integer
* @throws IllegalArgumentException
* if (isOutputOn == null)
*/
public void setIsOutputOn(JSCInt isOutputOn) {
if (isOutputOn == null)
throw new IllegalArgumentException("Argument was null.");
this.isOutputOn = isOutputOn;
}
}
Ads help maintain this website.