Painter base waveform canvas implemented

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

View File

@ -8,8 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: com.minres.scviewer.database;bundle-version="1.0.0",
org.eclipse.equinox.util;bundle-version="1.0.500",
org.eclipse.equinox.ds;bundle-version="1.4.200",
org.eclipse.osgi.services;bundle-version="3.4.0",
com.google.guava;bundle-version="15.0.0"
org.eclipse.osgi.services;bundle-version="3.4.0"
Bundle-ClassPath: .,
sqlite-jdbc-3.8.7.jar
Service-Component: OSGI-INF/component.xml

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
###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\

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 {

View File

@ -1,5 +1,15 @@
###############################################################################
# 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
###############################################################################
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/component.xml
OSGI-INF/
source.. = src/

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.test;
import static org.junit.Assert.assertEquals;
@ -6,18 +16,12 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.WaveformDb;
public class DatabaseServicesTest {

View File

@ -1,6 +1,15 @@
###############################################################################
# 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
###############################################################################
output.. = bin/
bin.includes = META-INF/,\
.,\
component.xml,\
OSGI-INF/
source.. = src/

View File

@ -1,8 +1,8 @@
package com.minres.scviewer.database.text;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.ITx
import com.minres.scviewer.database.ITxEvent
import com.minres.scviewer.database.IWaveformEvent
class TxEvent implements ITxEvent {
@ -27,6 +27,11 @@ class TxEvent implements ITxEvent {
}
Long getTime(){
return type==ITxEvent.Type.BEGIN?transaction.beginTime:transaction.endTime
type==ITxEvent.Type.BEGIN?transaction.beginTime:transaction.endTime
}
@Override
String toString() {
type.toString()+"@"+getTime()+" of tx #"+transaction.id;
}
}

View File

@ -15,9 +15,11 @@ import java.util.List;
import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxGenerator;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveformEvent;
class TxGenerator implements ITxGenerator{
Long id
@ -37,7 +39,7 @@ class TxGenerator implements ITxGenerator{
this.name=name
}
ITxStream getStream(){
ITxStream<? extends ITxEvent> getStream(){
return stream;
}

View File

@ -1,4 +1,15 @@
###############################################################################
# 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
###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
OSGI-INF/

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.vcd;
import com.minres.scviewer.database.BitVector;
@ -41,10 +51,10 @@ public interface IVCDDatabaseBuilder {
/**
* Append transition.
*
* @param intValue the int value
* @param fCurrentTime the f current time
* @param signalId the int value
* @param currentTime the current time in ps
* @param decodedValues the decoded values
*/
public void appendTransition(int intValue, long fCurrentTime, BitVector decodedValues);
public void appendTransition(int signalId, long currentTime, BitVector decodedValues);
}

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.vcd;
import java.io.File;
@ -93,7 +103,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/
@Override
public Long getMaxTime() {
return maxTime* TIME_RES;
return maxTime;
}
/* (non-Javadoc)
@ -157,9 +167,9 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int signalId, long fCurrentTime, BitVector decodedValues) {
public void appendTransition(int signalId, long currentTime, BitVector decodedValues) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = fCurrentTime* TIME_RES;
Long time = currentTime* TIME_RES;
if(signal.getWidth()==1){
((VCDSignal<ISignalChangeSingle>)signal).values.put(time, new VCDSignalChangeSingle(time, decodedValues.getValue()[0]));
} else {

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.vcd;
import java.io.*;

View File

@ -1,18 +1,24 @@
/*******************************************************************************
* 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.vcd;
import java.util.Collection;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
import com.google.common.collect.Ordering;
import com.google.common.collect.TreeMultimap;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformEvent;
public class VCDSignal<T extends ISignalChange> extends HierNode implements ISignal<T> {

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.vcd;
import com.minres.scviewer.database.BitVector;
@ -25,4 +35,9 @@ public class VCDSignalChangeMulti extends SignalChange implements ISignalChangeM
this.value = value;
}
@Override
public String toString() {
return value.toHexString()+"@"+getTime();
}
}

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.vcd;
import com.minres.scviewer.database.ISignalChangeSingle;
@ -20,4 +30,8 @@ public class VCDSignalChangeSingle extends SignalChange implements ISignalChange
this.value = value;
}
@Override
public String toString() {
return value+"@"+getTime();
}
}

View File

@ -1,6 +1,15 @@
###############################################################################
# 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
###############################################################################
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/component.xml,\
OSGI-INF/component.xml
OSGI-INF/
source.. = src/

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;
public enum 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;
public class BitVector {

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;
public enum DataType {

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;
import java.beans.PropertyChangeListener;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

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;
import java.util.NavigableMap;

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;
public interface ISignalChange extends IWaveformEvent {

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;

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;
public interface ISignalChangeSingle extends ISignalChange{

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

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;
public interface ITxEvent extends IWaveformEvent {

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

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;
public interface ITxRelation {

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;
@ -20,7 +20,7 @@ public interface ITxStream<T extends ITxEvent> extends IWaveform<T> {
public int getMaxConcurrency();
public NavigableMap<Long, Collection<T>> getEvents();
public NavigableMap<Long, List<ITxEvent>> getEvents();
public Collection<T> getWaveformEventsAtTime(Long time);

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;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;
@ -18,7 +18,7 @@ public interface IWaveformDb extends IHierNode {
public Long getMaxTime();
public IWaveform<?> getStreamByName(String name);
public IWaveform<? extends IWaveformEvent> getStreamByName(String name);
public List<IWaveform<?>> getAllWaves();

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;
import java.io.File;

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;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;

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;
public class SignalChange implements IWaveformEvent {

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;
import java.io.File;
@ -44,7 +54,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
}
@Override
public IWaveform<?> getStreamByName(String name) {
public IWaveform<? extends IWaveformEvent> getStreamByName(String name) {
return waveforms.get(name);
}

View File

@ -21,3 +21,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
swing2swt.jar
Import-Package: com.google.common.collect

View File

@ -1,10 +1,18 @@
output.. = bin/
###############################################################################
# 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
###############################################################################
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
contexts.xml,\
res/,\
swing2swt.jar,\
OSGI-INF/
res/
source.. = src/
jars.compile.order = .
output.. = bin/

View File

@ -116,8 +116,6 @@
id="com.minres.scviewer.ui.toolbar1">
<command
commandId="com.minres.scviewer.ui.gotoPrev"
disabledIcon="res/images/previous-green-d.png"
icon="res/images/previous-green.png"
label="Prev"
style="push"
tooltip="Go to previous event">
@ -130,8 +128,6 @@
</command>
<command
commandId="com.minres.scviewer.ui.gotoNext"
disabledIcon="res/images/next-green-d.png"
icon="res/images/next-green.png"
label="Next"
style="push"
tooltip="Go to next event">
@ -142,8 +138,157 @@
</reference>
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
id="com.minres.scviewer.ui.zoom.command"
style="pulldown"
tooltip="Set zoom level">
<visibleWhen
checkEnabled="false">
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomin"
label="Zoom in"
style="push"
tooltip="Zoom into">
<visibleWhen
checkEnabled="false">
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomout"
label="Zoom out"
style="push"
tooltip="Zoom out of">
<visibleWhen
checkEnabled="false">
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</visibleWhen>
</command>
</toolbar>
</menuContribution>
<menuContribution
locationURI="menu:com.minres.scviewer.ui.zoom.command">
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ps"
style="push"
tooltip="Resolution 100ps">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="5">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1ns"
style="push"
tooltip="Resolution 1ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="6">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10ns"
style="push"
tooltip="Resolution 10ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="7">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ns"
style="push"
tooltip="Resolution 100ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="8">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1us"
style="push"
tooltip="Resolution 1us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="9">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10us"
style="push"
tooltip="Resolution 10us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="10">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100us"
style="push"
tooltip="Resolution 100us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="11">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1ms"
style="push"
tooltip="Resolution 1ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="12">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10ms"
style="push"
tooltip="Resolution 10ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="13">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ms"
style="push"
tooltip="Resolution 100ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="14">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1s"
style="push"
tooltip="Resolution 1s">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="15">
</parameter>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
@ -157,9 +302,37 @@
id="com.minres.scviewer.ui.gotoPrev"
name="Prev">
</command>
<command
defaultHandler="com.minres.scviewer.ui.handler.Zoom"
description="Set the zoom level"
id="com.minres.scviewer.ui.zoom"
name="Zoom">
<commandParameter
id="com.minres.scviewer.ui.zoom.level"
name="level"
optional="true">
</commandParameter>
</command>
<command
id="com.minres.scviewer.ui.zoomin"
name="Zoom in">
</command>
<command
id="com.minres.scviewer.ui.zoomout"
name="Zoom out">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.minres.scviewer.ui.handler.GotoPrev"
commandId="com.minres.scviewer.ui.gotoPrev">
<enabledWhen>
<reference
definitionId="com.minres.scviewer.ui.oneElementSeleted">
</reference>
</enabledWhen>
</handler>
<handler
class="com.minres.scviewer.ui.handler.GotoNext"
commandId="com.minres.scviewer.ui.gotoNext">
@ -170,11 +343,20 @@
</enabledWhen>
</handler>
<handler
class="com.minres.scviewer.ui.handler.GotoPrev"
commandId="com.minres.scviewer.ui.gotoPrev">
class="com.minres.scviewer.ui.handler.ZoomInOut"
commandId="com.minres.scviewer.ui.zoomin">
<enabledWhen>
<reference
definitionId="com.minres.scviewer.ui.oneElementSeleted">
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</enabledWhen>
</handler>
<handler
class="com.minres.scviewer.ui.handler.ZoomInOut"
commandId="com.minres.scviewer.ui.zoomout">
<enabledWhen>
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</enabledWhen>
</handler>
@ -206,5 +388,30 @@
</with>
</definition>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="com.minres.scviewer.ui.gotoPrev"
disabledIcon="res/images/previous-green-d.png"
icon="res/images/previous-green.png">
</image>
<image
commandId="com.minres.scviewer.ui.gotoNext"
disabledIcon="res/images/next-green-d.png"
icon="res/images/next-green.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoom"
icon="res/images/zoom.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoomin"
icon="res/images/zoom_in.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoomout"
icon="res/images/zoom_out.png">
</image>
</extension>
</plugin>

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

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.ui;
import org.eclipse.ui.part.EditorActionBarContributor;

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.ui;
import java.util.ArrayList;
@ -11,6 +21,8 @@ public class TxEditorInput extends FileEditorInput {
private ArrayList<String> streamNames;
private Boolean secondaryLoaded=null;
public TxEditorInput(IFile file) {
super(file);
streamNames=new ArrayList<String>();
@ -27,5 +39,13 @@ public class TxEditorInput extends FileEditorInput {
public List<String> getStreamNames() {
return streamNames;
}
public Boolean isSecondaryLoaded() {
return secondaryLoaded;
}
public void setSecondaryLoaded(Boolean secondaryLoaded) {
this.secondaryLoaded = secondaryLoaded;
}
}

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.ui;
import java.io.ByteArrayInputStream;
@ -21,13 +31,18 @@ public class TxEditorInputFactory implements IElementFactory {
* with the "org.eclipse.ui.elementFactories" extension point.
*/
private static final String ID_FACTORY = "com.minres.scviewer.ui.TxEditorInputFactory"; //$NON-NLS-1$
/**
* Tag for the IFile.fullPath of the file resource.
*/
private static final String TAG_PATH = "path"; //$NON-NLS-1$
private static final String STREAMLIST_PATH = "stream_list"; //$NON-NLS-1$
/**
* Tag for the secondaryLoade of the resource.
*/
private static final String TAG_SECONDARY = "secondary"; //$NON-NLS-1$
/**
* Tag for the streamList of the resource.
*/
private static final String TAG_STREAMLIST = "stream_list"; //$NON-NLS-1$
/**
* Creates a new factory.
@ -45,13 +60,15 @@ public class TxEditorInputFactory implements IElementFactory {
if (fileName == null) {
return null;
}
// Get a handle to the IFile...which can be a handle
// to a resource that does not exist in workspace
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileName));
if (file != null) {
TxEditorInput tei = new TxEditorInput(file);
String listData = memento.getString(STREAMLIST_PATH);
Boolean isSecondaryLoaded = memento.getBoolean(TAG_SECONDARY);
if(isSecondaryLoaded!=null)
tei.setSecondaryLoaded(isSecondaryLoaded);
String listData = memento.getString(TAG_STREAMLIST);
if (listData != null) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(javax.xml.bind.DatatypeConverter.parseHexBinary(listData));
@ -85,11 +102,12 @@ public class TxEditorInputFactory implements IElementFactory {
public static void saveState(IMemento memento, TxEditorInput input) {
IFile file = input.getFile();
memento.putString(TAG_PATH, file.getFullPath().toString());
if(input.isSecondaryLoaded()!=null) memento.putBoolean(TAG_SECONDARY, input.isSecondaryLoaded());
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(input.getStreamNames());
memento.putString(STREAMLIST_PATH, javax.xml.bind.DatatypeConverter.printHexBinary(baos.toByteArray()));
memento.putString(TAG_STREAMLIST, javax.xml.bind.DatatypeConverter.printHexBinary(baos.toByteArray()));
} catch (IOException e) {
}
}

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui;
@ -20,12 +20,10 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
@ -40,13 +38,10 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.WaveformDb;
import com.minres.scviewer.ui.handler.GotoDirection;
import com.minres.scviewer.ui.swt.TxDisplay;
@ -76,19 +71,6 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
public void createPartControl(Composite parent) {
myParent=parent;
database=new WaveformDb();
txDisplay = new TxDisplay(parent);
txDisplay.setMaxTime(0);
getSite().setSelectionProvider(txDisplay);
new Thread(new Runnable() {
@Override
public void run() {
try {
loadDatabases();
} catch (InvocationTargetException | IOException | InterruptedException e) {
handleLoadException(e);
}
}
}).run();
database.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@ -102,6 +84,19 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
}
}
});
txDisplay = new TxDisplay(parent);
txDisplay.setMaxTime(0);
getSite().setSelectionProvider(txDisplay);
new Thread(new Runnable() {
@Override
public void run() {
try {
loadDatabases();
} catch (InvocationTargetException | IOException | InterruptedException e) {
handleLoadException(e);
}
}
}).run();
}
/*
@ -121,23 +116,35 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
IProgressService ps = wb.getProgressService();
IEditorInput input = getEditorInput();
File file=null;
boolean loadSecondary=false;
boolean dontAskForSecondary=false;
ArrayList<File> filesToLoad=new ArrayList<File>();
if(input instanceof IFileEditorInput){
file = ((IFileEditorInput) input).getFile().getLocation().toFile();
if(input instanceof TxEditorInput){
TxEditorInput txInput = (TxEditorInput) input;
file = txInput.getFile().getLocation().toFile();
loadSecondary=txInput.isSecondaryLoaded()==null||txInput.isSecondaryLoaded();
dontAskForSecondary=txInput.isSecondaryLoaded()!=null;
} else if(input instanceof FileStoreEditorInput){
file=new File(((FileStoreEditorInput) input).getURI().getPath());
}
if(file.exists()){
filesToLoad.add(file);
if(loadSecondary){
String ext = getFileExtension(file.getName());
if("vcd".equals(ext.toLowerCase())){
if(askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txdb"))))
if(dontAskForSecondary || askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txdb")))){
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txdb")));
else if(askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txlog"))))
if(input instanceof TxEditorInput) ((TxEditorInput) input).setSecondaryLoaded(true);
}else if(dontAskForSecondary ||askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "txlog")))){
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "txlog")));
if(input instanceof TxEditorInput) ((TxEditorInput) input).setSecondaryLoaded(true);
}
} else if("txdb".equals(ext.toLowerCase()) || "txlog".equals(ext.toLowerCase())){
if(askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "vcd"))))
if(dontAskForSecondary || askIfToLoad(new File(renameFileExtension(file.getCanonicalPath(), "vcd")))){
filesToLoad.add(new File(renameFileExtension(file.getCanonicalPath(), "vcd")));
if(input instanceof TxEditorInput) ((TxEditorInput) input).setSecondaryLoaded(true);
}
}
}
}
@ -183,7 +190,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
if(TxEditorPart.this.getEditorInput() instanceof TxEditorInput &&
((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames().size()>0){
for(String streamName:((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames()){
IWaveform stream = database.getStreamByName(streamName);
IWaveform<? extends IWaveformEvent> stream = database.getStreamByName(streamName);
if(stream!=null)
txDisplay.getStreamList().add(stream);
}
@ -266,7 +273,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
return database;
}
public void addStreamToList(IWaveform obj){
public void addStreamToList(IWaveform<? extends IWaveformEvent> obj){
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
txDisplay.getStreamList().add(obj);
@ -275,12 +282,12 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
}
public void addStreamsToList(IWaveform[] iWaveforms){
for(IWaveform stream:iWaveforms)
public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms){
for(IWaveform<? extends IWaveformEvent> stream:iWaveforms)
addStreamToList(stream);
}
public void removeStreamFromList(IWaveform obj){
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> obj){
if(getEditorInput() instanceof TxEditorInput && ((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().remove(obj.getFullName());
txDisplay.getStreamList().remove(obj);
@ -288,12 +295,12 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
txDisplay.getStreamList().remove(obj);
}
public void removeStreamsFromList(IWaveform[] iWaveforms){
for(IWaveform stream:iWaveforms)
public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms){
for(IWaveform<? extends IWaveformEvent> stream:iWaveforms)
removeStreamFromList(stream);
}
public List<IWaveform> getStreamList(){
public List<IWaveform<? extends IWaveformEvent>> getStreamList(){
return txDisplay.getStreamList();
}
@ -315,4 +322,16 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
txDisplay.moveSelection( next);
}
public void setZoomLevel(Integer level) {
txDisplay.setZoomLevel(level);
}
public void setZoomFit() {
txDisplay.setZoomLevel(6);
}
public int getZoomLevel() {
return txDisplay.getZoomLevel();
}
}

View File

@ -1,18 +1,16 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.adapter;

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.ui.adapter;
import org.eclipse.core.runtime.IAdapterFactory;

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.ui.handler;
public enum GotoDirection {PREV, NEXT}

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.ui.handler;
import org.eclipse.core.commands.AbstractHandler;

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.ui.handler;
import org.eclipse.core.commands.AbstractHandler;

View File

@ -0,0 +1,41 @@
/*******************************************************************************
* 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.ui.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.minres.scviewer.ui.TxEditorPart;
public class Zoom extends AbstractHandler {
private static final String PARM_MSG = "com.minres.scviewer.ui.zoom.level";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
String msg = event.getParameter(PARM_MSG);
if (msg == null) {
if(editor instanceof TxEditorPart){
((TxEditorPart)editor).setZoomFit();
}
} else {
Integer level = Integer.parseInt(msg);
if(editor instanceof TxEditorPart){
((TxEditorPart)editor).setZoomLevel(level);
}
}
return null;
}
}

View File

@ -0,0 +1,39 @@
/*******************************************************************************
* 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.ui.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.minres.scviewer.ui.TxEditorPart;
public class ZoomInOut extends AbstractHandler {
private static final String ZOOMIN_ID = "com.minres.scviewer.ui.zoomin";
private static final String ZOOMOUT_ID= "com.minres.scviewer.ui.zoomout";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if(editor instanceof TxEditorPart){
String id = event.getCommand().getId();
TxEditorPart txEditor=(TxEditorPart) editor;
if (ZOOMIN_ID.compareTo(id) == 0)
txEditor.setZoomLevel(txEditor.getZoomLevel()-1);
else if(ZOOMOUT_ID.compareTo(id) == 0)
txEditor.setZoomLevel(txEditor.getZoomLevel()+1);
}
return null;
}
}

View File

@ -0,0 +1,50 @@
/*******************************************************************************
* 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.ui.swt;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
class CursorPainter implements IPainter {
/**
*
*/
private final WaveformCanvas waveCanvas;
private long time;
/**
* @param i
* @param txDisplay
*/
CursorPainter(WaveformCanvas txDisplay, long time) {
this.waveCanvas = txDisplay;
this.time=time;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public void paintArea(GC gc, Rectangle area) {
if(this.waveCanvas.streams.size()>0){
int x = (int) (time/waveCanvas.getScaleFactor());
if(x>=area.x && x<=(area.x+area.width)){
gc.setForeground(waveCanvas.colors[WaveformCanvas.Colors.CURSOR.ordinal()]);
gc.drawLine(x, area.y, x, area.y+area.height);
}
}
}
}

View File

@ -1,7 +1,16 @@
/*******************************************************************************
* 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.ui.swt;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
public interface IPainter {

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.ui.swt;

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.ui.swt;
import java.beans.PropertyChangeEvent;
@ -208,6 +218,7 @@ public class ObservableList<E> implements List<E> {
List<E> values = new ArrayList<E>();
if (c != null) {
for (Iterator<?> i = c.iterator(); i.hasNext();) {
@SuppressWarnings("unchecked")
E element = (E) i.next();
if (this.delegate.contains(element)) {
values.add(element);

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.ui.swt;
import org.eclipse.swt.SWT;
@ -19,21 +29,26 @@ public class Ruler extends Composite {
static final int tickY = 15;
static final int majorTickY = 5;
static final int rulerTickMinor = 10;
static final int rulerTickMajor = 100;
static final int rulerTickMinorC = 10;
static final int rulerTickMajorC = 100;
private int length;
private int start;
private long start;
private TxEditorPlugin plugin;
private Color headerBgColor;
private Color headerFgColor;
private int bottom;
private int baselineY;
Ruler(Composite parent, int style, int lenght) {
private long scaleFactor=1000000;
private long rulerScaleFactor=1000000;
private long rulerTickMinor = rulerTickMinorC*scaleFactor;
private long rulerTickMajor = rulerTickMajorC*scaleFactor;
private String unit="";
Ruler(Composite parent, int style) {
super(parent, style | SWT.DOUBLE_BUFFERED);
this.length=lenght;
this.length=0;
headerBgColor=getDisplay().getSystemColor(SWT.COLOR_WHITE);
headerFgColor=getDisplay().getSystemColor(SWT.COLOR_BLACK);
plugin=TxEditorPlugin.getDefault();
@ -71,10 +86,10 @@ public class Ruler extends Composite {
void paintControl(PaintEvent e) {
GC gc = e.gc;
int startMinorIncr = start;
int modulo = start % rulerTickMinor;
long startMinorIncr = start;
long modulo = start % rulerTickMinor;
startMinorIncr+=rulerTickMinor-modulo;
int end=start+e.width;
long end=start+e.width*scaleFactor;
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(new Rectangle(e.x, e.y, e.width, height));
@ -83,10 +98,10 @@ public class Ruler extends Composite {
gc.setForeground(headerFgColor);
gc.drawLine(0, bottom, e.width, bottom);
for (int tick = startMinorIncr; tick < end; tick += rulerTickMinor) {
int x0 = tick-start;
for (long tick = startMinorIncr; tick < end; tick += rulerTickMinor) {
int x0 = (int) ((tick-start)/scaleFactor);
if ((tick % rulerTickMajor) == 0) {
gc.drawText(Integer.toString(tick), x0, 0);
gc.drawText(Double.toString(tick/rulerScaleFactor)+unit, (int) x0, 0);
gc.drawLine(x0, majorTickY, x0, bottom);
} else {
gc.drawLine(x0, tickY, x0, bottom);
@ -99,8 +114,34 @@ public class Ruler extends Composite {
return new Point(0, height);
}
public void setStartPoint(int start) {
this.start=start;
public void setStartPoint(long l) {
this.start=l;
redraw();
}
public void setScaleFactor(long scaleFactor) {
this.scaleFactor=scaleFactor;
if(scaleFactor<1000L){
unit="fs";
rulerScaleFactor=(long) 1e0;
}else if(scaleFactor<1000000L){
unit="ps";
rulerScaleFactor=(long) 1e3;
}else if(scaleFactor<1000000000L){
unit="ns";
rulerScaleFactor=(long) 1e6;
}else if(scaleFactor<1000000000000L){
unit="us";
rulerScaleFactor=(long) 1e9;
}else if(scaleFactor<1000000000000000L){
unit="ms";
rulerScaleFactor=(long) 1e9;
}else{
unit="s";
rulerScaleFactor=(long) 1e12;
}
this.rulerTickMinor = rulerTickMinorC*scaleFactor;
this.rulerTickMajor = rulerTickMajorC*scaleFactor;
redraw();
}
}

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.ui.swt;
import java.util.Map.Entry;
@ -32,7 +42,10 @@ class SignalPainter implements IWaveformPainter {
}
public void paintArea(GC gc, Rectangle area) {
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.getId()==signal.getId())
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.fillRectangle(area);
Entry<Long, ? extends ISignalChange> firstChange=signal.getEvents().floorEntry(area.x*this.waveCanvas.getScaleFactor());
@ -128,4 +141,8 @@ class SignalPainter implements IWaveformPainter {
return height;
}
public ISignal<? extends ISignalChange> getSignal() {
return signal;
}
}

View File

@ -1,11 +1,24 @@
/*******************************************************************************
* 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.ui.swt;
import java.util.Collection;
import java.util.Map;
import java.util.List;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeSet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ITx;
@ -22,6 +35,7 @@ class StreamPainter implements IWaveformPainter{
private int height, upper, txHeight;
private int totalHeight;
private boolean even;
private TreeSet<ITx> seenTx;
public StreamPainter(WaveformCanvas txDisplay, boolean even, int height, ITxStream<? extends ITxEvent> stream) {
this.waveCanvas = txDisplay;
@ -31,10 +45,15 @@ class StreamPainter implements IWaveformPainter{
this.txHeight=3*this.waveCanvas.getTrackHeight()/5;
this.totalHeight=stream.getMaxConcurrency()*this.waveCanvas.getTrackHeight();
this.even=even;
this.seenTx=new TreeSet<ITx>();
}
@SuppressWarnings("unchecked")
public void paintArea(GC gc, Rectangle area) {
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.getId()==stream.getId())
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.fillRectangle(area);
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
@ -45,24 +64,42 @@ class StreamPainter implements IWaveformPainter{
} else if(lastTx==null){
lastTx=stream.getEvents().lastEntry();
}
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TX_BG.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.setLineStyle(SWT.LINE_SOLID);
gc.setLineWidth(1);
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
for(int y1=area.y+this.waveCanvas.getTrackHeight()/2; y1<area.y+totalHeight; y1+=this.waveCanvas.getTrackHeight())
gc.drawLine(area.x, y1, area.x+area.width, y1);
if(firstTx==lastTx)
for(ITxEvent x:(Collection<? extends ITxEvent>)firstTx.getValue())
drawTx(gc, area, x.getTransaction());
else{
for(Entry<Long, ?> tx: stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true).entrySet())
for(ITxEvent x:(Collection<? extends ITxEvent>)tx.getValue())
if(x.getType()==ITxEvent.Type.END) drawTx(gc, area, x.getTransaction());
seenTx.clear();
NavigableMap<Long,?> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
for(Entry<Long, ?> tx: entries.entrySet())
for(ITxEvent x:(Collection<? extends ITxEvent>)tx.getValue()){
if(x.getType()==ITxEvent.Type.BEGIN)
seenTx.add(x.getTransaction());
if(x.getType()==ITxEvent.Type.END){
drawTx(gc, area, x.getTransaction());
seenTx.remove(x.getTransaction());
}
}
for(ITx tx:seenTx){
drawTx(gc, area, tx);
}
}
}
protected void drawTx(GC gc, Rectangle area, ITx tx) {
if(waveCanvas.currentSelection!=null && waveCanvas.currentSelection.getId()==tx.getId()){
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE_HIGHLITE.ordinal()]);
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TX_BG_HIGHLITE.ordinal()]);
}else {
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TX_BG.ordinal()]);
}
int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight();
Rectangle bb = new Rectangle(
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+upper,
@ -82,4 +119,26 @@ class StreamPainter implements IWaveformPainter{
return height;
}
public Object getClicked(Point point) {
int lane=point.y/waveCanvas.getTrackHeight();
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
if(firstTx!=null){
do {
ITx tx = getTxFromEntry(lane, firstTx);
if(tx!=null) return tx;
firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
}while(firstTx!=null);
}
return stream;
}
protected ITx getTxFromEntry(int lane, Entry<Long, List<ITxEvent>> firstTx) {
for(ITxEvent evt:firstTx.getValue()){
if(evt.getType()==ITxEvent.Type.BEGIN && evt.getTransaction().getConcurrencyIndex()==lane){
return evt.getTransaction();
}
}
return null;
}
}

View File

@ -1,8 +1,17 @@
/*******************************************************************************
* 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.ui.swt;
import java.util.Map.Entry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

View File

@ -1,21 +1,20 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.swt;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.NavigableMap;
import java.util.Vector;
import java.util.Map.Entry;
import java.util.TreeMap;
@ -33,24 +32,21 @@ import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.TextLayout;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@ -68,45 +64,44 @@ import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.ui.handler.GotoDirection;
public class TxDisplay implements PropertyChangeListener, ISelectionProvider, MouseListener{
private ListenerList listeners = new ListenerList();
private IWaveform currentStreamSelection;
private static final String SELECTION="selection";
private ITx currentSelection;
private IWaveform currentWaveformSelection;
private IWaveform<? extends IWaveformEvent> currentWaveformSelection;
private ScrolledComposite nameListScrolled;
private ScrolledComposite valueListScrolled;
private Canvas nameList;
private Canvas valueList;
private WaveformCanvas trackList;
WaveformCanvas trackList;
private Composite top;
ObservableList<IWaveform> streams;
protected ObservableList<IWaveform<? extends IWaveformEvent>> streams;
Vector<CursorPainter> cursorPainters;
private Composite trackPane;
private Ruler ruler;
TreeMap<Integer, IWaveform> trackVerticalOffset;
TreeMap<Integer, IWaveform<? extends IWaveformEvent>> trackVerticalOffset;
HashMap<IWaveform<? extends IWaveformEvent>, String> actualValues;
// private long maxTime=0;
private Font nameFont;
private Font valueFont;
private Font nameFont, nameFontB;
public TxDisplay(Composite parent) {
trackVerticalOffset = new TreeMap<Integer, IWaveform>();
Display d =parent.getDisplay();
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
dispose();
}
});
FontDescriptor fontDescriptor = FontDescriptor.createFrom(d.getSystemFont()).setStyle(SWT.BOLD);
nameFont = fontDescriptor.createFont(d);
valueFont = fontDescriptor.createFont(d);
trackVerticalOffset = new TreeMap<Integer, IWaveform<? extends IWaveformEvent>>();
actualValues= new HashMap<IWaveform<? extends IWaveformEvent>, String>();
cursorPainters=new Vector<CursorPainter>();
nameFont = parent.getDisplay().getSystemFont();
nameFontB = SWTResourceManager.getBoldFont(nameFont);
streams=new ObservableList<IWaveform>();
streams=new ObservableList<IWaveform<? extends IWaveformEvent>>();
streams.addPropertyChangeListener(this);
top = new Composite(parent, SWT.NONE);
@ -184,13 +179,17 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
trackPane = new Composite(topSash, SWT.NONE);
trackPane.setLayout(new BorderLayout(0, 0));
ruler = new Ruler(trackPane, SWT.NONE, 0);
ruler = new Ruler(trackPane, SWT.NONE);
ruler.setLayoutData(BorderLayout.NORTH);
trackList = new WaveformCanvas(trackPane, SWT.NONE);
trackList.setLayoutData(BorderLayout.CENTER);
trackList.streams=streams;
trackList.addTrackPainter(new TrackPainter(trackList));
trackList.setStreams(streams);
trackList.setRuler(ruler);
trackList.addPainter(new TrackPainter(trackList));
CursorPainter cp = new CursorPainter(trackList, trackList.getScaleFactor()*10);
trackList.addPainter(cp);
cursorPainters.add(cp);
trackList.setMaxTime(1);
trackList.addMouseListener(this);
@ -208,11 +207,6 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
trackList.scrollToY(y);
}
});
trackList.getHorizontalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ruler.setStartPoint(trackList.getHorizontalBar().getSelection());
}
});
trackList.getVerticalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int y = trackList.getVerticalBar().getSelection();
@ -225,10 +219,6 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
}
protected void dispose() {
nameFont.dispose();
valueFont.dispose();
}
private Composite createTextPane(SashForm leftSash, String text) {
Composite namePane = new Composite(leftSash, SWT.NONE);
@ -261,40 +251,54 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
}
}
@SuppressWarnings("unchecked")
protected void updateTracklist() {
int yoffs=0;
int nameMaxWidth=0;
int valueMaxWidth=0;
IWaveformPainter painter=null;
trackVerticalOffset.clear();
actualValues.clear();
trackList.clearAllWavefromPainter();
boolean even=true;
TextLayout tl = new TextLayout(trackList.getDisplay());
for(IWaveform waveform:streams){
tl.setFont(nameFontB);
for(IWaveform<? extends IWaveformEvent> waveform:streams){
int height=trackList.getTrackHeight();
if(waveform instanceof ITxStream){
height*=((ITxStream)waveform).getMaxConcurrency();
painter= new StreamPainter(trackList, even, height, (ITxStream) waveform);
if(waveform instanceof ITxStream<?>){
height*=((ITxStream<? extends ITxEvent>)waveform).getMaxConcurrency();
painter= new StreamPainter(trackList, even, height, (ITxStream<? extends ITxEvent>) waveform);
actualValues.put(waveform, "");
} else if(waveform instanceof ISignal<?>){
painter= new SignalPainter(trackList, even, height, (ISignal<?>) waveform);
actualValues.put(waveform, "---");
}
trackList.addWavefromPainter(yoffs, painter);
trackVerticalOffset.put(yoffs, waveform);
tl.setText(waveform.getFullName());
nameMaxWidth=Math.max(nameMaxWidth, tl.getBounds().width);
valueMaxWidth=nameMaxWidth;
yoffs+=height;
even=!even;
}
valueList.setSize(nameMaxWidth, yoffs);
nameList.setSize(valueMaxWidth, yoffs);
valueList.redraw();
nameList.setSize(nameMaxWidth+15, yoffs);
valueList.setSize(calculateValueWidth(), yoffs);
nameList.redraw();
valueList.redraw();
trackList.redraw();
top.layout(new Control[]{valueList, nameList, trackList});
}
private int calculateValueWidth() {
TextLayout tl = new TextLayout(trackList.getDisplay());
tl.setFont(nameFontB);
int valueMaxWidth=0;
for(String v:actualValues.values()){
tl.setText(v);
valueMaxWidth=Math.max(valueMaxWidth, tl.getBounds().width);
}
return valueMaxWidth+15;
}
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
listeners.add(listener);
@ -309,12 +313,13 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public ISelection getSelection() {
if(currentSelection!=null)
return new StructuredSelection(currentSelection);
else if(currentStreamSelection!=null)
return new StructuredSelection(currentStreamSelection);
else if(currentWaveformSelection!=null)
return new StructuredSelection(currentWaveformSelection);
else
return null;
}
@SuppressWarnings("unchecked")
@Override
public void setSelection(ISelection selection) {
boolean selectionChanged=false;
@ -324,9 +329,9 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
currentSelection=(ITx) sel;
currentWaveformSelection = currentSelection.getStream();
selectionChanged=true;
} else if(sel instanceof IWaveform && currentStreamSelection!=sel){
} else if(sel instanceof IWaveform<?> && currentWaveformSelection!=sel){
currentSelection=null;
currentWaveformSelection = (IWaveform) sel;
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
selectionChanged=true;
}
} else {
@ -335,6 +340,10 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
currentWaveformSelection = null;
}
if(selectionChanged){
trackList.setSelected(currentSelection, currentWaveformSelection);
nameList.setData(SELECTION, currentWaveformSelection);
valueList.redraw();
nameList.redraw();
Object[] list = listeners.getListeners();
for (int i = 0; i < list.length; i++) {
((ISelectionChangedListener) list[i]).selectionChanged(new SelectionChangedEvent(this, selection));
@ -342,21 +351,40 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
}
}
@SuppressWarnings("unchecked")
public void moveSelection(GotoDirection direction) {
if(currentStreamSelection instanceof ITxStream<?>){
ITxStream<ITxEvent> stream = (ITxStream<ITxEvent>) currentStreamSelection;
if(currentWaveformSelection instanceof ITxStream<?>){
ITxStream<ITxEvent> stream = (ITxStream<ITxEvent>) currentWaveformSelection;
ITx transaction=null;
if(direction==GotoDirection.NEXT){
Entry<Long, Collection<ITxEvent>> entry = stream.getEvents().higherEntry(currentSelection.getBeginTime());
Entry<Long, List<ITxEvent>> entry = stream.getEvents().higherEntry(currentSelection.getBeginTime());
if(entry!=null)
transaction = entry.getValue().iterator().next().getTransaction();
do {
for(ITxEvent evt:entry.getValue()){
if(evt.getType()==ITxEvent.Type.BEGIN){
transaction=evt.getTransaction();
break;
}
}
if(transaction==null)
entry=stream.getEvents().higherEntry(entry.getKey());
}while(entry!=null && transaction==null);
}else if(direction==GotoDirection.PREV){
Entry<Long, Collection<ITxEvent>> entry = stream.getEvents().lowerEntry(currentSelection.getBeginTime());
Entry<Long, List<ITxEvent>> entry = stream.getEvents().lowerEntry(currentSelection.getBeginTime());
if(entry!=null)
transaction = entry.getValue().iterator().next().getTransaction();
do {
for(ITxEvent evt:entry.getValue()){
if(evt.getType()==ITxEvent.Type.BEGIN)
transaction=evt.getTransaction();
break;
}
if(transaction==null)
entry=stream.getEvents().lowerEntry(entry.getKey());
}while(entry!=null && transaction==null);
}
if(transaction!=null){
setSelection(new StructuredSelection(transaction));
}
if(transaction!=null)
setSelection(new StructuredSelection(transaction));
}
}
@ -367,11 +395,13 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
@Override
public void mouseDown(MouseEvent e) {
if(e.widget==trackList){
}else if(e.widget==valueList){
}else if(e.widget==nameList){
Object o = trackList.getClicked(new Point(e.x, e.y));
if(o !=null)
setSelection(new StructuredSelection(o));
}else if(e.widget==valueList || e.widget==nameList){
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y);
if(entry!=null)
setSelection(new StructuredSelection(entry.getValue()));
}
}
@ -379,45 +409,66 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
public void mouseUp(MouseEvent e) {
}
public List<IWaveform> getStreamList(){
public List<IWaveform<? extends IWaveformEvent>> getStreamList(){
return streams;
}
protected void paintNames(GC gc, Rectangle rect) {
if(streams.size()>0){
IWaveform<? extends IWaveformEvent> wave = (IWaveform<? extends IWaveformEvent>) nameList.getData(SELECTION);
Integer firstKey=trackVerticalOffset.floorKey(rect.y);
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y+rect.height);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, 0);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, trackList.getTrackHeight());
if(lastKey==firstKey){
drawTextFormat(gc, subArea, firstKey, trackVerticalOffset.get(firstKey).getFullName());
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
if(w instanceof ITxStream<?>)
subArea.height*=((ITxStream<?>)w).getMaxConcurrency();
drawTextFormat(gc, subArea, firstKey, w.getFullName(), wave!=null && w.getId()==wave.getId());
}else{
for(Entry<Integer, IWaveform> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
drawTextFormat(gc, subArea, entry.getKey(), entry.getValue().getFullName());
for(Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
IWaveform<? extends IWaveformEvent> w = entry.getValue();
subArea.height=trackList.getTrackHeight();
if(w instanceof ITxStream<?>)
subArea.height*=((ITxStream<?>)w).getMaxConcurrency();
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), wave!=null && w.getId()==wave.getId());
}
}
}
}
@SuppressWarnings("unchecked")
protected void paintValues(GC gc, Rectangle rect) {
if(streams.size()>0){
IWaveform<? extends IWaveformEvent> wave = (IWaveform<? extends IWaveformEvent>) nameList.getData(SELECTION);
Integer firstKey=trackVerticalOffset.floorKey(rect.y);
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y+rect.height);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, 0);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, trackList.getTrackHeight());
if(lastKey==firstKey){
drawTextFormat(gc, subArea, firstKey, trackVerticalOffset.get(firstKey).getFullName());
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey);
if(w instanceof ITxStream<?>)
subArea.height*=((ITxStream<?>)w).getMaxConcurrency();
drawTextFormat(gc, subArea, firstKey, actualValues.get(w), wave!=null && w.getId()==wave.getId());
}else{
for(Entry<Integer, IWaveform> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
drawTextFormat(gc, subArea, entry.getKey(), "---");
for(Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
IWaveform<? extends IWaveformEvent> w = entry.getValue();
subArea.height=trackList.getTrackHeight();
if(w instanceof ITxStream<?>)
subArea.height*=((ITxStream<?>)w).getMaxConcurrency();
drawTextFormat(gc, subArea, entry.getKey(), actualValues.get(w), wave!=null && w.getId()==wave.getId());
}
}
}
}
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String p) {
Point size = gc.textExtent(p);
gc.drawText(p, subArea.x, subArea.y + yOffset+(trackList.getTrackHeight()-size.y)/2, true);
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
Point size = gc.textExtent(value);
if(highlite)
gc.setFont(nameFontB);
else
gc.setFont(nameFont);
gc.drawText(value, subArea.x+5, subArea.y + yOffset+(trackList.getTrackHeight()-size.y)/2, true);
}
public long getMaxTime() {
@ -428,4 +479,14 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
this.trackList.setMaxTime(maxTime);
}
public void setZoomLevel(int scale) {
trackList.setZoomLevel(scale);
}
public int getZoomLevel() {
return trackList.getZoomLevel();
}
// public long getScaleFactor(){
// return trackList.getScaleFactor();
// }
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH.
* 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
@ -10,11 +10,10 @@
*******************************************************************************/
package com.minres.scviewer.ui.swt;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.eclipse.swt.SWT;
@ -26,11 +25,9 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
@ -38,7 +35,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.wb.swt.SWTResourceManager;
import com.google.common.collect.Lists;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
public class WaveformCanvas extends Canvas {
public enum Colors {
@ -54,25 +54,27 @@ public class WaveformCanvas extends Canvas {
SIGNAL1,
SIGNALZ,
SIGNALX,
SIGNAL_TEXT
SIGNAL_TEXT,
CURSOR
}
Color[] colors=new Color[Colors.values().length];
/* zooming rates in x and y direction are equal.*/
final float ZOOMIN_RATE = 1.1f; /* zoomin rate */
final float ZOOMOUT_RATE = 0.9f; /* zoomout rate */
private int trackHeight = 50;
private long scaleFactor = 1000000L;
private int level=6;
private long maxTime;
protected Point origin; /* original size */
protected Transform transform;
protected Ruler ruler;
protected List<IPainter> painterList;
TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
List<IWaveform> streams;
protected List<IWaveform<? extends IWaveformEvent>> streams;
ITx currentSelection;
IWaveform<? extends IWaveformEvent> currentWaveformSelection;
/**
* Constructor for ScrollableCanvas.
@ -112,8 +114,8 @@ public class WaveformCanvas extends Canvas {
colors[Colors.LINE.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_RED);
colors[Colors.LINE_HIGHLITE.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_CYAN);
colors[Colors.TRACK_BG_EVEN.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_BLACK);
colors[Colors.TRACK_BG_ODD.ordinal()]=SWTResourceManager.getColor(25,25,25);
colors[Colors.TRACK_BG_HIGHLITE.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[Colors.TRACK_BG_ODD.ordinal()]=SWTResourceManager.getColor(40,40,40);
colors[Colors.TRACK_BG_HIGHLITE.ordinal()]=SWTResourceManager.getColor(40,40,80);
colors[Colors.TX_BG.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[Colors.TX_BG_HIGHLITE.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[Colors.TX_BORDER.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_RED);
@ -122,9 +124,30 @@ public class WaveformCanvas extends Canvas {
colors[Colors.SIGNALZ.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[Colors.SIGNALX.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_RED);
colors[Colors.SIGNAL_TEXT.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[Colors.CURSOR.ordinal()]=SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
}
}
public List<IWaveform<? extends IWaveformEvent>> getStreams() {
return streams;
}
public void setStreams(List<IWaveform<? extends IWaveformEvent>> streams) {
this.streams = streams;
}
public Ruler getRuler(){
return ruler;
}
public void setRuler(Ruler ruler) {
this.ruler=ruler;
}
public Object getOrigin() {
return origin;
}
public long getMaxTime() {
return maxTime;
}
@ -143,20 +166,27 @@ public class WaveformCanvas extends Canvas {
syncScrollBars();
}
public void setZoomLevel(int level) {
this.level=level;
this.scaleFactor = (long) Math.pow(10, level);
if(ruler!=null) ruler.setStartPoint(-origin.x*scaleFactor);
syncScrollBars();
}
public int getZoomLevel() {
return level;
}
public long getScaleFactor() {
return scaleFactor;
}
public void setScaleFactor(long scaleFactor) {
this.scaleFactor = scaleFactor;
}
public void addTrackPainter(IPainter painter) {
public void addPainter(IPainter painter) {
painterList.add(painter);
redraw();
}
public void removeTrackPainter(IPainter painter){
public void removePainter(IPainter painter){
painterList.remove(painter);
redraw();
}
@ -196,6 +226,7 @@ public class WaveformCanvas extends Canvas {
private void scrollHorizontally(ScrollBar scrollBar) {
if (painterList.size()==0) return;
origin.x= -scrollBar.getSelection();
if(ruler!=null) ruler.setStartPoint(-origin.x*scaleFactor);
syncScrollBars();
}
@ -271,6 +302,7 @@ public class WaveformCanvas extends Canvas {
}
vertical.setSelection(-origin.y);
vertical.setThumb(ch);
ruler.setScaleFactor(scaleFactor);
redraw();
}
@ -293,5 +325,44 @@ public class WaveformCanvas extends Canvas {
initScrollBars();
}
}
public Object getClicked(Point point) {
for(IPainter p:Lists.reverse(painterList)){
if(p instanceof TrackPainter){
int y= point.y-origin.y;
int x=point.x-origin.x;
Entry<Integer, IWaveformPainter> entry = trackVerticalOffset.floorEntry(y);
if(entry!=null){
if(entry.getValue() instanceof StreamPainter){
return ((StreamPainter)entry.getValue()).getClicked(new Point(x,y-entry.getKey()));
}else if(entry.getValue() instanceof SignalPainter)
return ((SignalPainter)entry.getValue()).getSignal();
}
}else if(p instanceof CursorPainter){
if(Math.abs(point.x*scaleFactor-((CursorPainter)p).getTime())<2){
return p;
}
}
}
return null;
}
public void setSelected(ITx currentSelection, IWaveform<? extends IWaveformEvent> currentWaveformSelection) {
this.currentSelection=currentSelection;
this.currentWaveformSelection=currentWaveformSelection;
if(currentSelection!=null) reveal(currentSelection.getBeginTime(), currentSelection.getEndTime());
redraw();
}
public void reveal(Long beginTime, Long endTime) {
int lower = (int) (beginTime/scaleFactor);
int higher=(int) (endTime/scaleFactor);
Point size = getSize();
if(lower<-origin.x){
scrollToX(lower);
} else if(higher>(size.x-origin.x)){
scrollToX(higher-size.x);
}
}
}

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views;
@ -27,20 +27,16 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.ui.TxEditorPart;
import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider;
import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider;
@ -119,7 +115,7 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
*/
public void init(IPageSite pageSite) {
super.init(pageSite);
IActionBars bars = pageSite.getActionBars();
// IActionBars bars = pageSite.getActionBars();
}
private void fillContextMenu(IMenuManager menuMgr) {
@ -181,21 +177,22 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
private Action makeStreamAction(String text, String imgDescriptor, final IStructuredSelection selection, boolean enabled, final boolean remove) {
Action action = new Action() {
@SuppressWarnings("unchecked")
public void run() {
if(selection!=null)
for(Object obj :selection.toArray()){
if(obj instanceof IWaveform){
if(remove)
editor.removeStreamFromList((IWaveform) obj);
editor.removeStreamFromList((IWaveform<? extends IWaveformEvent>) obj);
else
editor.addStreamToList((IWaveform) obj);
editor.addStreamToList((IWaveform<? extends IWaveformEvent>) obj);
} else if(obj instanceof IHierNode){
LinkedList<IHierNode> queue = new LinkedList<IHierNode>();
LinkedList<IWaveform> streams = new LinkedList<IWaveform>();
LinkedList<IWaveform<? extends IWaveformEvent>> streams = new LinkedList<IWaveform<? extends IWaveformEvent>>();
queue.add((IHierNode)obj);
while(queue.size()>0){
IHierNode n = queue.poll();
if(n instanceof IWaveform) streams.add((IWaveform) n);
if(n instanceof IWaveform) streams.add((IWaveform<? extends IWaveformEvent>) n);
queue.addAll(n.getChildNodes());
}
if(remove)

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views.provider;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views.provider;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views.sections;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* 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:
* IT Just working - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.ui.views.sections;

View File

@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* 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:
* Google, Inc. - initial API and implementation
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.swt;

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
*******************************************************************************/
#include <cstdio>
#include <iostream>
#include <string>