本文整理汇总了Java中prefuse.data.io.DataIOException类的典型用法代码示例。如果您正苦于以下问题:Java DataIOException类的具体用法?Java DataIOException怎么用?Java DataIOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataIOException类属于prefuse.data.io包,在下文中一共展示了DataIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/**
* @see java.lang.Runnable#run()
*/
public void run() {
while ( true ) {
Entry e = null;
synchronized ( s_queue ) {
if ( s_queue.size() > 0 )
e = (Entry)s_queue.remove(0);
}
if ( e != null ) {
try {
if ( e.listener != null ) e.listener.preQuery(e);
e.ds.getData(e.table, e.query, e.keyField, e.lock);
if ( e.listener != null ) e.listener.postQuery(e);
} catch ( DataIOException dre ) {
s_logger.warning(dre.getMessage() + "\n"
+ StringLib.getStackTrace(dre));
}
} else {
// nothing to do, chill out until notified
try {
synchronized (this) { wait(); }
} catch (InterruptedException ex) { }
}
}
}
示例2: readGraph
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/**
* @see prefuse.data.io.GraphReader#readGraph(java.io.InputStream)
*/
@Override
public Graph readGraph(InputStream is) throws DataIOException {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
GraphMLHandler handler = new GraphMLHandler();
saxParser.parse(is, handler);
return handler.getGraph();
} catch ( Exception e ) {
if ( e instanceof DataIOException ) {
throw (DataIOException)e;
} else {
throw new DataIOException(e);
}
}
}
示例3: main
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/**
* @param args
* @throws TemporalDataException
*/
public static void main(String[] args) throws TemporalDataException {
Locale.setDefault(Locale.US);
TemporalDataset events = null;
TemporalDataset patterns = null;
try {
GraphMLTemporalDatasetReader gmltdr = new GraphMLTemporalDatasetReader();
events = gmltdr.readData("data/cardiovascular_events.graphml.gz");
DebugHelper.printTemporalDatasetTable(System.out, events,"label","class",TemporalObject.ID);
patterns = gmltdr.readData("data/cardiovascular_patterns.graphml.gz");
//DebugHelper.printTemporalDatasetForest(System.out,patterns, "label",TemporalObject.ID);
} catch (DataIOException e) {
e.printStackTrace();
}
DataHelper.printMetadata(System.out, events.getNodeTable());
DataHelper.printMetadata(System.out, patterns.getNodeTable());
createVisualization(patterns,events);
}
示例4: readData
import prefuse.data.io.DataIOException; //导入依赖的package包/类
@Override
public TemporalDataset readData(InputStream is) throws DataIOException,
TemporalDataException {
TemporalDataColumnSpecification spec = (this.spec != null) ? this.spec
: new TemporalDataColumnSpecification();
TableReader tableReader = spec.getTableFormat().getTableReader();
// XXX hack to handle prefuse String -> Date conversion in UTC
TimeZone oldDefault = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Table table = tableReader.readTable(is);
TimeZone.setDefault(oldDefault);
if (logger.isInfoEnabled()) {
logger.info("Metadata of raw table:");
DataHelper.printMetadata(System.out, table);
}
if (this.spec == null)
scanTableForSpecification(table, spec);
TemporalDataset tmpds = new TemporalDataset();
importTable(table, tmpds, spec);
table = null;
return tmpds;
}
示例5: write
import prefuse.data.io.DataIOException; //导入依赖的package包/类
private void write(final IScope scope, final Graph prefuseGraph, final GraphWriter writer, final String filename) {
try {
writer.writeGraph(prefuseGraph, filename);
} catch (final DataIOException e) {
throw GamaRuntimeException.error(
"error during the exportation of the graph with a prefuse exporter: " + e.getMessage(), scope);
}
}
示例6: getEdgeListToTable
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/** reads a delimited file to table*/
public Table getEdgeListToTable(){
DelimitedTextTableReader dttr = new DelimitedTextTableReader(getSeparatorToExtension(m_openFile));
dttr.setHasHeader(false);
try{
return dttr.readTable(m_openFile);
}catch(DataIOException e){
e.printStackTrace();
return null;
}
}
示例7: saveFile
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/** clusters to file*/
public void saveFile(File p_file){
if(m_clusterTable != null)
try{
new DelimitedTextTableWriter().writeTable(m_clusterTable, p_file);
}catch(DataIOException e){
e.printStackTrace();
}
}
示例8: readGraph
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/**
*
* Reads an edge list to a {@link prefuse.data.Graph} instance.
*
* @param file
* @param p_directed
* @return a Graph instance
*/
public Graph readGraph(File file, boolean p_directed ){
directed = p_directed;
try {
return readGraph(file);
}catch(DataIOException e){
e.printStackTrace();
}
return null;
}
示例9: demo
import prefuse.data.io.DataIOException; //导入依赖的package包/类
public static JFrame demo(String table) throws DataIOException,
TemporalDataException, IOException, JAXBException {
// TemporalDataColumnSpecification spec = new
// TemporalDataColumnSpecification();
// spec.setCalendar(CalendarManagerFactory.getSingleton(
// CalendarManagers.JavaDate).getDefaultCalendar());
// spec.setTableFormat(new TextTableFormat(Method.REGEX, true, true,
// "\t"));
// TemporalObjectEncoding enc = new DateInstantEncoding("", "Date");
// String[] dataCols = {"AvgTemp", "MaxTemp", "MinTemp",
// "Precipitation", "RelHumidity", "CloudCover", "SunshineDuration",
// "AirPressure", "Wind", "VaporContent"};
// enc.setDataColumns(dataCols);
// spec.addEncoding(enc);
// JaxbMarshaller.save(CLIMATE_DATA_SPEC, spec);
TextTableTemporalDatasetReader reader = new TextTableTemporalDatasetReader(
CLIMATE_DATA_SPEC);
TemporalDataset tmpds = reader.readData(table);
// ieg.prefuse.data.DataHelper.printTable(System.out, tmpds.getNodeTable());
ClimateDemo cd = new ClimateDemo(tmpds);
JFrame frame = new JFrame("TimeBench | climate");
frame.add(new ViewMenu(cd.timeScale), BorderLayout.EAST);
frame.add(cd, BorderLayout.CENTER);
TimeScaleHeader tsh = new TimeScaleHeader(cd.timeScale);
frame.add(tsh, BorderLayout.NORTH);
TimeScaleStatusBar statusBar = new TimeScaleStatusBar(cd.timeScale);
// Mac-Workaround: GrowBox hides Label
statusBar.add(Box.createHorizontalStrut(20));
frame.add(statusBar, BorderLayout.SOUTH);
frame.pack();
frame.setLocationRelativeTo(null);
return frame;
}
示例10: readData
import prefuse.data.io.DataIOException; //导入依赖的package包/类
@Override
public TemporalDataset readData(String location) throws DataIOException,
TemporalDataException {
try {
InputStream is = IOLib.streamFromString(location);
if (is == null)
throw new DataIOException("Couldn't find " + location
+ ". Not a valid file, URL, or resource locator.");
return readData(is);
} catch (IOException e) {
throw new DataIOException(e);
}
}
示例11: parseNode
import prefuse.data.io.DataIOException; //导入依赖的package包/类
private void parseNode(XMLStreamReader reader, TemporalDataset tmpds,
HashMap<String, String> attributeIdToName)
throws XMLStreamException, DataIOException {
String graphMLId = reader.getAttributeValue(null, Tokens.ID);
// hashMap that temporarily stores the data of a node, gathers as the
// necessary values to add it to the TMDS
HashMap<String, String> dataMap = new HashMap<String, String>();
while (reader.hasNext()) {
switch (reader.next()) {
case XMLEvent.START_ELEMENT:
if (Tokens.DATA.equals(reader.getLocalName())) {
Pair<String, String> data = parseData(reader,
attributeIdToName);
dataMap.put(data.getKey(), data.getValue());
}
break;
case XMLEvent.END_ELEMENT:
if (Tokens.NODE.equals(reader.getLocalName())) {
// node parsing complete
// ignore root node
if (!ROOT.equals(graphMLId)) {
long id = Long.parseLong(graphMLId.substring(1));
if (NodeType.OBJECT == NodeType.byPrefix(graphMLId)) {
createTemporalObject(tmpds, id, dataMap);
} else if (NodeType.ELEMENT == NodeType
.byPrefix(graphMLId)) {
createTemporalElement(tmpds, id, dataMap);
}
}
return;
}
}
}
throw new IllegalStateException(
"GraphML document ended prematurely in <node>.");
}
示例12: parseEdge
import prefuse.data.io.DataIOException; //导入依赖的package包/类
/**
* reads XML content until the edge element ends and adds it to the cache.
* @param reader
* @param edgeCache
* @param attributeIdToName
* @throws XMLStreamException
* @throws DataIOException
*/
private void parseEdge(XMLStreamReader reader, Table edgeCache,
HashMap<String, String> attributeIdToName)
throws XMLStreamException, DataIOException {
// we assume that reader is on a <edge> element
Tuple edge = edgeCache.getTuple(edgeCache.addRow());
// parse source and target from attributes -> cache
edge.set(EDGE_SOURCE, reader.getAttributeValue(null, Tokens.SOURCE));
edge.set(EDGE_TARGET, reader.getAttributeValue(null, Tokens.TARGET));
while (reader.hasNext()) {
switch (reader.next()) {
case XMLEvent.START_ELEMENT:
if (Tokens.DATA.equals(reader.getLocalName())) {
Pair<String, String> data = parseData(reader,
attributeIdToName);
if (edge.getColumnIndex(data.getKey()) >= 0) {
edge.setString(data.getKey(), data.getValue());
} else {
throw new DataIOException("Unknown attribute key "
+ data.getKey() + " with value "
+ data.getValue());
}
}
break;
case XMLEvent.END_ELEMENT:
if (Tokens.EDGE.equals(reader.getLocalName())) {
// edge parsing complete
return;
}
}
}
throw new IllegalStateException(
"GraphML document ended prematurely in <edge>.");
}
示例13: parseData
import prefuse.data.io.DataIOException; //导入依赖的package包/类
private Pair<String, String> parseData(XMLStreamReader reader,
HashMap<String, String> attributeIdToName)
throws XMLStreamException, DataIOException {
// we assume that reader is on a <data> element
String key = reader.getAttributeValue(null, Tokens.KEY);
if (key == null) {
throw new DataIOException("<data> element without key.");
}
// build string from possibly multiple characters events
StringBuilder value = new StringBuilder();
// keep track of nested elements
int depth = 0;
while (reader.hasNext()) {
switch (reader.next()) {
case XMLEvent.CHARACTERS:
if (depth == 0) {
value.append(reader.getText());
}
break;
case XMLEvent.START_ELEMENT:
depth++;
break;
case XMLEvent.END_ELEMENT:
if (depth == 0 && Tokens.DATA.equals(reader.getLocalName())) {
// <data> parsing complete
String attName = attributeIdToName.get(key);
return new ImmutablePair<String, String>(attName,
value.toString());
} else {
depth--;
}
}
}
throw new DataIOException(
"GraphML document ended prematurely in <data>.");
}
示例14: readData
import prefuse.data.io.DataIOException; //导入依赖的package包/类
@Override
public TemporalDataset readData(InputStream is) throws DataIOException,
TemporalDataException {
Calendar calender = null;
// Building a calendar object from the given FileStream
try {
calender = new CalendarBuilder().build(is);
} catch (Exception e) {
e.printStackTrace();
throw new DataIOException("Calendar could not be instantiated!");
}
if (calender.getCalendarScale() != null
&& calender.getCalendarScale() != CalScale.GREGORIAN) {
throw new TemporalDataException("Calendar is not gregorian!");
}
// Extracting only those components which match
// the previously specified componentType
ComponentList componentList = calender.getComponents(m_componentType);
return readComponent(componentList);
}
示例15: writeData
import prefuse.data.io.DataIOException; //导入依赖的package包/类
@Override
public void writeData(TemporalDataset tmpds, File f) throws DataIOException {
try {
writeData(tmpds, new FileOutputStream(f));
} catch (FileNotFoundException e) {
throw new DataIOException(e);
}
}