/*
* -------------------------------------------------------------------------
* $Id: Model.java,v 1.3 2003/04/04 14:11:41 trudisch Exp $
* -------------------------------------------------------------------------
* Copyright (c) 1999 Visual Numerics Inc. All Rights Reserved.
*
* This software is confidential information which is proprietary to
* and a trade secret of Visual Numerics, Inc. Use, duplication or
* disclosure is subject to the terms of an appropriate license
* agreement.
*
* VISUAL NUMERICS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. VISUAL
* NUMERICS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
* ITS DERIVATIVES.
*--------------------------------------------------------------------------
*/
package com.imsl.demo.WallStreet;
import java.util.*;
/**
*
* @author brophy
* @created January 25, 2002
*/
class Model {
static public interface Listener /*extends EventObject*/ {
void modelChanged();
}
static public final int STYLE_CLOSE = 0;
static public final int STYLE_CANDLESTICK = 1;
static public final int STYLE_HIGH_LOW_CLOSE = 2;
static public final int VOLUME_NONE = 0;
static public final int VOLUME_BARS = 1;
static public final int VOLUME_LINE = 2;
static public final int VOLUME_AREA = 3;
static public final int SCALING_LINEAR = 0;
static public final int SCALING_LOG = 1;
static public final int INTERVAL_YEAR = 0;
static public final int INTERVAL_MONTH = 1;
static public final int INTERVAL_QUARTER = 2;
static public final int INTERVAL_WEEK = 3;
static public final int OVERLAY_NONE = 0;
static public final int OVERLAY_SAR = 1;
static public final int OVERLAY_MA20 = 2;
static public final int OVERLAY_KAL = 3;
private int style;
private int period;
private String ticker;
private int volumeStyle;
private int scaling;
private int interval;
private int overlay;
private boolean active;
private Database database;
private List listListeners;
/** Creates new Model */
public Model(Database database) {
this.database = database;
style = STYLE_CANDLESTICK;
period = GregorianCalendar.WEEK_OF_YEAR;
ticker = "SUNW";
volumeStyle = VOLUME_BARS;
scaling = SCALING_LINEAR;
interval = INTERVAL_YEAR;
overlay = OVERLAY_NONE;
active = false;
listListeners = new ArrayList();
}
public void addListener(Listener listener) {
listListeners.add(listener);
}
void setActive() {
active = true;
fireListeners();
}
private void fireListeners() {
if (!active) return;
Iterator iter = listListeners.iterator();
while (iter.hasNext()) {
((Listener)iter.next()).modelChanged();
}
}
public Database getDatabase() {
return database;
}
/**
* style is one of STYLE_CLOSE, STYLE_CANDLESTICK, STYLE_HIGH_LOW_CLOSE
*/
public void setStyle(int style) {
this.style = style;
fireListeners();
}
public int getStyle() {
return style;
}
public void setPeriod(int period) {
this.period = period;
fireListeners();
}
public int getPeriod() {
return period;
}
public void setTicker(String ticker) {
this.ticker = ticker;
fireListeners();
}
public String getTicker() {
return ticker;
}
public void setVolumeStyle(int volumeStyle) {
this.volumeStyle = volumeStyle;
fireListeners();
}
public int getVolumeStyle() {
return volumeStyle;
}
public void setScaling(int scaling) {
this.scaling = scaling;
fireListeners();
}
public int getScaling() {
return scaling;
}
public void setInterval(int interval) {
this.interval = interval;
fireListeners();
}
public int getInterval() {
return interval;
}
public void setOverlay(int overlay) {
this.overlay = overlay;
fireListeners();
}
public int getOverlay() {
return overlay;
}
}