/* * Leveler.java * * Created on April 22, 2003, 4:58 PM */ package org.das2.graph; import java.util.ArrayList; import java.util.List; /** * Manages a set of rows or columns, making sure they fill a space without * overlapping. This is an ancient class that would manage a set of rows to support a * PaPCo- or Autoplot-like application. * @deprecated do not use. * @author jbf */ public class Leveler { ArrayList rows; // DasDevicePositions ArrayList weights; // doubles double interMargin; DasCanvas parent; private static class LevelRow extends DasRow { Leveler lev; /** Creates a new instance of DasLevelRow */ public LevelRow( DasCanvas parent, Leveler lev, double nposition, double weight ) { super(parent,0,0); this.lev= lev; lev.insertAt(nposition,this,weight); } public LevelRow(DasCanvas parent, Leveler lev, double nposition) { this( parent, lev, nposition, 1.0 ); } public double getMaximum() { if (lev==null) { return 0.; } else { return lev.getMaximum(this); } } public double getMinimum() { if (lev==null) { return 0.; } else { return lev.getMinimum(this); } } public int getDMinimum() { return (int)( getMinimum()*getDeviceSize() ); } public int getDMaximum() { return (int)( getMaximum()*getDeviceSize() ); } public void setDPosition( int minimum, int maximum) { lev.setMaximum(this,maximum/(float)getDeviceSize()); lev.setMinimum(this,minimum/(float)getDeviceSize()); } public void setDMinimum(int minimum) { super.setDMinimum(minimum); } public void setDMaximum(int maximum) { super.setDMaximum(maximum); } } DasRow row; // this row contains the Leveler public Leveler( DasCanvas parent ) { this( parent, new DasRow( parent, 0.05, 0.9 ) ); } public Leveler( DasCanvas parent, DasRow row ) { this.parent= parent; this.row= row; rows= new ArrayList(); weights= new ArrayList(); interMargin= 0.03; } public double getWeight( DasRow row ) { int index= rows.indexOf(row); return ((Double)this.weights.get(index)).doubleValue(); } public double getPosition( DasRow row ) { return row.getMaximum(); } public DasRow addRow( double nposition, double weight ) { LevelRow r= new LevelRow( parent, this, nposition, weight ); return r; } public DasRow addRow( double nposition ) { LevelRow r= new LevelRow( parent, this, nposition ); return r; } public DasRow addRow( ) { LevelRow r= new LevelRow( parent, this, 1.0 ); return r; } public DasRow whichRow( int y ) { int i= objectIndexAt( y / parent.getHeight() ); if ( i>=0 && i= nposition ) { break; } } rows.add(i,row); weights.add(i,new Double(weight)); for ( int ii=0; ii