Package com.tinyline.svg

Examples of com.tinyline.svg.SVGRect


   * @param y the number of pixels to move vertically, moved the display viewport
   */
  public void pan( int x, int y )
  {
    // Get the current viewport
    SVGRect view = raster.view;
    // Get the SVGT document
    SVGDocument doc = raster.getSVGDocument();
    // Get the root of the SVGT document
    SVGSVGElem root = (SVGSVGElem)doc.root;
    // Get the current scale value
View Full Code Here


   * for zooming in and less than 1.0 for zooming out.
   */
  public void zoom( double scaleFactor )
  {
    // Get the current viewport
    SVGRect view = raster.view;
    // Get the SVGT document
//    SVGDocument doc = raster.getSVGDocument();
    // Get the root of the SVGT document
//    SVGSVGElem root = (SVGSVGElem)doc.root;
    // Get the current scale value
View Full Code Here

  /**
   * Reset the image to its original size and position
   */
  public void reset()
  {
    SVGRect view = raster.view;
    view.x = raster.origview.x;
    view.y = raster.origview.y;
    view.width = raster.origview.width;
    view.height = raster.origview.height;
   
View Full Code Here

  public void handleEvent(Event evt)
  {
//  System.out.println("handleEvent " + evt.getType());
   
    SVGEvent theEvent = (SVGEvent) evt;
    SVGRect view,origview;
    SVGDocument document;
    TinyPoint point;
    TinyRect  rect;
    SVGEvent event;
    String url;
   
    switch(theEvent.id)
    {
      case SVGEvent.EVENT_UPDATE:
        //long t1 = System.currentTimeMillis();
        //System.out.println("UPDATE" + "[ " + data.xmin +"," + data.ymin +","+ data.xmax+"," + data.ymax +"]");
        canvas.raster.setDevClip((TinyRect)theEvent.data);
        canvas.raster.update();
        canvas.raster.sendPixels();
       
        //long t2 = System.currentTimeMillis();
        //System.out.println("handleUpdateEvent elapsed time ms: " +(t2-t1) );
        break;
       
      case SVGEvent.EVENT_ANIMATE:
        //    System.out.println("handleAnimateEvent: " + animationsCount );
        document =  canvas.raster.document;
//                   System.out.println("document.nActiveAnimations: " + document.nActiveAnimations );
//                   if(document.nActiveAnimations > 0)
        {
          rect = document.animate(getCurrentTime());
          event = new SVGEvent(SVGEvent.EVENT_UPDATE, rect );
          canvas.postEvent(event);
        }
        // If there are not finished animations, produce a new
        // animation event.
        if( document.nActiveAnimations > 0 && !animationsPaused() )
        {
          event = new SVGEvent(SVGEvent.EVENT_ANIMATE,null);
          canvas.postEvent(event);
        }
        break;
       
      case SVGEvent.EVENT_BEGIN:
      case SVGEvent.EVENT_END:
      case SVGEvent.EVENT_REPEAT:
        document =  canvas.raster.document;
        TinyString smilEvent =  (TinyString)theEvent.data;
        if(document.resolveEventBased(smilEvent))
        {
          event = new SVGEvent(SVGEvent.EVENT_ANIMATE,null);
          canvas.postEvent(event);
        }
        break;
       
      case SVGEvent.EVENT_LOAD:
        // 1. Reset the event queue
        canvas.eventQueue.reset();
        // 2. Load the document
        url = (String)theEvent.data;
        document = canvas.loadSVG(url);
        if(document == null)
        {
          break;
        }
        // 3. Set the loaded document to be current document
        canvas.currentURL = new String(url);
        canvas.raster.setSVGDocument(document);
        // 4. Set the original view
        view     = canvas.raster.view;
        origview = canvas.raster.origview;
        view.x      = origview.x;
        view.y      = origview.y;
        view.width  = origview.width;
        view.height = origview.height;
        // 5. Set the camera transform
        canvas.raster.setCamera();
       
        // 6. Clear animTargets and add animation elements
        // if are there any
        document.nActiveAnimations = 0;
        document.animTargets.count = 0;
        document.addAnimations(document.root);
        // 7. Set the animation call back for SMIL events
        document.acb = this;
        // 8. Set the start time
        setStartTime();
       
        // 9. Fire the animation event
        event = new SVGEvent(SVGEvent.EVENT_ANIMATE,null);
        canvas.postEvent(event);
       
        // 10. Fire the update event
        event = new SVGEvent(SVGEvent.EVENT_UPDATE, canvas.raster.getDevClip() );
        canvas.postEvent(event);
        break;
       
      case SVGEvent.EVENT_SCROLL:
        document =  canvas.raster.document;
        // If the current document is not zoom and pan anabled then
        // just quit
        if(!document.isZoomAndPanAnable()) return;
        // 1. Get the drag point
        point = (TinyPoint)theEvent.data;
        SVGSVGElem root = (SVGSVGElem)document.root;
        // 2. Get the current scale
        int scale = root.getCurrentScale();
        // 3. Calculate the new current view
        view = canvas.raster.view;
        view.x += TinyUtil.div(point.x<<TinyUtil.FIX_BITS,scale);
        view.y += TinyUtil.div(point.y<<TinyUtil.FIX_BITS,scale);
        // 5. Set the camera transform
        canvas.raster.setCamera();
        // 6. Fire the update event
        event = new SVGEvent(SVGEvent.EVENT_UPDATE, canvas.raster.getDevClip() );
        canvas.postEvent(event);
        break;
       
      case SVGEvent.EVENT_UNLOAD:
        break;
       
      case SVGEvent.EVENT_ZOOM:
        document =  canvas.raster.document;
        if(!document.isZoomAndPanAnable()) return;
       
        TinyNumber direction = (TinyNumber)theEvent.data;
        // zoom in '0' size / 2
        if(direction.val == 0)
        {
          zoomLevel--;
          if(zoomLevel < MIN_ZOOMLEVEL)
          {
            zoomLevel = MIN_ZOOMLEVEL;
            return;
          }
        }
        else //zoom out size * 2
        {
          zoomLevel++;
          if(zoomLevel > MAX_ZOOMLEVEL)
          {
            zoomLevel = MAX_ZOOMLEVEL;
            return;
          }
        }
        SVGRect newView = new SVGRect();
        view = canvas.raster.view;
        int  midX = view.x + view.width/2;
        int  midY = view.y + view.height/2;
        // zoom in '0' size / 2
        if(direction.val == 0)
View Full Code Here

TOP

Related Classes of com.tinyline.svg.SVGRect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.