1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    22
    Vote Rating
    0
    hrishirise is on a distinguished road

      0  

    Default How do i add Text or inner sprites in RectangleSprite

    How do i add Text or inner sprites in RectangleSprite


    Hi,
    I would like to add "text" or Text Sprite in side a RectangleSprite rectangle. How do i perform this?

  2. #2
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    Aha, the kind of question I love, even more as I hadn't an opportunity to play much with the drawing API.
    But your question is a bit vague. I suppose you won't place the text inside the rectangle, but above it. But what position the text will have? The most likely is centred, but there are other possibilities. Do you allow overflow? Do you want to adjust the rectangle to the size of the text? Etc.

  3. #3
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Vote Rating
    1
    PhiLho is on a distinguished road

      1  

    Default


    My attempt:
    Code:
          DrawComponent draw = new DrawComponent(400, 400);
          RectangleSprite rect = new RectangleSprite(300, 100, 20, 20);
          rect.setFill(new Color("#FFC"));
          draw.addSprite(rect);
          TextSprite text = new TextSprite("I fit in a rectangle");
          text.setFont("Verdana");
          text.setFontSize(18);
          text.setTranslation(rect.getX() + 40, rect.getY() + 40);
          System.out.println(text.getBBox());
          text.setFill(new Color("#88F"));
          draw.addSprite(text);
          layout.add(draw);
    The problem is that at construction time, the bounding box of text is not known. It is known only after it has been rendered on screen. So it is quite hard to center text in the rectangle, or do similar alignments.
    I am not sure of how to handle this problem, except by waiting for rendering and adding elements after.
    I tried that when I had to add lines or areas on a chart, fitting between the axes: I can do it only on an event (eg. clicking on a button). I don't know if there is an event generated when rendering is finished...

  4. #4
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    Actually, the drawing API is quite simple, enough for charts and some animations, but it is not a full scenegraph, far from it. I don't know if we can change the z-order of sprites*, there is no possibility to nest the sprites (which is perhaps what you were looking for), etc.
    That's not JavaFX...

    * Actually, Sprite as a zIndex field. Beta 2 still has an inconsistency, with a getzIndex and a setZIndex...

  5. #5
    Sencha - GXT Dev Team BrendanC's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Vote Rating
    3
    BrendanC is on a distinguished road

      0  

    Default


    If your component was already attached you could call redrawSurfaceForced to attach the surface and then add text and call text.redraw before getting the bound box. This is the limitation of using the SVG text bounding box calculations. The text element needs to be attached to the DOM.

    In regards to zIndex that is a known issue and will be seen to. That is one of the rare cases where VML has built in functionality that SVG lacks. Also, thanks for pointing out that inconsistency. I just fixed it in SVN.

  6. #6
    Sencha - GXT Dev Team BrendanC's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Vote Rating
    3
    BrendanC is on a distinguished road

      0  

    Default


    Alright z-index sorting is now fixed for SVG. This change is in SVN and will be in the next release.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi