Android Open Source - adventure.datetime Fragment Connection






From Project

Back to project page adventure.datetime.

License

The source code is released under:

MIT License

If you think the Android project adventure.datetime listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ca.cmput301f13t03.adventure_datetime.view.treeView;
//from ww  w .ja  va2s  .  c  om
import android.content.res.Resources;
import android.graphics.*;
import android.graphics.Paint.Style;
import ca.cmput301f13t03.adventure_datetime.R;

import java.util.UUID;

/**
 * Represents a connection between two fragments
 * @author Jesse
 */
final class FragmentConnection
{
  private static final int PARTICLE_H_OFFSET = 10;
  private static final int PARTICLE_V_OFFSET = 10;
  private static final float FRAME_ANIMATION_SPEED = 0.015f;
  
  private static Paint s_pathStyle = null;
  private static Paint s_particleStyle = null;
  private static Bitmap s_particle = null;
  
  private PathMeasure m_measure = null;
  private Path m_connectionPath = null;
  private float m_length = 0.0f;
  private float m_animationProgress = 1.0f;
  
  private UUID m_originId = null;
  private UUID m_targetId = null;
  
  static
  {
    s_pathStyle = new Paint();
    s_pathStyle.setAntiAlias(true);
    s_pathStyle.setAlpha(200);
    s_pathStyle.setColor(Color.CYAN);
    s_pathStyle.setStyle(Style.STROKE);
    s_pathStyle.setStrokeWidth(3.0f);
    
    s_particleStyle = new Paint();
  }
  
  public FragmentConnection(UUID origin, UUID target, Resources res)
  {
    m_originId = origin;
    m_targetId = target;
    
    if(s_particle == null)
    {
      s_particle = BitmapFactory.decodeResource(res, R.drawable.particle);
    }
  }
  
  public void SetPath(Path path)
  {
    m_connectionPath = path;
    m_measure = new PathMeasure(m_connectionPath, false);
    m_length = m_measure.getLength();
  }
  
  public void Draw(Canvas surface, Camera camera)
  {
    camera.DrawLocal(surface, s_pathStyle, this.m_connectionPath);
    
    float pos[] = { 0.0f, 0.0f };
    if(m_measure.getPosTan(m_animationProgress * m_length, pos, null))
    {
      camera.DrawLocal(  surface, 
                s_particleStyle, 
                s_particle, 
                (int)(pos[0]) - PARTICLE_H_OFFSET, 
                (int)(pos[1]) - PARTICLE_V_OFFSET);
    }
    
    if(m_animationProgress <= 0.0f)
    {
      m_animationProgress = 1.0f;
    }
    
    m_animationProgress -= FRAME_ANIMATION_SPEED;
  }
  
  public UUID GetOrigin()
  {
    return m_originId;
  }
  
  public UUID GetTarget()
  {
    return m_targetId;
  }
}




Java Source Code List

ca.cmput301f13t03.adventure_datetime.controller.AuthorControllerTest.java
ca.cmput301f13t03.adventure_datetime.controller.AuthorController.java
ca.cmput301f13t03.adventure_datetime.controller.UserControllerTest.java
ca.cmput301f13t03.adventure_datetime.controller.UserController.java
ca.cmput301f13t03.adventure_datetime.model.AccountServiceTests.java
ca.cmput301f13t03.adventure_datetime.model.AccountService.java
ca.cmput301f13t03.adventure_datetime.model.BookmarkTest.java
ca.cmput301f13t03.adventure_datetime.model.Bookmark.java
ca.cmput301f13t03.adventure_datetime.model.ChoiceTest.java
ca.cmput301f13t03.adventure_datetime.model.Choice.java
ca.cmput301f13t03.adventure_datetime.model.CommentTest.java
ca.cmput301f13t03.adventure_datetime.model.Comment.java
ca.cmput301f13t03.adventure_datetime.model.ES.java
ca.cmput301f13t03.adventure_datetime.model.ImageTest.java
ca.cmput301f13t03.adventure_datetime.model.Image.java
ca.cmput301f13t03.adventure_datetime.model.StoryDBTest.java
ca.cmput301f13t03.adventure_datetime.model.StoryDB.java
ca.cmput301f13t03.adventure_datetime.model.StoryFragmentTest.java
ca.cmput301f13t03.adventure_datetime.model.StoryFragment.java
ca.cmput301f13t03.adventure_datetime.model.StoryManager.java
ca.cmput301f13t03.adventure_datetime.model.StoryTest.java
ca.cmput301f13t03.adventure_datetime.model.Story.java
ca.cmput301f13t03.adventure_datetime.model.ThreadPool.java
ca.cmput301f13t03.adventure_datetime.model.WebStorageCleaner.java
ca.cmput301f13t03.adventure_datetime.model.WebStorageTest.java
ca.cmput301f13t03.adventure_datetime.model.WebStorage.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IAllFragmentsListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IBookmarkListListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.ICommentsListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.ICurrentFragmentListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.ICurrentStoryListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.ILocalStorage.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.ILocalStoriesListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IOnlineStoriesListener.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IStoryModelDirector.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IStoryModelPresenter.java
ca.cmput301f13t03.adventure_datetime.model.Interfaces.IWebStorage.java
ca.cmput301f13t03.adventure_datetime.serviceLocator.Locator.java
ca.cmput301f13t03.adventure_datetime.view.AuthorEdit_Edit.java
ca.cmput301f13t03.adventure_datetime.view.AuthorEdit_Overview.java
ca.cmput301f13t03.adventure_datetime.view.AuthorEdit.java
ca.cmput301f13t03.adventure_datetime.view.AuthorStories.java
ca.cmput301f13t03.adventure_datetime.view.AuthorStoryDescription.java
ca.cmput301f13t03.adventure_datetime.view.AuthorViewPager.java
ca.cmput301f13t03.adventure_datetime.view.BrowseFragment.java
ca.cmput301f13t03.adventure_datetime.view.BrowseView.java
ca.cmput301f13t03.adventure_datetime.view.CommentsView.java
ca.cmput301f13t03.adventure_datetime.view.ContinueView.java
ca.cmput301f13t03.adventure_datetime.view.FragmentViewActivity.java
ca.cmput301f13t03.adventure_datetime.view.FragmentView.java
ca.cmput301f13t03.adventure_datetime.view.FullScreen_Image.java
ca.cmput301f13t03.adventure_datetime.view.IFragmentSelected.java
ca.cmput301f13t03.adventure_datetime.view.MainViewTest.java
ca.cmput301f13t03.adventure_datetime.view.MainView.java
ca.cmput301f13t03.adventure_datetime.view.StoryDescription.java
ca.cmput301f13t03.adventure_datetime.view.treeView.Camera.java
ca.cmput301f13t03.adventure_datetime.view.treeView.ConnectionPlacer.java
ca.cmput301f13t03.adventure_datetime.view.treeView.FragmentConnection.java
ca.cmput301f13t03.adventure_datetime.view.treeView.FragmentNode.java
ca.cmput301f13t03.adventure_datetime.view.treeView.GridSegment.java
ca.cmput301f13t03.adventure_datetime.view.treeView.InputHandler.java
ca.cmput301f13t03.adventure_datetime.view.treeView.NodeGrid.java
ca.cmput301f13t03.adventure_datetime.view.treeView.NodePlacer.java
ca.cmput301f13t03.adventure_datetime.view.treeView.Region.java
ca.cmput301f13t03.adventure_datetime.view.treeView.TreeView.java