NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Bill. I'm using DisplayImplJ2D. I need the text with Serif font by to show "tildes" (á é í ó ú). This is my code: display = new DisplayImplJ2D("display"); GraphicsModeControl dispGMC = (GraphicsModeControl) display.getGraphicsModeControl(); dispGMC.setScaleEnable(true); varRaster = new RealType("varRaster"); texField = new TextType("text"); lonMap = new ScalarMap( RealType.Longitude, Display.XAxis ); latMap = new ScalarMap( RealType.Latitude, Display.YAxis ); varMap = new ScalarMap( varRaster, Display.RGB ); texMap = new ScalarMap( texField, Display.Text ); display.addMap( latMap ); display.addMap( lonMap ); display.addMap( varMap ); display.addMap( texMap ); TextControl tcontrol = (TextControl) texMap.getControl(); Font font = new Font("Serif", Font.PLAIN, 60); tcontrol.setFont(font); /* se construye la referencia del flatField*/ Linear2DSet dominio; FunctionType funcionTransfer; campo=new RealTupleType(RealType.Longitude,RealType.Latitude); funcionTransfer = new FunctionType(campo, varRaster); dominio = new Linear2DSet(campo,-80,-65,900,-5,13,1080); float[][]datos={new Raster().getDatos()}; valores = new FlatField( funcionTransfer, dominio,null,null,new Integer1DSet[]{new Integer1DSet(varRaster, 1087)},null); valores.setSamples(datos, false); DataReferenceImpl data_ref = new DataReferenceImpl("data_ref"); data_ref.setData(valores); display.addReference(data_ref); ProjectionControl pc = display.getProjectionControl(); pc.setAspectCartesian(new double[] {1.0, (double) (1080/900d)}); /*se construye la referencia del texto */ RealType[] time = {RealType.Time}; RealTupleType time_type = new RealTupleType(time); MathType[] mtypes = {RealType.Latitude, RealType.Longitude, texField}; TupleType text_tuple = new TupleType(mtypes); FunctionType text_function = new FunctionType(RealType.Time, text_tuple); String[] names = {"texto con tílsde"}; int ntimes1 = names.length; Set time_set = new Linear1DSet(time_type, 0.0, (double) (ntimes1 - 1.0), ntimes1); FieldImpl text_field = new FieldImpl(text_function, time_set); for (int i=0; i<ntimes1; i++) { Data[] td = {new Real(RealType.Latitude, (double)5), new Real(RealType.Longitude, (double)-75), new Text(texField, names[i])}; Tuple tt = new Tuple(text_tuple, td); text_field.setSample(i, tt); } ref_text_field = new DataReferenceImpl("ref_text_field"); ref_text_field.setData(text_field); display.addReference(ref_text_field); //---------------- If I comment the line tcontrol.setFont(font), the text is showed, but without "í", and if I dón't comment that, the text appears under the flatfield. Thank's a lot. Olver > Hi Olver, > > You are probably using a DisplayImplJ2D or a DisplayImplJ3D > with a TwoDDisplayRendererJ3D. In both cases it wll try to > display lines and points over filled triangles. Text without > a font (or with a Hershey font) uses lines, text with a font > uses triangles (and hence go behind the lines of your FlatField). > > The easiest approach is to use a Hershey font. > > Another apporach is possible if you are using a DisplayImplJ3D > with a TwoDDisplayRendererJ3D. It is to not use the > TwoDDisplayRendererJ3D, but instead use: > > GraphicsModeControl mode = display.getGraphicsModeControl(); > mode.setProjectionPolicy(DisplayImplJ3D.PARALLEL_PROJECTION); > > You may also want to call MouseHelper.setFunctionMap() to > disable rotation (see an example of this function in > visad/examples/Test00.java). > > By not using TwoDDisplayRendererJ3D, you can use ConstantMaps > to ZAxis to explicitly place your Text and FlatField in depth > to control what's over what. > > Good luck, > Bill > > On Tue, 22 Apr 2003, OLVER OLFREY HERNANDEZ NAVARRO wrote: > >> Hi Bill. >> >> Thanks. >> >> A SIG (Sistema de Información Geográfica) is a GIS. >> >> textField is a TextType and textMap is a ScalarMap to Display.Text. >> >> Thanks a lot >> >> Olver. >> >> >> > Hi Olver, >> > >> > What are TextField and TextMap? Are they your own classes >> > of is TextField a FieldIMpl with a TextType in the range, >> > and TextMap a ScalarMap to Display.Text? Also, what's a >> > SIG? >> > >> > Cheers, >> > Bill >> > >> > On Mon, 21 Apr 2003, OLVER OLFREY HERNANDEZ NAVARRO wrote: >> > >> >> Hi All. >> >> >> >> I'm working in a SIG, and I need to show a Reference with a >> FlatField and a reference with a TextField. When I get the control >> of the TextMap, and I set the Font, the TextField is showed under >> the flatfield, but if I don't set the font the flatField is showed >> under the textFiel. >> >> >> >> I need to set the font and that the FlatField is shown under the >> textFiel. Can I do this??? >> >> >> >> Olver.
visad
archives: