[Jtreeview-cvs] jtreeview commit notification
Brought to you by:
alokito
From: Alok S. <al...@us...> - 2007-02-03 04:58:44
|
Update of /cvsroot/jtreeview/LinkedView/src/edu/stanford/genetics/treeview/plugin/karyoview In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17681/src/edu/stanford/genetics/treeview/plugin/karyoview Added Files: KaryoPanelLoader.java Log Message: Moved LoadProgress2 into the main package Made it work with only two threads, and maintaining most of the internal state. --- NEW FILE: KaryoPanelLoader.java --- /* * Created on Feb 2, 2007 * * Copyright Alok Saldnaha, all rights reserved. */ package edu.stanford.genetics.treeview.plugin.karyoview; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import edu.stanford.genetics.treeview.*; /** * This is a class that performs the transformation of information from * what's appropriate to a TVModel into what's required for karyoscope display. * @author aloksaldanha * */ class KaryoPanelLoader implements ProgressTrackable { /* * first some variables to support a fancy progress bar */ private int progressLength = -1; private int progressValue = -1; javax.swing.Timer loadTimer; private LoadProgress2 loadProgress; /** did we encounter a problem in parsing? */ boolean hadProblem = false; /** Setter for hadProblem */ public void setHadProblem(boolean hadProblem) { this.hadProblem = hadProblem; } /** Getter for hadProblem */ public boolean getHadProblem() { return hadProblem; } public int getLength() { // TODO Auto-generated method stub return progressLength; } public int getValue() { // TODO Auto-generated method stub return progressValue; } /** We hold fatal exceptions, for access by a reporting thread */ LoadException exception = null; /** Setter for exception */ public void setException(LoadException exception) { this.exception = exception; } /** Getter for exception */ public LoadException getException() { return exception; } public void setValue(int value) { progressValue = value; } public void incrValue(int i) { progressValue++; } public void setLength(int length) { progressLength = length; } boolean finished = false; // this is set when thread forced to stop. /** Setter for finished */ public void setFinished(boolean finished) { this.finished = finished; } /** Getter for finished */ public boolean getFinished() { return finished; } public int phaseValue; /** Setter for phaseValue */ public void setPhaseValue(int phaseValue) { this.phaseValue = phaseValue; } /** Getter for phaseValue */ public int getPhaseValue() { return phaseValue; } public int phaseLength = -1; /** Setter for phaseLength */ public void setPhaseLength(int phaseLength) { if (loadProgress != null) loadProgress.setPhaseLength(phaseLength); this.phaseLength = phaseLength; } /** Getter for phaseLength */ public int getPhaseLength() { return phaseLength; } public String phaseText; /** Setter for phaseText */ public void setPhaseText(String phaseText) { this.phaseText = phaseText; } /** Getter for phaseText */ public String getPhaseText() { return phaseText; } class TimerListener implements ActionListener { // manages the FileLoader // this method is invoked every few hundred ms public void actionPerformed(ActionEvent evt) { loadProgress.setValue(getValue()); loadProgress.setPhaseValue(getPhaseValue()); loadProgress.setPhaseText(getPhaseText()); if (loadProgress.getCanceled() || getFinished()) { setFinished(true); loadTimer.stop(); if (getHadProblem() == false) { loadProgress.setVisible(false); } else { loadProgress.setButtonText("Dismiss"); Toolkit.getDefaultToolkit().beep(); loadProgress.getToolkit().beep(); } } } } /** * source to load from */ private ViewFrame sourceFrame; /** * Target to load into */ private KaryoPanel targetPanel; } |