Revision 3396

View differences:

branches/gvSIG_CAD/applications/appgvSIG/distFiles/llig-me.txt
1
llig-me.txt
2

  
3
**************************
4

  
5
gvSIG v 0.4
6

  
7
Requisits de la instal?laci?:
8

  
9
    - M?quina Virtual Java 1.4.2 o superior instal?lada (http://java.sun.com).
10

  
11
Requisits de l'aplicaci?:
12

  
13
    - Sistema
14

  
15
        ? M?nims: Pentium III / 256 MB RAM.
16

  
17
        ? Recomanables: Pentium IV / 512 MB RAM.
18

  
19
        ? Sistemes operatius: plataformes Windows i Linux.
20
        Provat en Win98/XP, Linux Suse 8.2/9.0/9.2 i Linux Debian(Lliurex).
21

  
22

  
23
    - Programari instal?lat (disponible en http://www.gvsig.gva.es o en http://java.sun.com)
24

  
25
        ? M?quina Virtual Java 1.4.2 (06 o superior).
26

  
27
        ? JAI (Java Advanced Imaging).
28

  
29
        ? JAI Image I/O.
30

  
31

  
32
Nota: les libreries JAI i JAI Image I/O han d'estar instal?lades sobre la M?quina Virtual Java que gvSIG utilitze en l'execuci?. Si s'instal?la una nova JVM en el sistema i s'usa per a executar gvSIG ser? indispensable instal?lar les llibreries sobre esta.
33

  
34

  
35
M?s informaci? ? suport:
36

  
37
    Web oficial del projecte:
38

  
39
        http://www.gvsig.gva.es
40

  
41
    Llistes de distribuci?:
42

  
43
        http://runas.cap.gva.es/mailman/listinfo/gvsig_usuarios (suport per a usuaris).
44

  
45
        http://runas.cap.gva.es/mailman/listinfo/gvsig_desarrolladores (suport per a desenvolupadors).
46

  
47
        http://runas.cap.gva.es/mailman/listinfo/gvsig_english (suport per a usuaris o desenvolupadors de parla no-hispana).
48

  
0 49

  
branches/gvSIG_CAD/applications/appgvSIG/distFiles/LEEME.txt
1
gvSIG v 0.2.0 beta.
2

  
3
Prerequisitos:
4
  - Java instalado (JRE 1.4.2 o superior) (http://java.sun.com)
5
  - JAI + JAI image I/O (http://java.sun.com)
6
  - librer?as din?micas para los ECW: vienen con cualquier
7
    producto de ERMAPPER y son gratuitas (Actualmente solo hay disponibles para
8
    MS windows)(http://www.ermapper.com)
9
  
10
Instalaci?n:
11

  
12
	Descomprimir el archivo zip completo en el directorio deseado
13
	
14
Ejecuci?n
15
	En windows: gvSIG.bat
16
	En linux:  gvSIG.sh
17

  
18
M?s informaci?n:
19
	gvsig@gva.es
0 20

  
branches/gvSIG_CAD/applications/appgvSIG/build.number
1
#Build Number for ANT. Do not edit!
2
#Mon Sep 05 13:36:50 CEST 2005
3
build.number=737
0 4

  
branches/gvSIG_CAD/applications/appgvSIG/VCN
1
REALIZADOS:
2

  
3
- Al a?adir un nuevo fframe se debe de quedar ese como seleccionado 
4
y todos los dem?s hay que dejarlos como no seleccionados.
5

  
6
- Implementar el FFrameLegend con todos los nombres de capas 
7
como textLayout y los s?mbolos.
8

  
9
-Meterle un m?todo que cambie cada uno de los nombres y s?mbolos 
10
del fframe en un fframe por separado.
11
(Simplificar)A partir de un FFrameLegend crear FFrameText y FFrameSymbol.
12

  
13
-Introducir dentro FGraphicsUtilities la parte del m?todo paintcomponent 
14
de FPreviewSymbol que sea com?n dibujar sobre el mapa de forma est?tica.
15
Se dibuja por la posici?n del shape y no del rect?ngulo.
16

  
17
-Crear una clase FLayoutUtilities, con los m?todos est?ticos fromSheet y toSheet.
18

  
19
-Crear grupos de fframes unidos, Agrupar y para Desagrupar, 
20
de forma que cuando se agrupan se crea un FframeGroup que contenga dentro 
21
todos los fframes seleccionados previamente, y cuando se desagrupa 
22
se elimina el fframegroup y se vuelve a crear un fframe 
23
de cada uno de los fframe que contenia dentro el fframegroup.
24

  
25
-Alinear como lo hace arcView o como lo hace el visual editor en funci?n 
26
de los fframes seleccionados o en funci?n del Layout.
27

  
28
-Colocar detr?s y delante fframes seleccionados respecto de los dem?s.
29

  
30
-El FConstanstLayout debe de desaparecer y a?adir las 
31
constantes que contiene en las clases que las necesiten.
32

  
33
- Crear las barras de escala y modificar la escala en vez de en metros en cent?metros.
34

  
35
-Cuando se muestra una escala que no es fija, y se modifica la escala de la vista, 
36
la escala que lo representa no varia.
37

  
38
- Se pueda abrir el di?logo de propiedades de cada uno de los fframes a?adidos al Layout, 
39
con la informaci?n que necesita.
40

  
41
- Cuando se alinea un solo elemento no se hace como deber?a. 
42

  
43
-L?nea gr?fica.
44

  
45
-FullExtent.
46

  
47
- El di?logo de FPanelDefault no tiene la posibilidad p?blica de modificar 
48
que no contenga relleno.
49
-Los puntos se deben de poder cambiar su tama?o al cambiar su tama?o arrastrando con 
50
el rat?n en el Layout y no solo desde el di?logo de propiedades de este.
51

  
52
- El Fshape se crea cada vez que se dibuja y por lo tanto no hay que guardarlo.
53

  
54
- FSymbol tiene que guardarse en XML utilizando la XMLEntity.La forma separar el modelo del Layout.
55

  
56
-Al cambiar de tama?o un fframe por encima de su posicion x e y, se distorsiona.
57

  
58
-Al modificar la escala de una vista en el Layout la escala gr?fica debe de cambiar su tama?o 
59
de acuerdo al cambio en la escala de la vista.
60

  
61
-Haciendo un doble click se acceda al dialogo de propiedades de cada uno de los fframes.
62

  
63
-FFrameText: Falta poder posicionar las l?neas a la izquierda, centro o derecha.
64

  
65
-Hacer el entramado que sea transparente totalmente en vez de blanco y que se pueda controlar su transparencia en las l?neas que lo componen.
66

  
67
- La propiedad de poder a?adir una vista, una imagen o una leyenda en forma de borrador o presentaci?n.
68

  
69
- Popupmenu en el Layout que se abre pulsando el bot?n derecho del rat?n.
70

  
71
- En FFrameViewDialog si no se selecciona ninguna vista y se acepta salta una excepci?n.
72

  
73
- Al cambiar el zoom y posicionar alg?n elemento detr?s o delante respecto de los dem?s 
74
cambia el zoom y se coloca siempre en mismo lugar.
75

  
76
- Teniendo seleccionada la herramienta de selecci?n y desplazar un fframe cambia su tama?o, ahora lo sigue cambiando pero solo cuando
77
 se desplaza de su posici?n, el desplazamiento y cambio de tama?o de un rect?ngulo 
78
con el grid seleccionado no funciona del todo bien, cambia 
79
el tama?o de forma anormal, pero no siempre.
80

  
81
- Separar el drawLayout para imprimir del drawLayout para visualizar en pantalla.
82

  
83
-En FBorderDialog, falta a?adir propiedades al rect?ngulo que se a?ade, 
84
por ejemplo elegir el color, grosor, textura,de momento es un rect?ngulo simple.
85

  
86

  
87
- FFramePicture se debe cambiar, ya que crea un bufferedimage tan grande como el zoom que se hace y salta la excepci?n de out of memory.
88

  
89
PENDIENTES:
90

  
91
- Rematar el a?adir una vista al Layout, 
92
y su actualizaci?n.
93

  
94
- El Di?logo FLegendManagerWindow, 
95
para que pueda funcionar igual que en arcView 
96
debe ser ?nico implementando SingletonView y que se pueda cambiar su modelo 
97
por el de otra vista que lo requiera. 
98
Ahora mismo lo he dejado como modal y que implementa View.
99

  
100
-Al a?adir una misma vista dos veces al Layout sigue cambiando su extent, cada repaint.
101
Tambi?n al tocar la vista y refrescar en el Layout, que debe ser por lo mismo ya que la 
102
escala que calcula es diferente cada vez y eso cambia el extent.
103
Supongo que es la forma de calcular el extent respecto de la anchura y altura del 
104
fframe que lo contiene y al ser dos se reajusta sin parar. Para corregir esto hay que:
105
El extent del Fmap debe de quedarse fuera de este, 
106
de esta forma no se necesitara clonar fmap cuando el extent 
107
de la vista a a?adir al Layout no tiene que ser la misma.
108

  
109
-A?adir el insertar un rect?ngulo a cada uno de los fframes seleccionados
110
dentro de fframeGraphics contener FShapes con el rect?ngulo dentro en este caso y 
111
pensando en poder a?adir tambi?n de otras formas los rect?ngulos y l?neas que queramos.
112
fshape + symbol==graphics.
113

  
114
- No corren prisa: deshacer, escala real, 
115
zoom a lo seleccionado.
116

  
117
-Revisar los di?logos de los fframes para ver posibles fallos.
118

  
119
- Hay que tener en cuenta que di?logos abrir cuando hay varios fframes seleccionados 
120
cuando se quiere abrir el di?logo de propiedades. En FLayoutGraphics,openFFrameDialog(), 
121
hay que abrir el di?logo de propiedades cuando hayan m?s de uno seleccionado, 
122
incluido cuando son de tipos diferentes.
123

  
124
- Cuando se deslinka el extent de una vista a?adidar al Layout del extent original, se clona el FMap. 
125

  
126
-FFrameView: Falta recortar a la vista y lo de los eventos de cuando se tiene que actualizar el Layout respecto de los cambios de la vista.
127
	Enlace vivo: Se debe guardar el extent actual de la vista y quedarse con ese extent.
128
	
129
-FFramePicture: Falta lo de los eventos.
130
-FFrameScaleBar: Visualizar solo las vistas que esten a?adidas al Layout y no todas.
131
-FFrameLegend: Eventos .Y visualizar en la lista de selecci?n, si se quiere, las vistas a?adidas solamente y no todas.
132

  
133

  
134
-Preparar p?gina: FConfigLayoutDialog muestra una apariencia que no es la del Look and feel elegida. 
135
Puede que sea porque es un MODALDIALOG.
136

  
137
- Cuando se posiciona delante o detr?s una barra de escala, se cambia el tipo de fuente. 
138
Pero el tama?o es el mismo, el color del graphics tambi?n y el tipo de fuente.
139
- El area imprimible hay que conseguir que sea la misma para 
140
los attributes, PageFormat y para guardarla en un atributo 
141
de la clase Attributes. Imprimir de acuerdo a los m?rgenes establecidos, no funciona bien todav?a. Es un tema delicado.
142

  
143
- m_name de FFrame solo lo utilizan tres fframes de momento.
144

  
145
- Mirar el por que una vista tarda tanto en dibujar un trocillo peque?o en el Layout.
146

  
147
- La leyenda que se introduzca con tama?o adecuado, mirar arcView.
148

  
149
DUDAS:
150

  
151
- El simplificar un fframe, como por ejemplo la leyenda esta ya hecho pero el arcView 
152
tambi?n simplifica una vista por cada uno de sus shapes.(Esto no).
153
--------------------------------------------------------------------------------------
154
______________________________
155
VERSION 0.3:
156
______________________________
157

  
158
- Los botones del Layout que se apliquen sobre la vista a?adida se deben de poner a enables 
159
cuando se tenga seleccionada una vista. V
160

  
161
- Cuando se abre las propiedades de una vista a?adida en el Layout en el di?logo no se queda 
162
esta seleccionada en la lista, pero si se rellena el di?ologo con los datos necesarios. V
163

  
164
- Al imprimir un layout que est? en vertical tras haber guardado el proyecto y recuperado se 
165
visualiza en vertical pero la impresi?n es en horizontal. V
166

  
167
- A?adir al di?logo de FFrameText la posibilidad de poner color a los textos a?adidos. V
168

  
169

  
170

  
171
________________________________
172
CAD
173
________________________________
174

  
175

  
0 176

  
branches/gvSIG_CAD/applications/appgvSIG/src/com/vividsolutions/jump/util/OrderedMap.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 * 
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
package com.vividsolutions.jump.util;
35

  
36
import java.util.*;
37

  
38

  
39
/**
40
 * A Map that preserves the order of its keys.
41
 */
42
public class OrderedMap implements Map {
43
    private Map map;
44
    private List keyList;
45

  
46
    /**
47
     * Creates an OrderedMap backed by the given map.
48
     * @param map a Map that will be this OrderedMap's underlying Map
49
     */
50
    public OrderedMap(List keyList, Map map) {
51
    	this.keyList = keyList;
52
        this.map = map;
53
    }
54

  
55
    /**
56
     * Creates an OrderedMap.
57
     */
58
    public OrderedMap() {
59
        this(new HashMap());
60
    }
61
    
62
    public OrderedMap(Map map) {
63
    	this(new UniqueList(), map);
64
    }
65

  
66
    public int size() {
67
        return map.size();
68
    }
69

  
70
    public boolean isEmpty() {
71
        return map.isEmpty();
72
    }
73

  
74
    public boolean containsKey(Object key) {
75
        return map.containsKey(key);
76
    }
77

  
78
    public boolean containsValue(Object value) {
79
        return map.containsValue(value);
80
    }
81

  
82
    public Object get(Object key) {
83
        return map.get(key);
84
    }
85

  
86
    public Object put(Object key, Object value) {
87
        keyList.add(key);
88

  
89
        return map.put(key, value);
90
    }
91

  
92
    public Object remove(Object key) {
93
        keyList.remove(key);
94

  
95
        return map.remove(key);
96
    }
97

  
98
    public void putAll(Map t) {
99
        keyList.addAll(t.keySet());
100
        map.putAll(t);
101
    }
102

  
103
    public void clear() {
104
        keyList.clear();
105
        map.clear();
106
    }
107

  
108
    public Set keySet() {
109
        return map.keySet();
110
    }
111

  
112
    /**
113
     * Returns the keys, in order.
114
     * @return the keys in the order they were (first) added
115
     */
116
    public List keyList() {
117
        return keyList;
118
    }
119

  
120
    /**
121
     * Returns the values.
122
     * @return the values in the same order as the keys
123
     * @see #keyList()
124
     */
125
    public List valueList() {
126
        return (List) values();
127
    }
128

  
129
    /**
130
     * Returns the values.
131
     * @return the values in the same order as the keys
132
     * @see #keyList()
133
     */
134
    public Collection values() {
135
        ArrayList values = new ArrayList();
136

  
137
        for (Iterator i = keyList.iterator(); i.hasNext();) {
138
            Object key = i.next();
139
            values.add(map.get(key));
140
        }
141

  
142
        return values;
143
    }
144

  
145
    public Set entrySet() {
146
        return map.entrySet();
147
    }
148

  
149
    public boolean equals(Object o) {
150
        return map.equals(o);
151
    }
152
}
0 153

  
branches/gvSIG_CAD/applications/appgvSIG/src/com/vividsolutions/jump/util/Blackboard.java
1
/*
2
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
3
 * for visualizing and manipulating spatial features with geometry and attributes.
4
 *
5
 * Copyright (C) 2003 Vivid Solutions
6
 * 
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 * 
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
 * 
21
 * For more information, contact:
22
 *
23
 * Vivid Solutions
24
 * Suite #1A
25
 * 2328 Government Street
26
 * Victoria BC  V8T 5G5
27
 * Canada
28
 *
29
 * (250)385-6040
30
 * www.vividsolutions.com
31
 */
32

  
33
package com.vividsolutions.jump.util;
34

  
35
import java.util.HashMap;
36
import java.util.Map;
37
/**
38
* String-to-Object map that anyone can use.
39
* For example, the Options dialog has a single instance, and
40
* it's stored on the Workbench Blackboard.
41
*/
42
public class Blackboard implements Cloneable {
43
    private HashMap properties = new HashMap();
44

  
45
    /**
46
     * Used by Java2XML
47
     */
48
    public HashMap getProperties() {
49
        return properties;
50
    }
51

  
52
    /**
53
     * Used by Java2XML
54
     */
55
    public void setProperties(HashMap properties) {
56
        this.properties = properties;
57
    }
58

  
59
    public Blackboard put(String key, Object value) {
60
        properties.put(key, value);
61
        return this;
62
    }
63

  
64
    public Object get(String key) {
65
        return properties.get(key);
66
    }
67

  
68
    public Blackboard put(String key, boolean value) {
69
        put(key, new Boolean(value));
70
        return this;
71
    }
72
    public Blackboard putAll(Map properties) {
73
        this.properties.putAll(properties);
74
        return this;
75
    }
76

  
77
    public boolean get(String key, boolean defaultValue) {
78
        if (get(key) == null) {
79
            put(key, defaultValue);
80
        }
81

  
82
        return getBoolean(key);
83
    }
84

  
85
    public boolean getBoolean(String key) {
86
        return ((Boolean) get(key)).booleanValue();
87
    }
88

  
89
    public Blackboard put(String key, int value) {
90
        put(key, new Integer(value));
91
        return this;
92
    }
93

  
94
    public Blackboard put(String key, double value) {
95
        put(key, new Double(value));
96
        return this;
97
    }
98

  
99
    public double get(String key, double defaultValue) {
100
        if (get(key) == null) {
101
            put(key, defaultValue);
102
        }
103

  
104
        return getDouble(key);
105
    }
106

  
107
    public int get(String key, int defaultValue) {
108
        if (get(key) == null) {
109
            put(key, defaultValue);
110
        }
111

  
112
        return getInt(key);
113
    }
114

  
115
    public int getInt(String key) {
116
        return ((Integer) get(key)).intValue();
117
    }
118

  
119
    public double getDouble(String key) {
120
        return ((Double) get(key)).doubleValue();
121
    }
122

  
123
    public Object get(String key, Object defaultValue) {
124
        if (get(key) == null) {
125
            put(key, defaultValue);
126
        }
127

  
128
        return get(key);
129
    }
130
    
131
    public Object clone() {
132
        return new Blackboard().putAll(properties);
133
    }
134
}
0 135

  
branches/gvSIG_CAD/applications/appgvSIG/src/com/vividsolutions/jump/util/Fmt.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 * 
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
package com.vividsolutions.jump.util;
35

  
36

  
37
// Fmt - some simple single-arg sprintf-like routines
38
//
39
// Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>.  All rights reserved.
40
//
41
// Redistribution and use in source and binary forms, with or without
42
// modification, are permitted provided that the following conditions
43
// are met:
44
// 1. Redistributions of source code must retain the above copyright
45
//    notice, this list of conditions and the following disclaimer.
46
// 2. Redistributions in binary form must reproduce the above copyright
47
//    notice, this list of conditions and the following disclaimer in the
48
//    documentation and/or other materials provided with the distribution.
49
//
50
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
51
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53
// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
54
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60
// SUCH DAMAGE.
61
//
62
// Visit the ACME Labs Java page for up-to-date versions of this and other
63
// fine Java utilities: http://www.acme.com/java/
64
/// Some simple single-arg sprintf-like routines.
65
// <P>
66
// It is apparently impossible to declare a Java method that accepts
67
// variable numbers of any type of argument.  You can declare it to take
68
// Objects, but numeric variables and constants are not in fact Objects.
69
// <P>
70
// However, using the built-in string concatenation, it's almost as
71
// convenient to make a series of single-argument formatting routines.
72
// <P>
73
// Fmt can format the following types:
74
// <BLOCKQUOTE><CODE>
75
// byte short int long float double char String Object
76
// </CODE></BLOCKQUOTE>
77
// For each type there is a set of overloaded methods, each returning
78
// a formatted String.  There's the plain formatting version:
79
// <BLOCKQUOTE><PRE>
80
// Fmt.fmt( x )
81
// </PRE></BLOCKQUOTE>
82
// There's a version specifying a minimum field width:
83
// <BLOCKQUOTE><PRE>
84
// Fmt.fmt( x, minWidth )
85
// </PRE></BLOCKQUOTE>
86
// And there's a version that takes flags:
87
// <BLOCKQUOTE><PRE>
88
// Fmt.fmt( x, minWidth, flags )
89
// </PRE></BLOCKQUOTE>
90
// Currently available flags are:
91
// <BLOCKQUOTE><PRE>
92
// Fmt.ZF - zero-fill
93
// Fmt.LJ - left justify
94
// Fmt.HX - hexadecimal
95
// Fmt.OC - octal
96
// </PRE></BLOCKQUOTE>
97
// The HX and OC flags imply unsigned output.
98
// <P>
99
// For doubles and floats, there's a significant-figures parameter before
100
// the flags:
101
// <BLOCKQUOTE><PRE>
102
// Fmt.fmt( d )
103
// Fmt.fmt( d, minWidth )
104
// Fmt.fmt( d, minWidth, sigFigs )
105
// Fmt.fmt( d, minWidth, sigFigs, flags )
106
// </PRE></BLOCKQUOTE>
107
// <P>
108
// <A HREF="/resources/classes/Acme/Fmt.java">Fetch the software.</A><BR>
109
// <A HREF="/resources/classes/Acme.tar.gz">Fetch the entire Acme package.</A>
110
// <HR>
111
// Similar classes:
112
// <UL>
113
// <LI> Andrew Scherpbier's <A HREF="http://www.sdsu.edu/doc/java-SDSU/sdsu.FormatString.html">FormatString</A>
114
// Tries to allow variable numbers of arguments by
115
// supplying overloaded routines with different combinations of parameters,
116
// but doesn't actually supply that many.  The floating point conversion
117
// is described as "very incomplete".
118
// <LI> Core Java's <A HREF="http://www.apl.jhu.edu/~hall/java/CoreJava-Format.html">Format</A>.
119
// The design seems a little weird.  They want you to create an instance,
120
// passing the format string to the constructor, and then call an instance
121
// method with your data to do the actual formatting.  The extra steps are
122
// pointless; better to just use static methods.
123
// </UL>
124
public class Fmt {
125
    // Flags.
126
    /// Zero-fill.
127
    public static final int ZF = 1;
128

  
129
    /// Left justify.
130
    public static final int LJ = 2;
131

  
132
    /// Hexadecimal.
133
    public static final int HX = 4;
134

  
135
    /// Octal.
136
    public static final int OC = 8;
137

  
138
    // Was a number - internal use.
139
    private static final int WN = 16;
140

  
141
    // byte
142
    public static String fmt(byte b) {
143
        return fmt(b, 0, 0);
144
    }
145

  
146
    public static String fmt(byte b, int minWidth) {
147
        return fmt(b, minWidth, 0);
148
    }
149

  
150
    public static String fmt(byte b, int minWidth, int flags) {
151
        boolean hexadecimal = ((flags & HX) != 0);
152
        boolean octal = ((flags & OC) != 0);
153

  
154
        if (hexadecimal) {
155
            return fmt(Integer.toString(b & 0xff, 16), minWidth, flags | WN);
156
        } else if (octal) {
157
            return fmt(Integer.toString(b & 0xff, 8), minWidth, flags | WN);
158
        } else {
159
            return fmt(Integer.toString(b & 0xff), minWidth, flags | WN);
160
        }
161
    }
162

  
163
    // short
164
    public static String fmt(short s) {
165
        return fmt(s, 0, 0);
166
    }
167

  
168
    public static String fmt(short s, int minWidth) {
169
        return fmt(s, minWidth, 0);
170
    }
171

  
172
    public static String fmt(short s, int minWidth, int flags) {
173
        boolean hexadecimal = ((flags & HX) != 0);
174
        boolean octal = ((flags & OC) != 0);
175

  
176
        if (hexadecimal) {
177
            return fmt(Integer.toString(s & 0xffff, 16), minWidth, flags | WN);
178
        } else if (octal) {
179
            return fmt(Integer.toString(s & 0xffff, 8), minWidth, flags | WN);
180
        } else {
181
            return fmt(Integer.toString(s), minWidth, flags | WN);
182
        }
183
    }
184

  
185
    // int
186
    public static String fmt(int i) {
187
        return fmt(i, 0, 0);
188
    }
189

  
190
    public static String fmt(int i, int minWidth) {
191
        return fmt(i, minWidth, 0);
192
    }
193

  
194
    public static String fmt(int i, int minWidth, int flags) {
195
        boolean hexadecimal = ((flags & HX) != 0);
196
        boolean octal = ((flags & OC) != 0);
197

  
198
        if (hexadecimal) {
199
            return fmt(Long.toString(i & 0xffffffffL, 16), minWidth, flags |
200
                WN);
201
        } else if (octal) {
202
            return fmt(Long.toString(i & 0xffffffffL, 8), minWidth, flags | WN);
203
        } else {
204
            return fmt(Integer.toString(i), minWidth, flags | WN);
205
        }
206
    }
207

  
208
    // long
209
    public static String fmt(long l) {
210
        return fmt(l, 0, 0);
211
    }
212

  
213
    public static String fmt(long l, int minWidth) {
214
        return fmt(l, minWidth, 0);
215
    }
216

  
217
    public static String fmt(long l, int minWidth, int flags) {
218
        boolean hexadecimal = ((flags & HX) != 0);
219
        boolean octal = ((flags & OC) != 0);
220

  
221
        if (hexadecimal) {
222
            if ((l & 0xf000000000000000L) != 0) {
223
                return fmt(Long.toString(l >>> 60, 16) +
224
                    fmt(l & 0x0fffffffffffffffL, 15, HX | ZF), minWidth,
225
                    flags | WN);
226
            } else {
227
                return fmt(Long.toString(l, 16), minWidth, flags | WN);
228
            }
229
        } else if (octal) {
230
            if ((l & 0x8000000000000000L) != 0) {
231
                return fmt(Long.toString(l >>> 63, 8) +
232
                    fmt(l & 0x7fffffffffffffffL, 21, OC | ZF), minWidth,
233
                    flags | WN);
234
            } else {
235
                return fmt(Long.toString(l, 8), minWidth, flags | WN);
236
            }
237
        } else {
238
            return fmt(Long.toString(l), minWidth, flags | WN);
239
        }
240
    }
241

  
242
    // float
243
    public static String fmt(float f) {
244
        return fmt(f, 0, 0, 0);
245
    }
246

  
247
    public static String fmt(float f, int minWidth) {
248
        return fmt(f, minWidth, 0, 0);
249
    }
250

  
251
    public static String fmt(float f, int minWidth, int sigFigs) {
252
        return fmt(f, minWidth, sigFigs, 0);
253
    }
254

  
255
    public static String fmt(float f, int minWidth, int sigFigs, int flags) {
256
        if (sigFigs != 0) {
257
            return fmt(sigFigFix(Float.toString(f), sigFigs), minWidth,
258
                flags | WN);
259
        } else {
260
            return fmt(Float.toString(f), minWidth, flags | WN);
261
        }
262
    }
263

  
264
    // double
265
    public static String fmt(double d) {
266
        return fmt(d, 0, 0, 0);
267
    }
268

  
269
    public static String fmt(double d, int minWidth) {
270
        return fmt(d, minWidth, 0, 0);
271
    }
272

  
273
    public static String fmt(double d, int minWidth, int sigFigs) {
274
        return fmt(d, minWidth, sigFigs, 0);
275
    }
276

  
277
    public static String fmt(double d, int minWidth, int sigFigs, int flags) {
278
        if (sigFigs != 0) {
279
            return fmt(sigFigFix(doubleToString(d), sigFigs), minWidth,
280
                flags | WN);
281
        } else {
282
            return fmt(doubleToString(d), minWidth, flags | WN);
283
        }
284
    }
285

  
286
    // char
287
    public static String fmt(char c) {
288
        return fmt(c, 0, 0);
289
    }
290

  
291
    public static String fmt(char c, int minWidth) {
292
        return fmt(c, minWidth, 0);
293
    }
294

  
295
    public static String fmt(char c, int minWidth, int flags) {
296
        // return fmt( Character.toString( c ), minWidth, flags );
297
        // Character currently lacks a static toString method.  Workaround
298
        // is to make a temporary instance and use the instance toString.
299
        return fmt(new Character(c).toString(), minWidth, flags);
300
    }
301

  
302
    // Object
303
    public static String fmt(Object o) {
304
        return fmt(o, 0, 0);
305
    }
306

  
307
    public static String fmt(Object o, int minWidth) {
308
        return fmt(o, minWidth, 0);
309
    }
310

  
311
    public static String fmt(Object o, int minWidth, int flags) {
312
        return fmt(o.toString(), minWidth, flags);
313
    }
314

  
315
    // String
316
    public static String fmt(String s) {
317
        return fmt(s, 0, 0);
318
    }
319

  
320
    public static String fmt(String s, int minWidth) {
321
        return fmt(s, minWidth, 0);
322
    }
323

  
324
    public static String fmt(String s, int minWidth, int flags) {
325
        int len = s.length();
326
        boolean zeroFill = ((flags & ZF) != 0);
327
        boolean leftJustify = ((flags & LJ) != 0);
328
        boolean hexadecimal = ((flags & HX) != 0);
329
        boolean octal = ((flags & OC) != 0);
330
        boolean wasNumber = ((flags & WN) != 0);
331

  
332
        if ((hexadecimal || octal || zeroFill) && !wasNumber) {
333
            throw new InternalError("Acme.Fmt: number flag on a non-number");
334
        }
335

  
336
        if (zeroFill && leftJustify) {
337
            throw new InternalError("Acme.Fmt: zero-fill left-justify is silly");
338
        }
339

  
340
        if (hexadecimal && octal) {
341
            throw new InternalError("Acme.Fmt: can't do both hex and octal");
342
        }
343

  
344
        if (len >= minWidth) {
345
            return s;
346
        }
347

  
348
        int fillWidth = minWidth - len;
349
        StringBuffer fill = new StringBuffer(fillWidth);
350

  
351
        for (int i = 0; i < fillWidth; ++i)
352
            if (zeroFill) {
353
                fill.append('0');
354
            } else {
355
                fill.append(' ');
356
            }
357

  
358
        if (leftJustify) {
359
            return s + fill;
360
        } else if (zeroFill && s.startsWith("-")) {
361
            return "-" + fill + s.substring(1);
362
        } else {
363
            return fill + s;
364
        }
365
    }
366

  
367
    // Internal routines.
368
    private static String sigFigFix(String s, int sigFigs) {
369
        // First dissect the floating-point number string into sign,
370
        // integer part, fraction part, and exponent.
371
        String sign;
372
        String unsigned;
373

  
374
        if (s.startsWith("-") || s.startsWith("+")) {
375
            sign = s.substring(0, 1);
376
            unsigned = s.substring(1);
377
        } else {
378
            sign = "";
379
            unsigned = s;
380
        }
381

  
382
        String mantissa;
383
        String exponent;
384
        int eInd = unsigned.indexOf('e');
385

  
386
        if (eInd == -1) { // it may be 'e' or 'E'
387
            eInd = unsigned.indexOf('E');
388
        }
389

  
390
        if (eInd == -1) {
391
            mantissa = unsigned;
392
            exponent = "";
393
        } else {
394
            mantissa = unsigned.substring(0, eInd);
395
            exponent = unsigned.substring(eInd);
396
        }
397

  
398
        StringBuffer number;
399
        StringBuffer fraction;
400
        int dotInd = mantissa.indexOf('.');
401

  
402
        if (dotInd == -1) {
403
            number = new StringBuffer(mantissa);
404
            fraction = new StringBuffer("");
405
        } else {
406
            number = new StringBuffer(mantissa.substring(0, dotInd));
407
            fraction = new StringBuffer(mantissa.substring(dotInd + 1));
408
        }
409

  
410
        int numFigs = number.length();
411
        int fracFigs = fraction.length();
412

  
413
        if (((numFigs == 0) || number.equals("0")) && (fracFigs > 0)) {
414
            // Don't count leading zeros in the fraction.
415
            numFigs = 0;
416

  
417
            for (int i = 0; i < fraction.length(); ++i) {
418
                if (fraction.charAt(i) != '0') {
419
                    break;
420
                }
421

  
422
                --fracFigs;
423
            }
424
        }
425

  
426
        int mantFigs = numFigs + fracFigs;
427

  
428
        if (sigFigs > mantFigs) {
429
            // We want more figures; just append zeros to the fraction.
430
            for (int i = mantFigs; i < sigFigs; ++i)
431
                fraction.append('0');
432
        } else if ((sigFigs < mantFigs) && (sigFigs >= numFigs)) {
433
            // Want fewer figures in the fraction; chop.
434
            fraction.setLength(fraction.length() -
435
                (fracFigs - (sigFigs - numFigs)));
436

  
437
            // Round?
438
        } else if (sigFigs < numFigs) {
439
            // Want fewer figures in the number; turn them to zeros.
440
            fraction.setLength(0); // should already be zero, but make sure
441

  
442
            for (int i = sigFigs; i < numFigs; ++i)
443
                number.setCharAt(i, '0');
444

  
445
            // Round?
446
        }
447

  
448
        // Else sigFigs == mantFigs, which is fine.
449
        if (fraction.length() == 0) {
450
            return sign + number + exponent;
451
        } else {
452
            return sign + number + "." + fraction + exponent;
453
        }
454
    }
455

  
456
    /// Improved version of Double.toString(), returns more decimal places.
457
    // <P>
458
    // The JDK 1.0.2 version of Double.toString() returns only six decimal
459
    // places on some systems.  In JDK 1.1 full precision is returned on
460
    // all platforms.
461
    // @deprecated
462
    // @see java.lang.Double#toString
463
    public static String doubleToString(double d) {
464
        // Handle special numbers first, to avoid complications.
465
        if (Double.isNaN(d)) {
466
            return "NaN";
467
        }
468

  
469
        if (d == Double.NEGATIVE_INFINITY) {
470
            return "-Inf";
471
        }
472

  
473
        if (d == Double.POSITIVE_INFINITY) {
474
            return "Inf";
475
        }
476

  
477
        // Grab the sign, and then make the number positive for simplicity.
478
        boolean negative = false;
479

  
480
        if (d < 0.0D) {
481
            negative = true;
482
            d = -d;
483
        }
484

  
485
        // Get the native version of the unsigned value, as a template.
486
        String unsStr = Double.toString(d);
487

  
488
        // Dissect out the exponent.
489
        String mantStr;
490

  
491
        // Dissect out the exponent.
492
        String expStr;
493
        int exp;
494
        int eInd = unsStr.indexOf('e');
495

  
496
        if (eInd == -1) { // it may be 'e' or 'E'
497
            eInd = unsStr.indexOf('E');
498
        }
499

  
500
        if (eInd == -1) {
501
            mantStr = unsStr;
502
            expStr = "";
503
            exp = 0;
504
        } else {
505
            mantStr = unsStr.substring(0, eInd);
506
            expStr = unsStr.substring(eInd + 1);
507

  
508
            if (expStr.startsWith("+")) {
509
                exp = Integer.parseInt(expStr.substring(1));
510
            } else {
511
                exp = Integer.parseInt(expStr);
512
            }
513
        }
514

  
515
        // Dissect out the number part.
516
        String numStr;
517
        int dotInd = mantStr.indexOf('.');
518

  
519
        if (dotInd == -1) {
520
            numStr = mantStr;
521
        } else {
522
            numStr = mantStr.substring(0, dotInd);
523
        }
524

  
525
        long num;
526

  
527
        if (numStr.length() == 0) {
528
            num = 0;
529
        } else {
530
            num = Integer.parseInt(numStr);
531
        }
532

  
533
        // Build the new mantissa.
534
        StringBuffer newMantBuf = new StringBuffer(numStr + ".");
535
        double p = Math.pow(10, exp);
536
        double frac = d - (num * p);
537
        String digits = "0123456789";
538
        int nDigits = 16 - numStr.length(); // about 16 digits in a double
539

  
540
        for (int i = 0; i < nDigits; ++i) {
541
            p /= 10.0D;
542

  
543
            int dig = (int) (frac / p);
544

  
545
            if (dig < 0) {
546
                dig = 0;
547
            }
548

  
549
            if (dig > 9) {
550
                dig = 9;
551
            }
552

  
553
            newMantBuf.append(digits.charAt(dig));
554
            frac -= (dig * p);
555
        }
556

  
557
        if ((int) ((frac / p) + 0.5D) == 1) {
558
            // Round up.
559
            boolean roundMore = true;
560

  
561
            for (int i = newMantBuf.length() - 1; i >= 0; --i) {
562
                int dig = digits.indexOf(newMantBuf.charAt(i));
563

  
564
                if (dig == -1) {
565
                    continue;
566
                }
567

  
568
                ++dig;
569

  
570
                if (dig == 10) {
571
                    newMantBuf.setCharAt(i, '0');
572

  
573
                    continue;
574
                }
575

  
576
                newMantBuf.setCharAt(i, digits.charAt(dig));
577
                roundMore = false;
578

  
579
                break;
580
            }
581

  
582
            if (roundMore) {
583
                // If this happens, we need to prepend a 1.  But I haven't
584
                // found a test case yet, so I'm leaving it out for now.
585
                // But if you get this message, please let me know!
586
                newMantBuf.append("ROUNDMORE");
587
            }
588
        }
589

  
590
        // Chop any trailing zeros.
591
        int len = newMantBuf.length();
592

  
593
        while (newMantBuf.charAt(len - 1) == '0')
594
            newMantBuf.setLength(--len);
595

  
596
        // And chop a trailing dot, if any.
597
        if (newMantBuf.charAt(len - 1) == '.') {
598
            newMantBuf.setLength(--len);
599
        }
600

  
601
        // Done.
602
        return (negative ? "-" : "") + newMantBuf +
603
        ((expStr.length() != 0) ? ("e" + expStr) : "");
604
    }
605

  
606
    /******************************************************************************
607
        /// Test program.
608
        public static void main( String[] args )
609
            {
610
            System.out.println( "Starting tests." );
611
            show( Fmt.fmt( "Hello there." ) );
612
            show( Fmt.fmt( 123 ) );
613
            show( Fmt.fmt( 123, 10 ) );
614
            show( Fmt.fmt( 123, 10, Fmt.ZF ) );
615
            show( Fmt.fmt( 123, 10, Fmt.LJ ) );
616
            show( Fmt.fmt( -123 ) );
617
            show( Fmt.fmt( -123, 10 ) );
618
            show( Fmt.fmt( -123, 10, Fmt.ZF ) );
619
            show( Fmt.fmt( -123, 10, Fmt.LJ ) );
620
            show( Fmt.fmt( (byte) 0xbe, 22, Fmt.OC ) );
621
            show( Fmt.fmt( (short) 0xbabe, 22, Fmt.OC ) );
622
            show( Fmt.fmt( 0xcafebabe, 22, Fmt.OC ) );
623
            show( Fmt.fmt( 0xdeadbeefcafebabeL, 22, Fmt.OC ) );
624
            show( Fmt.fmt( 0x8000000000000000L, 22, Fmt.OC ) );
625
            show( Fmt.fmt( (byte) 0xbe, 16, Fmt.HX ) );
626
            show( Fmt.fmt( (short) 0xbabe, 16, Fmt.HX ) );
627
            show( Fmt.fmt( 0xcafebabe, 16, Fmt.HX ) );
628
            show( Fmt.fmt( 0xdeadbeefcafebabeL, 16, Fmt.HX ) );
629
            show( Fmt.fmt( 0x8000000000000000L, 16, Fmt.HX ) );
630
            show( Fmt.fmt( 'c' ) );
631
            show( Fmt.fmt( new java.util.Date() ) );
632
            show( Fmt.fmt( 123.456F ) );
633
            show( Fmt.fmt( 123456000000000000.0F ) );
634
            show( Fmt.fmt( 123.456F, 0, 8 ) );
635
            show( Fmt.fmt( 123.456F, 0, 7 ) );
636
            show( Fmt.fmt( 123.456F, 0, 6 ) );
637
            show( Fmt.fmt( 123.456F, 0, 5 ) );
638
            show( Fmt.fmt( 123.456F, 0, 4 ) );
639
            show( Fmt.fmt( 123.456F, 0, 3 ) );
640
            show( Fmt.fmt( 123.456F, 0, 2 ) );
641
            show( Fmt.fmt( 123.456F, 0, 1 ) );
642
            show( Fmt.fmt( 123456000000000000.0F, 0, 4 ) );
643
            show( Fmt.fmt( -123.456F, 0, 4 ) );
644
            show( Fmt.fmt( -123456000000000000.0F, 0, 4 ) );
645
            show( Fmt.fmt( 123.0F ) );
646
            show( Fmt.fmt( 123.0D ) );
647
            show( Fmt.fmt( 1.234567890123456789F ) );
648
            show( Fmt.fmt( 1.234567890123456789D ) );
649
            show( Fmt.fmt( 1234567890123456789F ) );
650
            show( Fmt.fmt( 1234567890123456789D ) );
651
            show( Fmt.fmt( 0.000000000000000000001234567890123456789F ) );
652
            show( Fmt.fmt( 0.000000000000000000001234567890123456789D ) );
653
            show( Fmt.fmt( 12300.0F ) );
654
            show( Fmt.fmt( 12300.0D ) );
655
            show( Fmt.fmt( 123000.0F ) );
656
            show( Fmt.fmt( 123000.0D ) );
657
            show( Fmt.fmt( 1230000.0F ) );
658
            show( Fmt.fmt( 1230000.0D ) );
659
            show( Fmt.fmt( 12300000.0F ) );
660
            show( Fmt.fmt( 12300000.0D ) );
661
            show( Fmt.fmt( Float.NaN ) );
662
            show( Fmt.fmt( Float.POSITIVE_INFINITY ) );
663
            show( Fmt.fmt( Float.NEGATIVE_INFINITY ) );
664
            show( Fmt.fmt( Double.NaN ) );
665
            show( Fmt.fmt( Double.POSITIVE_INFINITY ) );
666
            show( Fmt.fmt( Double.NEGATIVE_INFINITY ) );
667
            show( Fmt.fmt( 1.0F / 8.0F ) );
668
            show( Fmt.fmt( 1.0D / 8.0D ) );
669
            System.out.println( "Done with tests." );
670
            }
671

  
672
        private static void show( String str )
673
            {
674
            System.out.println( "#" + str + "#" );
675
            }
676
    ******************************************************************************/
677
}
0 678

  
branches/gvSIG_CAD/applications/appgvSIG/src/com/vividsolutions/jump/util/DebugTimer.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 * 
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
package com.vividsolutions.jump.util;
35

  
36
import com.vividsolutions.jts.util.Stopwatch;
37

  
38

  
39
public class DebugTimer {
40
    private static final int TIME_LEN = 10;
41
    private static DebugTimer timer = new DebugTimer();
42
    private Stopwatch sw = null;
43
    private String blankStr;
44

  
45
    public DebugTimer() {
46
        sw = new Stopwatch();
47
        sw.start();
48
        blankStr = fillString(TIME_LEN, ' ');
49
    }
50

  
51
    public static void startStatic(String msg) {
52
        timer.start(msg);
53
    }
54

  
55
    public static void logEventStatic(String msg) {
56
        timer.logEvent(msg);
57
    }
58

  
59
    public void start(String msg) {
60
        System.out.println("Started    " + msg);
61
        sw.start();
62
    }
63

  
64
    public void logEvent(String msg) {
65
        String elapsedStr = formatTime(sw.getTimeString());
66
        System.out.println("Elapsed: " + elapsedStr + "    " + msg);
67
        sw.start();
68
    }
69

  
70
    public String formatTime(String timeStr) {
71
        if (timeStr.length() < TIME_LEN) {
72
            String filled = blankStr + timeStr;
73
            int start = filled.length() - TIME_LEN;
74

  
75
            return filled.substring(start);
76
        }
77

  
78
        // don't pad if it's already longer
79
        return timeStr;
80
    }
81

  
82
    public String fillString(int len, char ch) {
83
        StringBuffer buf = new StringBuffer(len);
84

  
85
        for (int i = 0; i < len; i++) {
86
            buf.append(ch);
87
        }
88

  
89
        return buf.toString();
90
    }
91
}
0 92

  
branches/gvSIG_CAD/applications/appgvSIG/src/com/vividsolutions/jump/util/MathUtil.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 * 
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
package com.vividsolutions.jump.util;
35

  
36

  
37
/**
38
 * Additional math utilities.
39
 * @see Math
40
 */
41
public class MathUtil {
42
    public MathUtil() {
43
    }   
44

  
45
    public static double orderOfMagnitude(double x) {
46
        return base10Log(x);
47
    }
48

  
49
    public static double base10Log(double x) {
50
        return Math.log(x) / Math.log(10);
51
    }
52

  
53
    public static int mostSignificantDigit(double x) {
54
        return (int) (x / Math.pow(10, Math.floor(MathUtil.orderOfMagnitude(x))));
55
    }
56

  
57
    /**
58
     * Returns the average of two doubles
59
     * @param a one of the doubles to average
60
     * @param b the other double to average
61
     * @return the average of two doubles
62
     */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff