/******************************************************************* Copyright (c) 2001-2010 Apprisant Technologies Inc. All rights reserved. Apprisant Technologies permits non-exclusive royalty free use, copying and modification of this demo program source code for the purposes of evaluating the Apprisant Toolkit or building applications that use it. This software and documentation is provided "AS IS". APPRISANT TECHNOLOGIES DISCLAIMS ANY REPRESENTATIONS AND WARRANTIES, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS OF THIS PRODUCT FOR ANY PARTICULAR PURPOSE. APPRISANT TECHNOLOGIES SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY ANY PARTY, INCLUDING LOST PROFITS, ARISING FROM THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ITS DERIVATIONS. ********************************************************************/ package oilfield; import java.awt.geom.Point2D; import java.io.*; import java.util.*; import apprisant.diagram.*; import apprisant.diagram.data.*; import apprisant.diagram.event.*; /* The data model for the Oilfield demo. The data object class is the Well class. Some data objects are stored in a separate pool for use with the Add and Remove buttons. */ public class OilfieldData implements DataModel { private DataModelSupport support = new DataModelSupport(this); // The data in the model private HashMap wells = new HashMap(); // Pool of spare wells for adding and removing private ArrayList pool = new ArrayList(); public OilfieldData() { initWells(); } /* DataModel interface methods */ public Collection keySet() { return wells.keySet(); } public Well get (Object key) { return wells.get(key); } public void addAGDataListener (AGDataListener listener) { support.addAGDataListener(listener); } public void removeAGDataListener (AGDataListener listener) { support.removeAGDataListener(listener); } public AGDataListener[] getAGDataListeners() { return support.getAGDataListeners(); } /* Creates all the data objects, adding most to the data model, the rest to the pool. */ public void initWells() { wells.clear(); pool.clear(); wells.put("W458", new Well("W458", 45, 973, 58437.28, .76, new Point2D.Float(100, 150))); wells.put("W459", new Well("W459", 78, 1037, 69438.25, .25, new Point2D.Float(140, 210))); wells.put("W461", new Well("W461", 33, 645, 37389.69, .89, new Point2D.Float(340, 330))); wells.put("W462", new Well("W462", 63, 954, 62480.82, .32, new Point2D.Float(380, 280))); wells.put("W463", new Well("W463", 21, 438, 25837.37, .56, new Point2D.Float(450, 130))); support.fireAddAll(); pool.add(new Well("W464", 12, 275, 13456.63, .84, new Point2D.Float(120, 90))); pool.add(new Well("W465", 9, 158, 9438.19, .18, new Point2D.Float(300, 120))); pool.add(new Well("W466", 7, 137, 8435.87, .23, new Point2D.Float(270, 290))); } /* Methods for the Add and Remove button listeners. */ public void addWell() { if (pool.size() > 0) { Well w = pool.remove(0); wells.put(w.getKey(), w); support.fireAdd(w.getKey()); } } public void removeWell (Object key) { if (key != null) { pool.add(wells.get(key)); wells.remove(key); support.fireRemove(key); } } }