package com.dwave.util; /* * WindowArranger * * Copyright (C) 2000 Michael Coury, Vincent Dupont * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import javax.swing.*; import java.util.Vector; import java.util.Comparator; import java.awt.Dimension; import java.awt.Component; import java.awt.event.*; import java.awt.BorderLayout; /** * @author Michael Coury * @author Vincent Dupont * @version 1.0 07/24/2000 */ public class WindowArranger implements java.io.Serializable { public static final int HORIZONTAL = 0, VERTICAL = 1, CASCADE = 2, ARRANGE = 3; // empty constructor. Class methods are accessed statically private WindowArranger() {} // method to tile open windows in various styles: // HORIZONTAL = horizontal tiling // VERTICAL = vertical tiling // CASCADE = cascade windows, resizing based on desktop size // ARRANGE = arranges windows in a grid public static void tileFrames(JDesktopPane desk, int style){ Dimension deskDim = desk.getSize(); int deskWidth = deskDim.width; int deskHeight = deskDim.height; JInternalFrame[] frames = desk.getAllFrames(); int frameCount = frames.length; int frameWidth=0; int frameHeight=0; int xpos=0; int ypos=0; double scale = 0.6; int spacer=30; int frameCounter=0; Vector frameVec=new Vector(1,1); boolean areIcons=false; int tempy=0,tempx=0; for (int i =0; i< frameCount;i++) { if (frames[i].isVisible() && !frames[i].isIcon()) { frameVec.addElement(frames[i]); frameCounter++; } else if(frames[i].isIcon()) areIcons=true; } if(areIcons) deskHeight = deskHeight - 50; switch(style){ case(HORIZONTAL): for (int i=0; ideskWidth)||(ypos+frameHeight>deskHeight-50)){ xpos=0; ypos=0; } } break; case(ARRANGE): int row=new Long(Math.round(Math.sqrt(new Integer(frameCounter).doubleValue()))).intValue(); if(row==0) break; int col=frameCounter/row; if (col ==0) break; int rem=frameCounter%row; int rowCount=1; frameWidth = (int) deskWidth/col; frameHeight = (int) deskHeight/row; for (int i=0; i=name1.length())|(index>=name2.length())) break; } else if (name1.charAt(index)>name2.charAt(index)) test= 1; else test = -1; }//while return test; } public boolean equals(Object object) { return object.equals(this); } public String toString(){ return "FILE_NAME"; } }; }