Package com.confluenity.jaylen.io

Examples of com.confluenity.jaylen.io.JsrcFile$Frame


    if (selected == null) {
      return;
    }
    UUID uuid = null;
    try {
      uuid = context.addJsrcFile(new JsrcFile(selected.getFilePath(), "r"));
    } catch (IOException e) {
      logger.error(e.getLocalizedMessage(), e);
    }
    JsrcFile jsrc = context.getJsrcFile(uuid);
    if(jsrc != null) {
      Tree tree = springContext.getBean("objectTree", Tree.class);
      TreeItem treeItem = new TreeItem(tree, SWT.NONE);
      treeItem.setImage(springContext.getBean("treeItemGlyph", Image.class));
      treeItem.setText(new String[] {jsrc.getFileType(), String.valueOf(jsrc.getFrameCount()), String.valueOf(jsrc.getPointCount())});
      treeItem.setData(uuid);
    }

  }
View Full Code Here


    Canvas.class.cast(owner).addPaintListener(this);
  }

  @Override
  public void paintControl(PaintEvent event) {
    final JsrcFile jsrc = context.getJsrcFile(context.getSelectedFile());
    if(jsrc == null) {
      return;
    }
    Integer f = context.getSelectedFrame(jsrc.getUuid());
    if (f < 0) {
      return;
    }
    Rectangle rectangle = ((Canvas) event.widget).getBounds();
    event.gc.setForeground(event.display.getSystemColor(SWT.COLOR_DARK_GRAY));
    event.gc.drawFocus(5, 5, rectangle.width - 15, rectangle.height - 15);
    try {
      JsrcFile.Frame frame = jsrc.readFrame(f);
      double size = Double.parseDouble(jsrc.getHeader().getItem("size"));
      double halfSize = size*0.5;
      for (JsrcFile.Frame.Particle particle : frame.getParticles()) {
        int x = (int)(((particle.getRx() + halfSize) / size) * (double)(rectangle.width - 20));
        int y = (int)(((halfSize - particle.getRy()) / size) * (double)(rectangle.height - 20));
        event.gc.drawOval(x + 10 - 2, y + 10 - 2, 4, 4);
View Full Code Here

      case ODS: exportToOds(selected); break;
    }
  }

  private JsrcFile.Frame getFrame() throws IOException {
    final JsrcFile jsrc = context.getJsrcFile(context.getSelectedFile());
    if (jsrc == null) {
      return null;
    }
    return jsrc.readFrame(context.getSelectedFrame(jsrc.getUuid()));
  }
View Full Code Here

    TreeItem[] selection = Tree.class.cast(owner).getSelection();
    if (selection.length > 0) {
      TreeItem item = selection[0];
      UUID uuid = UUID.class.cast(item.getData());
      context.setSelectedFile(uuid);
      JsrcFile jsrc = context.getJsrcFile(uuid);
      frameScale.setMaximum(jsrc.getFrameCount() - 1);
      dataTable.removeAll();
      {
        TableItem tableItem = new TableItem(dataTable, SWT.NONE);
        tableItem.setText(new String[] {"File name", jsrc.getName()});
      }
      for (String name : jsrc.getHeader().getNames()) {
        TableItem tableItem = new TableItem(dataTable, SWT.NONE);
        tableItem.setText(new String[] {name, jsrc.getHeader().getItem(name)});
      }
      context.setSelectedFrame(jsrc.getUuid(), 0);
      canvas.redraw();
    }
  }
View Full Code Here

    super(type, owner);
  }

  @Override
  public void handleEvent(Event event) {
    final JsrcFile jsrc = context.getJsrcFile(context.getSelectedFile());
    if(jsrc == null) {
      return;
    }
    context.setSelectedFrame(jsrc.getUuid(), Scale.class.cast(owner).getSelection());
    canvas.redraw();
  }
View Full Code Here

      Animation animation) {
    d.printSection(animation.getName());
    d.printKeyValue("DefaultKeyDuration",""+animation.getDefaultKeyDuration());
    Frame[] frames = animation.getFrames();
    for(int fi=0; fi<frames.length; fi++) {
      Frame f = frames[fi];
      d.printKeyValue("KeyData"+(fi+1),f.getName());
      if(f.getKeyDuration()>0)
        d.printKeyValue("KeyDuration"+(fi+1),""+f.getKeyDuration());
    }
    for(int fi=0; fi<frames.length; fi++) {
      Frame f = frames[fi];
      Point offset = f.getOffset();
      if(offset.x!=0 || offset.y!=0) {
        d.printKeyValue("KeyEventName"+(fi+1),"__"+fi);
        d.printKeyValue("__"+fi, "("+offset.x+","+offset.y+",0)");       
      }
    }
View Full Code Here

    return null;
  }

  @Override
  public long getFrameDelay(int index) {
    Frame frame = getFrame(index);
    return (long) (frame.getFinalFrameDuration()*1000);
  }
 
View Full Code Here

        for(Frame frame: animation.getFrames()) {
          paintFrame(g, frame);
        }
      }
      if (selected instanceof Frame) {
        Frame frame = (Frame) selected;
        paintFrame(g,frame);
      }   
    }
    if(freeOffsetStart != null && freeOffsetEnd != null) {
      Point base = toScreen(freeOffsetStart);
View Full Code Here

  private int snap(int snapMe){
    return java.lang.Math.round( snapMe/parent.SnapSlider.getValue() )*parent.SnapSlider.getValue();
  }
 
  @Override public void mouseDragged(MouseEvent e) {
    Frame selected = getSelectedFrame();
    if(selected==null) return;
    if((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) {
      if(parent.isSettingOffsetDirectly())
        handleEditOffset(selected,e);     
      if(parent.isSettingOffsetWithRelativePos())
        freeOffsetEnd = getViewPoint(e);
      if(parent.isSettingPivot()) 
        selected.setPivot(new Point(getViewX(e),getViewY(e)));
      if(parent.isRectangleLocked()) {
        int x = snap(getViewX(e)), y = snap(getViewY(e))

        selected.setRectangle(new Rectangle(x,y,parent.lockRectButton.lastRect.width,parent.lockRectButton.lastRect.height));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));

        int PivotDX = parent.lockRectButton.lastPivot.x - parent.lockRectButton.lastRect.x;
        int PivotDY = parent.lockRectButton.lastPivot.y - parent.lockRectButton.lastRect.y;
        selected.setPivot(new Point(x+PivotDX,y+PivotDY));
      }
      if(parent.isEditingRectangle()){
       
        Rectangle rect = selected.getRectangle();
        int x = snap(rect.x), y = snap(rect.y);
        int dx = snap(getViewX(e)-x), dy = snap(getViewY(e)-y);
        Rectangle newRectangle = new Rectangle(x,y,dx,dy);
        selected.setRectangle(newRectangle);
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
      }
      if(parent.isSettingOffsetWithTemporaryPivot()) {
        if(parent.temporaryPivotOffsetButton.getPivot2()!=null) {
          parent.temporaryPivotOffsetButton.setPivot2(getViewPoint(e));
          selected.setOffset(parent.temporaryPivotOffsetButton.getOffset());
        }
        else
          parent.temporaryPivotOffsetButton.setPivot1(getViewPoint(e));
      }
    }
View Full Code Here

    repaint(20);
  }

  @Override
  public void mousePressed(MouseEvent e) {
    Frame selected  = getSelectedFrame();
    if(selected==null) return;
 
    if(e.getButton() == MouseEvent.BUTTON3) {
      if(parent.isSettingOffsetDirectly()) {
            handleEditOffset(selected, e);
      }
        if (parent.isSettingOffsetWithRelativePos()) {
          freeOffsetStart = getViewPoint(e);
        }
      if(parent.isSettingPivot()) {
        selected.setPivot(new Point(getViewX(e),getViewY(e)));
      }   
      if (parent.isRectangleLocked()) {
        selected.setRectangle(new Rectangle(getViewX(e),getViewY(e),parent.lockRectButton.lastRect.width,parent.lockRectButton.lastRect.height));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
        int PivotDX = parent.lockRectButton.lastPivot.x - parent.lockRectButton.lastRect.x;
        int PivotDY = parent.lockRectButton.lastPivot.y - parent.lockRectButton.lastRect.y;
        selected.setPivot(new Point(getViewX(e)+PivotDX,getViewY(e)+PivotDY));         
      }
      if(parent.isEditingRectangle()) {
        selected.setRectangle(new Rectangle(getViewX(e),getViewY(e),0,0));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
        selected.setPivot(null);
      }
      if(parent.isSettingOffsetWithTemporaryPivot()) {
        if(parent.temporaryPivotOffsetButton.getPivot1()==null) {
          parent.temporaryPivotOffsetButton.setPivot1(getViewPoint(e));
        } else {
          parent.temporaryPivotOffsetButton.setPivot2(getViewPoint(e));
          selected.setOffset(parent.temporaryPivotOffsetButton.getOffset());
        }
      }
    }
    repaint(20);
  }
View Full Code Here

TOP

Related Classes of com.confluenity.jaylen.io.JsrcFile$Frame

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.