Android Open Source - AnkiStats Lines






From Project

Back to project page AnkiStats.

License

The source code is released under:

GNU General Public License

If you think the Android project AnkiStats 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

/**
 * /* w ww.  j av a 2  s  . c o  m*/
 */
package com.wildplot.android.rendering;

import com.wildplot.android.rendering.graphics.wrapper.*;
import com.wildplot.android.rendering.interfaces.Drawable;
import com.wildplot.android.rendering.interfaces.Legendable;


/**
 * The LinesPoints objects draw points from a data array and connect them with lines on. 
 * These LinesPoints are drawn onto a PlotSheet object
 */
public class Lines implements Drawable, Legendable {

    private boolean mHasShadow = false;
    private float mShadowRadius = 0.0f;
    private float mShadowDx= 0.0f;
    private float mShadowDy = 0.0f;
    private Color mShadowColor = Color.BLACK;

    private String mName = "";
    private boolean mNameIsSet = false;

  private PlotSheet plotSheet;
  
  private double[][] pointList;
  
  private Color color;

    public void setSize(float size) {
        this.size = size;
    }

    private float size;

    /**
   * Constructor for points connected with lines without drawn points
   * @param plotSheet the sheet the lines and points will be drawn onto
   * @param pointList x- , y-positions of given points
   * @param color point and line color
   */
  public Lines(PlotSheet plotSheet, double[][] pointList, Color color) {
    this.plotSheet = plotSheet;
    this.pointList = pointList;
    this.color = color;
  }
  
  /* (non-Javadoc)
   * @see rendering.Drawable#paint(java.awt.Graphics)
   */
  @Override
  public void paint(Graphics g) {
    Color oldColor = g.getColor();
    Rectangle field = g.getClipBounds();
    g.setColor(color);
        Stroke oldStroke = g.getStroke();
        g.setStroke(new BasicStroke(this.size));  // set stroke width of 10
        if(mHasShadow){
            g.setShadow(mShadowRadius, mShadowDx, mShadowDy, mShadowColor);
        }

        float[] coordStart = plotSheet.toGraphicPoint(pointList[0][0],pointList[1][0],field);
        float[] coordEnd = coordStart;
    
    for(int i = 0; i< pointList[0].length; i++) {
      coordEnd = coordStart;
      coordStart = plotSheet.toGraphicPoint(pointList[0][i],pointList[1][i],field);
      g.drawLine(coordStart[0], coordStart[1], coordEnd[0], coordEnd[1]);
      //drawPoint(pointList[0][i], pointList[1][i], canvas, paint, field);
    }
        if(mHasShadow){
            g.unsetShadow();
        }
        g.setStroke(oldStroke);
    g.setColor(oldColor);
  }
  
  /**
   * Draw points as karo
   * @param x x-value of a point
   * @param y y-value of a point
   * @param g graphic object where to draw
   * @param field given Rect field
   */
  public void drawPoint(double x, double y, Graphics g, Rectangle field) {
        float[] coordStart   = plotSheet.toGraphicPoint(x, y,field);
    g.drawRect(coordStart[0]-3, coordStart[1]-3, coordStart[0]-3+6, coordStart[1]-3+6);
//    g.drawLine(coordStart[0]-3, coordStart[1]-3, coordStart[0]+3, coordStart[1]-3);
//    g.drawLine(coordStart[0]+3, coordStart[1]-3, coordStart[0]+3, coordStart[1]+3);
//    g.drawLine(coordStart[0]+3, coordStart[1]+3, coordStart[0]-3, coordStart[1]+3);
//    g.drawLine(coordStart[0]-3, coordStart[1]+3, coordStart[0]-3, coordStart[1]-3);
  }
  
  /*
   * (non-Javadoc)
   * @see rendering.Drawable#isOnFrame()
   */
  public boolean isOnFrame() {
    return false;
  }

    @Override
    public void abortAndReset() {
        // TODO Auto-generated method stub
        
    }
    @Override
    public boolean isClusterable() {
        return true;
    }

    @Override
    public boolean isCritical() {
        return false;
    }

    @Override
    public Color getColor() {
        return color;
    }

    @Override
    public String getName() {
        return mName;
    }

    @Override
    public boolean nameIsSet() {
        return mNameIsSet;
    }

    public void setName(String name){
        mName = name;
        mNameIsSet = true;
    }

    public void setShadow(float radius, float dx, float dy, Color color){
        mHasShadow =true;
        mShadowRadius = radius;
        mShadowDx = dx;
        mShadowDy = dy;
        mShadowColor = color;
    }
    public void unsetShadow(){
        mHasShadow = false;
    }
}




Java Source Code List

com.wildplot.android.ankistats.AnkiDb.java
com.wildplot.android.ankistats.AnkiStatsActivity.java
com.wildplot.android.ankistats.AnkiStatsApplication.java
com.wildplot.android.ankistats.AnswerButton.java
com.wildplot.android.ankistats.ApplicationTest.java
com.wildplot.android.ankistats.CardsTypes.java
com.wildplot.android.ankistats.CollectionData.java
com.wildplot.android.ankistats.Forecast.java
com.wildplot.android.ankistats.HourlyBreakdown.java
com.wildplot.android.ankistats.Intervals.java
com.wildplot.android.ankistats.ReviewCount.java
com.wildplot.android.ankistats.Utils.java
com.wildplot.android.ankistats.WeeklyBreakdown.java
com.wildplot.android.parsing.Atom.java
com.wildplot.android.parsing.ExpressionFormatException.java
com.wildplot.android.parsing.Expression.java
com.wildplot.android.parsing.Factor.java
com.wildplot.android.parsing.Pow.java
com.wildplot.android.parsing.Term.java
com.wildplot.android.parsing.TopLevelParser.java
com.wildplot.android.parsing.TreeElement.java
com.wildplot.android.parsing.AtomTypes.FunctionXAtom.java
com.wildplot.android.parsing.AtomTypes.FunctionXYAtom.java
com.wildplot.android.parsing.AtomTypes.MathFunctionAtom.java
com.wildplot.android.parsing.AtomTypes.NumberAtom.java
com.wildplot.android.parsing.AtomTypes.VariableAtom.java
com.wildplot.android.parsing.AtomTypes.XVariableAtom.java
com.wildplot.android.parsing.AtomTypes.YVariableAtom.java
com.wildplot.android.rendering.AdvancedPlotSheet.java
com.wildplot.android.rendering.BarGraph.java
com.wildplot.android.rendering.DrawableContainer.java
com.wildplot.android.rendering.FunctionDrawer.java
com.wildplot.android.rendering.FunctionDrawer_y.java
com.wildplot.android.rendering.Integral.java
com.wildplot.android.rendering.LegendDrawable.java
com.wildplot.android.rendering.LinesPoints.java
com.wildplot.android.rendering.Lines.java
com.wildplot.android.rendering.MultiScreenPart.java
com.wildplot.android.rendering.PieChart.java
com.wildplot.android.rendering.PlotSheet.java
com.wildplot.android.rendering.PointDrawer2D.java
com.wildplot.android.rendering.RelativeColorGradient.java
com.wildplot.android.rendering.ReliefDrawer.java
com.wildplot.android.rendering.XAxisBarGraph.java
com.wildplot.android.rendering.XAxisHistoGram.java
com.wildplot.android.rendering.XAxis.java
com.wildplot.android.rendering.XGrid.java
com.wildplot.android.rendering.YAxisBarGraph.java
com.wildplot.android.rendering.YAxisHistoGram.java
com.wildplot.android.rendering.YAxis.java
com.wildplot.android.rendering.YGrid.java
com.wildplot.android.rendering.graphics.wrapper.BasicStroke.java
com.wildplot.android.rendering.graphics.wrapper.BufferedImage.java
com.wildplot.android.rendering.graphics.wrapper.Color.java
com.wildplot.android.rendering.graphics.wrapper.FontMetrics.java
com.wildplot.android.rendering.graphics.wrapper.Graphics2D.java
com.wildplot.android.rendering.graphics.wrapper.Graphics.java
com.wildplot.android.rendering.graphics.wrapper.Rectangle.java
com.wildplot.android.rendering.graphics.wrapper.Stroke.java
com.wildplot.android.rendering.interfaces.Drawable.java
com.wildplot.android.rendering.interfaces.Function2D.java
com.wildplot.android.rendering.interfaces.Function3D.java
com.wildplot.android.rendering.interfaces.Legendable.java
com.wildplot.android.rendering.interfaces.StepFunction2D.java