@Override protected void update(BoneRef ref, Bone root, int time) { boolean isObject = ref instanceof ObjectRef; // Tween bone/object Bone bone1 = null, bone2 = null, tweenTarget = null; Timeline t1 = onFirstMainLine() ? anim1.getTimeline(ref.timeline) : anim1.getSimilarTimeline(anim2.getTimeline(ref.timeline)); Timeline t2 = onFirstMainLine() ? anim2.getSimilarTimeline(t1) : anim2.getTimeline(ref.timeline); Timeline targetTimeline = super.getTimeline(onFirstMainLine() ? t1.id : t2.id); if (t1 != null) bone1 = anim1.tweenedKeys[t1.id].object(); if (t2 != null) bone2 = anim2.tweenedKeys[t2.id].object(); if (targetTimeline != null) tweenTarget = this.tweenedKeys[targetTimeline.id].object(); if (isObject && (t2 == null || !tweenSprites)) { if (!onFirstMainLine()) bone1 = bone2; else bone2 = bone1; } if (bone2 != null && tweenTarget != null && bone1 != null) { if (isObject) this.tweenObject( (Object) bone1, (Object) bone2, (Object) tweenTarget, this.weight, this.curve); else this.tweenBone(bone1, bone2, tweenTarget, this.weight, this.curve); this.unmappedTweenedKeys[targetTimeline.id].active = true; } // Transform the bone relative to the parent bone or the root if (this.unmappedTweenedKeys[ref.timeline].active) { this.unmapTimelineObject( targetTimeline.id, isObject, (ref.parent != null) ? this.unmappedTweenedKeys[ref.parent.timeline].object() : root); } }
public void updateArmor() { TextureFilm film = new TextureFilm(tiers(), ((Hero) ch).tier(), FRAME_WIDTH, FRAME_HEIGHT); idle = new Animation(1, true); idle.frames(film, 0, 0, 0, 1, 0, 0, 1, 1); run = new Animation(RUN_FRAMERATE, true); run.frames(film, 2, 3, 4, 5, 6, 7); die = new Animation(20, false); die.frames(film, 8, 9, 10, 11, 12, 11); attack = new Animation(15, false); attack.frames(film, 13, 14, 15, 0); zap = attack.clone(); operate = new Animation(8, false); operate.frames(film, 16, 17, 16, 17); fly = new Animation(1, true); fly.frames(film, 18); read = new Animation(20, false); read.frames(film, 19, 20, 20, 20, 20, 20, 20, 20, 20, 19); }
/** * From the "animationInfo" set of animation properties, set all these values into all the * Animation objects held as memeber data. * * @param transfer AnimationInfo to get properties from */ public void setProperties(AnimationInfo transfer) { setBoxPanelVisible(transfer.getBoxesVisible()); animationInfo.set(transfer); setSharing(animationInfo.shared); if (animationInfo.getAnimationGroup() != null) { setShareGroup(animationInfo.getAnimationGroup()); } if (propertiesDialog != null) { propertiesDialog.setInfo(animationInfo); } try { if (anime != null) { anime.setAnimationInfo(animationInfo); DisplayMaster displayMaster = anime.getDisplayMaster(); if (displayMaster != null) { displayMaster.dataChange(); } else { if (getAnimationSetInfo().getActive()) { anime.setSet(getAnimationSetInfo().makeTimeSet(null)); } else { anime.setSet(getAnimationSetInfo().getBaseTimes()); } } } } catch (Exception exp) { LogUtil.logException("Error setting properties", exp); } updateRunButton(); checkAutoUpdate(); }
private void changeItem(SequenceItem item) { if (item.color != null) LEDCubeManager.setPaintColor(item.color); if (item.clear) { LEDManager ledManager = LEDCubeManager.getLEDManager(); Dimension3D dim = ledManager.getDimensions(); for (int x = 0; x < dim.x; x++) { for (int y = 0; y < dim.y; y++) { for (int z = 0; z < dim.z; z++) { ledManager.setLEDColor(x, y, z, new Color()); } } } } Animation anim = LEDCubeManager.getLEDCube().getAnimationByClassName("Animation" + item.animation); if (anim != null) { LEDCubeManager.getLEDCube().getCommThread().setCurrentAnimation(anim); LEDCubeManager.getInstance() .getScreenMainControl() .animComboBox .setSelectedItem(anim.getName()); } if (item.options != null) { for (SequenceItem.Option option : item.options) { LEDCubeManager.getLEDCube() .getCommThread() .getCurrentAnimation() .setOption(option.name, option.value); } } }
@Override public void writeToBinary(OutputStream out) { DataOutputStream dos = new DataOutputStream(out); try { dos.writeByte(getID()); new DataString(getName()).writeToBinary(out); new DataString(getSource()).writeToBinary(out); dos.writeShort(getPositionX()); dos.writeShort(getPositionY()); dos.writeShort(getSourceX()); dos.writeShort(getSourceY()); dos.writeShort(getSourceWidth()); dos.writeShort(getSourceHeight()); dos.writeShort(getDestinationWidth()); dos.writeShort(getDestinationHeight()); dos.writeShort(getAnchorX()); dos.writeShort(getAnchorY()); dos.writeShort(getScaleX()); dos.writeShort(getScaleY()); dos.writeInt(getColour()); dos.writeShort(getOpacity()); dos.writeByte(getRotation()); for (Animation animation : animations) { animation.writeToBinary(out); } } catch (IOException e) { e.printStackTrace(); } }
private static JSONObject animationToJSONObject(Animation animation) { JSONObject json = new JSONObject(); json.put("Name", animation.getName()); json.put("id", animation.getID()); json.put("AnimationFrames", animationFramesToJSONArray(animation.getFrames())); return (json); }
public void dispose() { for (Animation anim : this.animations) { anim.dispose(); } this.animations.clear(); this.currAnimation = null; }
private Animation readAnimation(JSONObject root, String animKind, TextureFilm film) { try { JSONObject jsonAnim = root.getJSONObject(animKind); Animation anim = new Animation(jsonAnim.getInt("fps"), jsonAnim.getBoolean("looped")); List<Integer> framesSeq = new ArrayList<Integer>(16); JSONArray jsonFrames = jsonAnim.getJSONArray("frames"); int nextFrame; for (int i = 0; (nextFrame = jsonFrames.optInt(i, -1)) != -1; ++i) { framesSeq.add(nextFrame); } anim.frames(film, framesSeq, kind * framesInRow); return anim; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
// resets rotation matrix, rotates to the new angle, moves image to center of screen and draws it public void draw(Canvas canvas) { matrix.reset(); matrix.postRotate( angle, animation.getImage().getWidth() / 2, animation.getImage().getHeight() / 2); matrix.postTranslate(x, y); canvas.drawBitmap(animation.getImage(), matrix, null); }
/** Stops animation for the given {@link ImageDisplay}. */ public void stop(final ImageDisplay display) { final Animation animation = animations.get(display); if (animation != null) { animation.stop(); statusService.showStatus(STOPPED_STATUS); } }
public LTexture getSpriteImage(int idx) { if (currentFrameIndex > -1 && currentFrameIndex < size) { Animation animation = playAnimations.get(currentFrameIndex); return animation.getSpriteImage(idx); } else { return null; } }
/** Stops animation of displays whose {@link Data} have been restructured. */ @EventHandler protected void onEvent(final DataRestructuredEvent event) { final Data data = event.getObject(); for (final Animation animation : animations.values()) { final ImageDisplay display = animation.getDisplay(); if (display.isDisplaying(data)) stop(display); } }
/** Hide and remove the XActivityToast */ void removeSuperToast(final XActivityToast xActivityToast) { /* If XActivityToast has been dismissed before it shows, do not attempt to show it */ if (!xActivityToast.isShowing()) { mList.remove(xActivityToast); return; } /* If being called somewhere else get rid of delayed remove message */ removeMessages(Messages.REMOVE, xActivityToast); final ViewGroup viewGroup = xActivityToast.getViewGroup(); final View toastView = xActivityToast.getView(); if (viewGroup != null) { Animation animation = getDismissAnimation(xActivityToast); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { /* Do nothing */ } @Override public void onAnimationEnd(Animation animation) { if (xActivityToast.getOnDismissWrapper() != null) { xActivityToast.getOnDismissWrapper().onDismiss(xActivityToast.getView()); } /* Show the XActivityToast next in the list if any exist */ ManagerXActivityToast.this.showNextSuperToast(); } @Override public void onAnimationRepeat(Animation animation) { /* Do nothing */ } }); toastView.startAnimation(animation); viewGroup.removeView(toastView); mList.poll(); } }
private void setUpTimelines() { Animation maxAnim = this.entity.getAnimationWithMostTimelines(); int max = maxAnim.timelines(); for (int i = 0; i < max; i++) { Timeline t = new Timeline(i, maxAnim.getTimeline(i).name, maxAnim.getTimeline(i).objectInfo); addTimeline(t); } prepare(); }
/** * Appends an animation update. * * @param block The update block. * @param otherPlayer The player. */ private void appendAnimationUpdate(PacketBuilder block, Player otherPlayer) { // TODO: CHEAP FIX!! Caused errors if you attacked someone and clicked away Animation anim = otherPlayer.getCurrentAnimation() != null ? otherPlayer.getCurrentAnimation() : Animation.create(-1, 0); block.putShort(anim.getId()); block.putByteS((byte) anim.getDelay()); }
public void playIndex(int idx) { if (currentFrameIndex > -1 && currentFrameIndex < size) { currentFrameIndex = idx; Animation animation = playAnimations.get(currentFrameIndex); if (animation != null) { animation.reset(); } } }
@Override public void draw(Graphics g) { super.draw(g); AffineTransform at = new AffineTransform(); at.setTransform(scaler.getScale(), 0, 0, scaler.getScale(), 0, 0); anim.setAffineTransform(at); anim.draw(g); }
public void indexLocked(int inx) { this.animationIndexLocked = inx; if (animationIndexLocked > -1 && animationIndexLocked < size) { this.currentFrameIndex = animationIndexLocked; Animation animation = playAnimations.get(currentFrameIndex); if (animation != null) { animation.reset(); } } }
/** * Plays the animation once. * * @param forward whether the animation should be played forward. */ private void playOnce(boolean forward) throws InterruptedException { int n = animation.getFrameCount(); for (int i = 0; i < n; i++) { int frame = forward ? i : n - i - 1; animation.showFrame(frame); if (Thread.interrupted()) { throw new InterruptedException("Play job interrupted."); } Thread.sleep(animation.getFrameDisplayTime(frame)); } }
public static void main(String[] args) { // TODO Auto-generated method stub JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Animation panel = new Animation(); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); frame.setFocusable(false); if (!panel.isFocusOwner()) panel.requestFocus(); }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; Key other = (Key) obj; if (a1 == null) { if (other.a1 != null) return false; } else if (!a1.equals(other.a1)) return false; if (a2 == null) { if (other.a2 != null) return false; } else if (!a2.equals(other.a2)) return false; return true; }
/** * Get the time at the given index. May return null. * * @param index Index * @return Time */ public DateTime getTimeAtIndex(int index) { if (anime == null) { return null; } if (timesArray == null) { timesArray = Animation.getDateTimeArray(anime.getSet()); } if ((timesArray == null) || (index < 0) || (index >= timesArray.length)) { return null; } return timesArray[index]; }
/** Share the value of the animation step. */ protected void shareValue() { Animation myAnimation = anime; AnimationInfo myAnimationInfo = animationInfo; if ((myAnimation != null) && (myAnimationInfo != null)) { if (myAnimation.getNumSteps() > 0) { if (animationInfo.getShareIndex()) { shareIndex(); } else { shareValue(myAnimation.getAniValue()); } } } }
@Override public void tick(float time) { for (int i = 0; i < animations.size(); i++) { Animation a = animations.get(i); a.tick(time); if (a.finished()) toremove.add(a); } for (int i = 0; i < toremove.size(); i++) { animations.remove(toremove.get(i)); } toremove.clear(); }
private void paintAnimations(Graphics2D g2d) { LinkedList<Animation> toRemove = new LinkedList<Animation>(); // get all the animations you can, forget about the ones that are about to be added animationLock.lock(); List<Animation> toPaint = (List<Animation>) animations.clone(); animationLock.unlock(); for (Animation x : toPaint) { if (x.isOver()) toRemove.add(x); else x.step(g2d); } animations.removeAll(toRemove); }
private void updateNextPrevControls() { boolean showPrev = mCurrentPosition > 0; boolean showNext = mCurrentPosition < mAllImages.getCount() - 1; boolean prevIsVisible = mPrevImageView.getVisibility() == View.VISIBLE; boolean nextIsVisible = mNextImageView.getVisibility() == View.VISIBLE; if (showPrev && !prevIsVisible) { Animation a = mShowPrevImageViewAnimation; a.setDuration(500); mPrevImageView.startAnimation(a); mPrevImageView.setVisibility(View.VISIBLE); } else if (!showPrev && prevIsVisible) { Animation a = mHidePrevImageViewAnimation; a.setDuration(500); mPrevImageView.startAnimation(a); mPrevImageView.setVisibility(View.GONE); } if (showNext && !nextIsVisible) { Animation a = mShowNextImageViewAnimation; a.setDuration(500); mNextImageView.startAnimation(a); mNextImageView.setVisibility(View.VISIBLE); } else if (!showNext && nextIsVisible) { Animation a = mHideNextImageViewAnimation; a.setDuration(500); mNextImageView.startAnimation(a); mNextImageView.setVisibility(View.GONE); } }
public void draw(Graphics2D g) { tX = mp.getX(); tY = mp.getY(); if (reverse) { if (factingRight) { g.drawImage( animation.getImage(), (int) (tX + x - width / 2), (int) (tY + y + height / 2), width, -height, null); } else { g.drawImage( animation.getImage(), (int) (tX + x + width / 2), (int) (tY + y + height / 2), -width, -height, null); } } else { if (factingRight) { g.drawImage( animation.getImage(), (int) (tX + x - width / 2), (int) (tY + y - height / 2), null); } else { g.drawImage( animation.getImage(), (int) (tX + x + width / 2), (int) (tY + y - height / 2), -width, height, null); } } // health if (health > 4) { g.drawImage(healths[0], 30, 30, null); } else { if (health > 2) { g.drawImage(healths[1], 30, 30, null); } else { if (health > 0) { g.drawImage(healths[2], 30, 30, null); } } } }
private void calcBoundingRectangle(BoneRef root) { for (BoneRef ref : getCurrentKey().boneRefs) { if (ref.parent != root && root != null) continue; Bone bone = this.unmappedTweenedKeys[ref.timeline].object(); this.prevBBox.calcFor(bone, animation.getTimeline(ref.timeline).objectInfo); Rectangle.setBiggerRectangle(rect, this.prevBBox.getBoundingRect(), rect); this.calcBoundingRectangle(ref); } for (ObjectRef ref : getCurrentKey().objectRefs) { if (ref.parent != root) continue; Bone bone = this.unmappedTweenedKeys[ref.timeline].object(); this.prevBBox.calcFor(bone, animation.getTimeline(ref.timeline).objectInfo); Rectangle.setBiggerRectangle(rect, this.prevBBox.getBoundingRect(), rect); } }
/** Go to the end of the animation sequence. */ public void gotoEnd() { if (anime != null) { visad.Set aset = anime.getSet(); if (aset != null) { try { anime.setCurrent(aset.getLength() - 1); } catch (VisADException ve) {; } } } setRunning(false); // shareIndex (); shareValue(); }
public synchronized void update(long timer) { if (loopCount != -1 && loopPlay > loopCount) { return; } if (isRunning) { if (currentFrameIndex > -1 && currentFrameIndex < size) { Animation animation = playAnimations.get(currentFrameIndex); if (animation != null) { if (animation.isRunning) { animation.update(timer); } } } } }