?? viewoptions.java
字號:
/** * Copyright 2004 Carlos Silva A. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package jgantt.model;import java.util.Calendar;import java.util.Date;import java.util.Enumeration;import java.util.Vector;/** * ViewOptions controla el como la visualizacion debe realizarse. * Ademas calcula cuanta informacion debe mostrarse.</p> * * <p>$Date: 2005/06/13 23:43:27 $</p> * @version $Revision: 1.6 $ * @author Carlos Silva */public class ViewOptions extends ViewOptionsData { /** * Milisegundos por pixel */ public long msPixel = 0; /** * tiempos en las divisiones * que no haya mas de 300 divisiones en la pantalla (aprox 3.000 pixels */ public long divTimes[] = new long[300]; /** * Pixeles donde se producen las divisiones * que no haya mas de 500 divisiones en la pantalla */ public int divX[] = new int[300]; /** * numero de divisiones */ public int divCount = 0; /** * tiempo en la division 0 */ public long t0 = 0; /** * Proyecto asociado */ Project project = null; /** * Constructor reservado al paquete. * @param p project asociado */ ViewOptions(Project p) { this.project = p; setStartDate(project.getMainTask().getStartDate(), startOffset); } /** * Asigna la fecha de inicio de la carta gantt * */ public void setStartDate(Date d, int days) { Calendar c = Calendar.getInstance(); c.setTime(d); c.set(java.util.Calendar.HOUR_OF_DAY, 0); c.set(java.util.Calendar.MINUTE, 0); c.set(java.util.Calendar.SECOND, 0); c.set(java.util.Calendar.MILLISECOND, 0); c.add(java.util.Calendar.DATE, days); // Fecha de inicio de la carta gantt startDate = c.getTime(); t0 = c.getTime().getTime(); notifyObservers(); } /** * Recalcula el inicio de la carta gantt, el ancho de las divisiones menores * y los tiempos asociados a cada division menor * */ public void recalc() { t0 = startDate.getTime(); // determinar el ancho de la divisio menor switch (minDivUnit) { case Calendar.DAY_OF_MONTH : if (minDivFormat==java.util.Calendar.DATE) divWidth = stdDivWidth*3/2; else divWidth = stdDivWidth; msPixel = (msDay * minDivMult) / divWidth; break; case Calendar.WEEK_OF_YEAR : divWidth = stdDivWidth * 3; msPixel = (msWeek * minDivMult) / divWidth; break; case Calendar.MONTH : divWidth = stdDivWidth * 5; msPixel = (msMonth * minDivMult) / divWidth; break; } // calcular la fecha de inicio de la gantt como 5 dias antes de empezar el proyecto Calendar c = Calendar.getInstance(); c.setTime(startDate); divCount = 0; for (int x = 0;(x <= 1500) && (divCount < 500);) { long t = c.getTime().getTime(); x = (int) ((t - t0) / msPixel); divX[divCount] = x; divTimes[divCount] = t; c.add(minDivUnit, minDivMult); divCount++; } // ancho interno int width = (int) ((project.getMainTask().getFinishDate().getTime() - project.getMainTask().getStartDate().getTime()) / msPixel); } public void setTopRow(int tr){ topRow=tr; notifyObservers(); } public int getTopRow(){ return topRow; } // Observadores transient Vector observers = new Vector(); public void addObserver(Observer o) { observers.addElement(o); } public void removeObserver(Observer o) { observers.remove(o); } public void notifyObservers() { recalc(); for (Enumeration e = observers.elements(); e.hasMoreElements();) { Observer ob = (Observer) e.nextElement(); ob.viewOptionsChanged(); } } public interface Observer { public void viewOptionsChanged(); } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -