Skip to content

Commit

Permalink
Updated and adjusted examples due to the model changes (issue #50).
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Aug 29, 2012
1 parent fd1f752 commit 07c7695
Show file tree
Hide file tree
Showing 9 changed files with 463 additions and 464 deletions.
Binary file modified tightdb-android/libs/tightdb.jar
Binary file not shown.
Binary file modified tightdb-android/libs/tightdb/tightdb-devkit.jar
Binary file not shown.
282 changes: 141 additions & 141 deletions tightdb-android/src/com/tightdb/example/TightdbAndroidActivity.java
Original file line number Diff line number Diff line change
@@ -1,142 +1,142 @@
package com.tightdb.example;

import java.io.File;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;

// import com.stocks.generate;
import com.tightdb.example.generated.*;

import com.tightdb.lib.AbstractColumn;
import com.tightdb.lib.Table;
import com.tightdb.lib.TightDB;

import com.tightdb.Group;
import com.tightdb.TableBase;

import org.stockchart.StockChartView;
import org.stockchart.core.Area;
import org.stockchart.core.Axis;
import org.stockchart.core.Axis.ILabelFormatProvider;
import org.stockchart.core.Axis.Side;
import org.stockchart.core.AxisRange;
import org.stockchart.points.CustomPoint;
import org.stockchart.points.StockPoint;
import org.stockchart.series.AbstractSeries;
import org.stockchart.series.BarSeries;
import org.stockchart.series.LinearSeries;
import org.stockchart.series.StockSeries;

public class TightdbAndroidActivity extends Activity {

@Table
class stocka{
String Date;
int Open;
int High;
int Low;
int Close;
int Volume;
int Adj_Close;
}

private Handler mHandler = new Handler();
private StockSeries s1 = new StockSeries();

private static long tttt = 0;
StockChartView s;
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {

// new generate().stocks();

File dir = Environment.getExternalStorageDirectory();
// File file = new File(dir, "NOK.tightdb");
File file = new File(dir, "stocks_ZBRA.tightdb");

Group group = new Group(file);
StockaTable stocks = new StockaTable(group);

Log.i("STOCK", stocks.getName() + "SSS" );
for (Stocka stock : stocks) {
Log.i("STOCK", "BLA!" + stock.getDate() +" " + Long.toString(stock.getHigh()) );
StockPoint ss = new StockPoint(++tttt);
ss.setLow(stock.getLow());
ss.setHigh(stock.getHigh());
ss.setClose(stock.getClose());
ss.setOpen(stock.getOpen());
s1.addPoint(ss);
}
s.invalidate();
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

s = new StockChartView(this);

AxisRange ar = new AxisRange();
ar.setMovable(true);
ar.setZoomable(true);

s.enableGlobalAxisRange(Axis.Side.BOTTOM, ar);

Area a1 = new Area();
Area a2 = new Area();
a1.getRightAxis().setLabelFormatProvider(new ILabelFormatProvider()
{
@Override
public String getAxisLabel(Axis sender, double value) {
return String.valueOf(value);
}
});

a2.setAutoHeight(false);
a2.setHeightInPercents(0.2f);
a2.getBottomAxis().setLabelFormatProvider(new ILabelFormatProvider()
{
@Override
public String getAxisLabel(Axis sender, double value)
{
Area a = sender.getParent();

for(int i=0;i<a.getSeriesCount();i++)
{
AbstractSeries s = a.getSeriesAt(i);

int index = s.convertToArrayIndex(value);
if(index >=0 && index < s.getPointCount())
{
Object id = s.getPointAt(index).getID();

if(null != id)
return id.toString();
}
}
return null;
}
});

a1.getLeftAxis().setVisible(false);
a1.getTopAxis().setVisible(false);

a2.getLeftAxis().setVisible(false);
a2.getTopAxis().setVisible(false);

a1.addSeries(s1);

s.addArea(a1);

setContentView(s, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

mHandler.removeCallbacks(mUpdateTimeTask);
mHandler.postDelayed(mUpdateTimeTask, 100);
}
package com.tightdb.example;

import java.io.File;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;

// import com.stocks.generate;
import com.tightdb.example.generated.*;

import com.tightdb.lib.AbstractColumn;
import com.tightdb.lib.Table;
import com.tightdb.lib.TightDB;

import com.tightdb.Group;
import com.tightdb.TableBase;

import org.stockchart.StockChartView;
import org.stockchart.core.Area;
import org.stockchart.core.Axis;
import org.stockchart.core.Axis.ILabelFormatProvider;
import org.stockchart.core.Axis.Side;
import org.stockchart.core.AxisRange;
import org.stockchart.points.CustomPoint;
import org.stockchart.points.StockPoint;
import org.stockchart.series.AbstractSeries;
import org.stockchart.series.BarSeries;
import org.stockchart.series.LinearSeries;
import org.stockchart.series.StockSeries;

public class TightdbAndroidActivity extends Activity {

@Table(row = "Stocka")
class stocka{
String Date;
int Open;
int High;
int Low;
int Close;
int Volume;
int Adj_Close;
}

private Handler mHandler = new Handler();
private StockSeries s1 = new StockSeries();

private static long tttt = 0;
StockChartView s;
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {

// new generate().stocks();

File dir = Environment.getExternalStorageDirectory();
// File file = new File(dir, "NOK.tightdb");
File file = new File(dir, "stocks_ZBRA.tightdb");

Group group = new Group(file);
StockaTable stocks = new StockaTable(group);

Log.i("STOCK", stocks.getName() + "SSS" );
for (Stocka stock : stocks) {
Log.i("STOCK", "BLA!" + stock.getDate() +" " + Long.toString(stock.getHigh()) );
StockPoint ss = new StockPoint(++tttt);
ss.setLow(stock.getLow());
ss.setHigh(stock.getHigh());
ss.setClose(stock.getClose());
ss.setOpen(stock.getOpen());
s1.addPoint(ss);
}
s.invalidate();
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

s = new StockChartView(this);

AxisRange ar = new AxisRange();
ar.setMovable(true);
ar.setZoomable(true);

s.enableGlobalAxisRange(Axis.Side.BOTTOM, ar);

Area a1 = new Area();
Area a2 = new Area();
a1.getRightAxis().setLabelFormatProvider(new ILabelFormatProvider()
{
@Override
public String getAxisLabel(Axis sender, double value) {
return String.valueOf(value);
}
});

a2.setAutoHeight(false);
a2.setHeightInPercents(0.2f);
a2.getBottomAxis().setLabelFormatProvider(new ILabelFormatProvider()
{
@Override
public String getAxisLabel(Axis sender, double value)
{
Area a = sender.getParent();

for(int i=0;i<a.getSeriesCount();i++)
{
AbstractSeries s = a.getSeriesAt(i);

int index = s.convertToArrayIndex(value);
if(index >=0 && index < s.getPointCount())
{
Object id = s.getPointAt(index).getID();

if(null != id)
return id.toString();
}
}
return null;
}
});

a1.getLeftAxis().setVisible(false);
a1.getTopAxis().setVisible(false);

a2.getLeftAxis().setVisible(false);
a2.getTopAxis().setVisible(false);

a1.addSeries(s1);

s.addArea(a1);

setContentView(s, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

mHandler.removeCallbacks(mUpdateTimeTask);
mHandler.postDelayed(mUpdateTimeTask, 100);
}
}
Binary file modified tightdb-example/lib/tightdb-devkit.jar
Binary file not shown.
Binary file modified tightdb-example/lib/tightdb.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void main(String[] args) {
* rows in the EmployeeTable, which will also be generated.
*/

@Table
@Table(row="Employee")
class employee {
String firstName;
String lastName;
Expand All @@ -42,7 +42,7 @@ class employee {
phone phones;
}

@Table
@Table(row="Phone")
class phone {
String type;
String number;
Expand Down
Loading

0 comments on commit 07c7695

Please sign in to comment.