Painter base waveform canvas implemented

Fixed Copyright information
This commit is contained in:
2015-01-21 21:58:35 +01:00
parent 5f5bfbd792
commit 6853484417
95 changed files with 1542 additions and 297 deletions

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import java.beans.IntrospectionException;
@@ -6,14 +16,12 @@ import java.io.FileInputStream;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
@@ -29,10 +37,12 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
long timeResolution=1;
private HashMap<String, RelationType> relationMap = new HashMap<String, RelationType>();
private RelationTypeFactory rtf = new RelationTypeFactory();
private IWaveformDb db;
private ScvSimProps scvSimProps;
public SQLiteDbLoader() {
}
@@ -43,7 +53,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
try {
List<ScvTxEvent> event = handler.selectObjects();
if(event.size()>0)
return event.get(0).getTime();
return event.get(0).getTime()*scvSimProps.getTime_resolution();
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
e.printStackTrace();
@@ -58,7 +68,9 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
streams=new ArrayList<IWaveform<? extends IWaveformEvent>>();
try {
for(ScvStream scvStream:handler.selectObjects()){
streams.add(new TxStream(database, db, scvStream));
TxStream stream = new TxStream(database, db, scvStream);
stream.setRelationTypeFactory(rtf);
streams.add(stream);
}
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
@@ -85,7 +97,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
database.setData("TIMERESOLUTION", 1L);
SQLiteDatabaseSelectHandler<ScvSimProps> handler = new SQLiteDatabaseSelectHandler<ScvSimProps>(ScvSimProps.class, database);
try {
for(ScvSimProps scvSimProps:handler.selectObjects()){
for(ScvSimProps simProps:handler.selectObjects()){
scvSimProps=simProps;
database.setData("TIMERESOLUTION", scvSimProps.getTime_resolution());
}
return true;
@@ -95,13 +108,4 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
}
return false;
}
public RelationType getRelationType(String relationName) {
if(relationMap.containsKey(relationName)) return relationMap.get(relationName);
RelationType type = new RelationType(relationName);
relationMap.put(relationName, type);
return type;
}
}

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import java.beans.IntrospectionException;
@@ -16,6 +26,7 @@ import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvStream;
import com.minres.scviewer.database.sqlite.tables.ScvTx;
import com.minres.scviewer.database.sqlite.tables.ScvTxAttribute;
import com.minres.scviewer.database.sqlite.tables.ScvTxEvent;
@@ -29,7 +40,7 @@ public class Tx implements ITx {
private ScvTx scvTx;
private List<ITxAttribute> attributes;
private Long begin, end;
private List<ITxRelation> incoming, outgoing;
private List<ITxRelation> incoming, outgoing;
public Tx(IDatabase database, TxStream trStream, TxGenerator trGenerator, ScvTx scvTx) {
this.database=database;
@@ -143,20 +154,26 @@ public class Tx implements ITx {
}
private ITxRelation createRelation(ScvTxRelation rel, boolean outgoing) {
long otherId = outgoing?rel.getSink():rel.getSrc();
/*FIXME:
int otherId = outgoing?rel.getSink():rel.getSrc();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
"id="+otherId);
try {
List<ScvTx> scvTx=new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database, "id="+otherId).selectObjects();
assert(scvTx.size()==1);
ITxStream stream = trStream.getDb().getStreamById(scvTx.get(0).getStream());
Tx that=(Tx) stream.getTransactionById(otherId);
List<ScvTx> res = handler.selectObjects();
if(res.size()!=1) return null;
List<ScvStream> streams = new SQLiteDatabaseSelectHandler<ScvStream>(ScvStream.class, database,
"id="+res.get(0).getStream()).selectObjects();
if(streams.size()!=1) return null;
TxStream tgtStream = (TxStream) trStream.getDb().getStreamByName(streams.get(0).getName());
Tx that = (Tx) tgtStream.getTransactions().get(otherId);
if(outgoing)
return new TxRelation(trStream.getDb().getRelationType(rel.getName()), this, that);
return new TxRelation(trStream.getRelationType(rel.getName()), this, that);
else
return new TxRelation(trStream.getDb().getRelationType(rel.getName()), that, this);
return new TxRelation(trStream.getRelationType(rel.getName()), that, this);
} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException
| InvocationTargetException | SQLException | IntrospectionException e) {
}*/
e.printStackTrace();
}
return null;
}
@@ -165,4 +182,8 @@ public class Tx implements ITx {
return this.getBeginTime().compareTo(o.getBeginTime());
}
@Override
public String toString() {
return "tx#"+getId()+"@"+getBeginTime()+"-@"+getEndTime();
}
}

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.AssociationType;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.ITx;
@@ -40,4 +50,8 @@ public class TxEvent implements ITxEvent {
return type;
}
@Override
public String toString() {
return type.toString()+"@"+getTime()+" of tx #"+tx.getId();
}
}

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import java.util.List;
@@ -11,7 +21,9 @@ import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
public class TxGenerator implements ITxGenerator {
private ITxStream<ITxEvent> stream;
private ScvGenerator scvGenerator;
public TxGenerator(ITxStream<ITxEvent> stream, ScvGenerator scvGenerator) {
this.stream=stream;
this.scvGenerator=scvGenerator;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import com.minres.scviewer.database.ITxRelation;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite;
import java.beans.IntrospectionException;
@@ -5,18 +15,20 @@ import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.Vector;
import com.google.common.collect.TreeMultimap;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.sqlite.db.IDatabase;
import com.minres.scviewer.database.sqlite.db.SQLiteDatabaseSelectHandler;
import com.minres.scviewer.database.sqlite.tables.ScvGenerator;
@@ -33,13 +45,15 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
private ScvStream scvStream;
private HashMap<Integer, TxGenerator> generators;
private TreeMap<Integer, TxGenerator> generators;
private HashMap<Integer, ITx> transactions;
private TreeMap<Integer, ITx> transactions;
private Integer maxConcurrency;
private TreeMultimap<Long, ITxEvent> events;
private TreeMap<Long, List<ITxEvent>> events;
private RelationTypeFactory relationMap;
public TxStream(IDatabase database, IWaveformDb waveformDb, ScvStream scvStream) {
super(scvStream.getName());
@@ -74,7 +88,7 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
if(generators==null){
SQLiteDatabaseSelectHandler<ScvGenerator> handler = new SQLiteDatabaseSelectHandler<ScvGenerator>(
ScvGenerator.class, database, "stream="+scvStream.getId());
generators=new HashMap<Integer, TxGenerator>();
generators=new TreeMap<Integer, TxGenerator>();
try {
for(ScvGenerator scvGenerator:handler.selectObjects()){
generators.put(scvGenerator.getId(), new TxGenerator(this, scvGenerator));
@@ -120,22 +134,32 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
}
@Override
public NavigableMap<Long, Collection<ITxEvent>> getEvents(){
public NavigableMap<Long, List<ITxEvent>> getEvents(){
if(events==null){
events=TreeMultimap.create();
events=new TreeMap<Long, List<ITxEvent>>();
for(Entry<Integer, ITx> entry:getTransactions().entrySet()){
events.put(entry.getValue().getBeginTime(), new TxEvent(TxEvent.Type.BEGIN, entry.getValue()));
events.put(entry.getValue().getBeginTime(), new TxEvent(TxEvent.Type.END, entry.getValue()));
putEvent(new TxEvent(TxEvent.Type.BEGIN, entry.getValue()));
putEvent(new TxEvent(TxEvent.Type.END, entry.getValue()));
}
}
return events.asMap();
return events;
}
private void putEvent(TxEvent ev){
Long time = ev.getTime();
if(!events.containsKey(time)){
Vector<ITxEvent> vector=new Vector<ITxEvent>();
vector.add(ev);
events.put(time, vector);
} else {
events.get(time).add(ev);
}
}
protected HashMap<Integer, ITx> getTransactions() {
protected Map<Integer, ITx> getTransactions() {
if(transactions==null){
if(generators==null) getGenerators();
transactions = new HashMap<Integer, ITx>();
transactions = new TreeMap<Integer, ITx>();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, database,
"stream="+scvStream.getId());
try {
@@ -155,4 +179,14 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
return getEvents().get(time);
}
public void setRelationTypeFactory(RelationTypeFactory rtf) {
this.relationMap=rtf;
}
public RelationType getRelationType(String name) {
if(relationMap!=null) return relationMap.getRelationType(name);
return null;
}
}

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.db;
import java.lang.reflect.Field;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.db;
import java.sql.Connection;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.db;
import java.sql.Connection;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.db;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.db;
import java.beans.IntrospectionException;

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvGenerator {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvSimProps {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvStream {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvTx {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvTxAttribute {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvTxEvent {

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.sqlite.tables;
public class ScvTxRelation {