Android Open Source - codemap Code Map Item






From Project

Back to project page codemap.

License

The source code is released under:

GNU General Public License

If you think the Android project codemap 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 com.hdweiss.codemap.view.workspace.fragments;
/*from  www  . j  av  a  2  s  .c o  m*/
import java.util.UUID;

import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hdweiss.codemap.R;
import com.hdweiss.codemap.data.ICodeMapItem;
import com.hdweiss.codemap.util.CodeMapPoint;
import com.hdweiss.codemap.util.Utils;
import com.hdweiss.codemap.view.workspace.WorkspaceView;

public abstract class CodeMapItem extends LinearLayout implements ICodeMapItem {
  public UUID id = UUID.randomUUID();

  public TextView titleView;
  private ImageButton removeButton;
  private LinearLayout containerView;
  
  private View contentView;
  protected WorkspaceView codeMapView;
  
  private boolean moveItem = false;
  
  public CodeMapItem(Context context, AttributeSet attrs, String name) {
    super(context, attrs);
    
    inflate(context, R.layout.codemap_item, this);
        
    containerView = (LinearLayout) findViewById(R.id.codemap_item_container);
    
    titleView = (TextView) findViewById(R.id.title);
    titleView.setText(name);
    
    removeButton = (ImageButton) findViewById(R.id.remove);
    removeButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {        
        remove();
      }
    });

    this.post(Utils.getTouchDelegateAction(this, removeButton, 50, 50, 50, 50));
  }

  
  public void setCodeMapView(WorkspaceView codeMapView) {
    this.codeMapView = codeMapView;
  }
  

  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
        
    if (this.codeMapView != null && moveItem) {
      this.codeMapView.moveFragment(this);
      this.moveItem = false;
    }
  }

  protected void setContentView(View view) {
    this.contentView = view;
    containerView.addView(view);
  }
  

  public void setPosition(CodeMapPoint point) {
    setX(point.x);
    setY(point.y);
  }
  
  public CodeMapPoint getPosition() {
    return new CodeMapPoint(getX(), getY());
  }

  public void setPositionCenter(CodeMapPoint point) {
    float startX = point.x - (getWidth() / 2);
    float startY = point.y - (getHeight() / 2);
    setX(startX);
    setY(startY);
  }
  
  public Rect getBounds() {
    final int top = (int) getY();
    final int bottom = top + getHeight();

    final int left = (int) getX();
    final int right = left + getWidth();
        
    return new Rect(left, top, right, bottom);
  }
  
  public void push(Point offset) {
    setX(getX() + offset.x);
    setY(getY() + offset.y);
  }

  public boolean contains(CodeMapPoint point) {
//    Log.d("CodeMap", "point : [" + getX() + " < " + point.x + " < "
//        + (getX() + getWidth()) + "] [" + getY() + " < " + point.y
//        + " < " + (getY() + getHeight()) + "]");
    if (point.x >= getX() && point.x <= getX() + getWidth()
        && point.y >= getY() && point.y <= getY() + getHeight()) {
      //Log.d("CodeMap", "match!");
      return true;
    }
    else
      return false;
  }

  public void makeItemMoveable() {
    this.moveItem = true;
  }
  
  public void remove() {
    if(codeMapView != null)
      codeMapView.remove(this);
  }
  
  public String getUrl() {
    return this.titleView.getText().toString();
  }
  
  public float getContentViewYOffset() {
    return titleView.getHeight() + titleView.getPaddingTop()
        + titleView.getPaddingBottom() + contentView.getPaddingTop()
        + contentView.getPaddingBottom() + 5;
  }
  
  public float getTitleViewYMid() {
    return this.getY() + (titleView.getHeight() / 2);
  }
  
  public void setFontSize(int fontSize) {
    // Do nothing
  }
  
  public void setupForAnnotation() {
    containerView.setBackgroundResource(R.drawable.fragment_bg_annotation);
  }
}




Java Source Code List

com.hdweiss.codemap.data.CodeMapApp.java
com.hdweiss.codemap.data.CscopeEntry.java
com.hdweiss.codemap.data.CscopeWrapper.java
com.hdweiss.codemap.data.Cscope.java
com.hdweiss.codemap.data.ICodeMapItem.java
com.hdweiss.codemap.data.JGitWrapper.java
com.hdweiss.codemap.data.ProjectController.java
com.hdweiss.codemap.data.Project.java
com.hdweiss.codemap.data.SerializableItem.java
com.hdweiss.codemap.data.SerializableLink.java
com.hdweiss.codemap.util.AbsoluteLayout.java
com.hdweiss.codemap.util.CodeMapCursorPoint.java
com.hdweiss.codemap.util.CodeMapPoint.java
com.hdweiss.codemap.util.FlowLayout.java
com.hdweiss.codemap.util.ObjectSerializer.java
com.hdweiss.codemap.util.SpanUtils.java
com.hdweiss.codemap.util.SyntaxHighlighter.java
com.hdweiss.codemap.util.Utils.java
com.hdweiss.codemap.util.ZoomableAbsoluteLayout.java
com.hdweiss.codemap.util.ZoomableLinearLayout.java
com.hdweiss.codemap.view.CodeMapActivity.java
com.hdweiss.codemap.view.CodeMapTabListener.java
com.hdweiss.codemap.view.Preferences.java
com.hdweiss.codemap.view.project.ProjectAdapter.java
com.hdweiss.codemap.view.project.ProjectBrowser.java
com.hdweiss.codemap.view.project.ProjectItemView.java
com.hdweiss.codemap.view.project.ProjectWizard.java
com.hdweiss.codemap.view.workspace.CollisionManager.java
com.hdweiss.codemap.view.workspace.FindDeclarationTask.java
com.hdweiss.codemap.view.workspace.WorkspaceController.java
com.hdweiss.codemap.view.workspace.WorkspaceFragment.java
com.hdweiss.codemap.view.workspace.WorkspaceStateLoader.java
com.hdweiss.codemap.view.workspace.WorkspaceState.java
com.hdweiss.codemap.view.workspace.WorkspaceViewListeners.java
com.hdweiss.codemap.view.workspace.WorkspaceView.java
com.hdweiss.codemap.view.workspace.browser.WorkspaceBrowserAdapter.java
com.hdweiss.codemap.view.workspace.browser.WorkspaceBrowser.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapAnnotation.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapFunction.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapImage.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapItem.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapLink.java
com.hdweiss.codemap.view.workspace.fragments.FunctionLinkSpan.java
com.hdweiss.codemap.view.workspace.outline.CscopeEntryAdapter.java
com.hdweiss.codemap.view.workspace.outline.OutlineAdapter.java
com.hdweiss.codemap.view.workspace.outline.OutlineBrowser.java
com.hdweiss.codemap.view.workspace.outline.OutlineItemComparator.java
com.hdweiss.codemap.view.workspace.outline.OutlineItemView.java
com.hdweiss.codemap.view.workspace.outline.OutlineItem.java