⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guistate.java

📁 实现对owl-s描述服务的检索
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * OWL-S Matchmaker
 * 
 * COPYRIGHT NOTICE
 * 
 * Copyright (C) 2005 DFKI GmbH, Germany
 * Developed by Benedikt Fries, Matthias Klusch
 * 
 * The code is free for non-commercial use only.
 * You can redistribute it and/or modify it under the terms
 * of the Mozilla Public License version 1.1  as
 * published by the Mozilla Foundation at
 * http://www.mozilla.org/MPL/MPL-1.1.txt
 */
package owlsmx.gui.util;


import java.awt.Component;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JOptionPane;

import owlsmx.gui.data.TaskContent;
import owlsmx.gui.data.TestCollection;



public class GUIState implements java.io.Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static GUIState instance = new GUIState();
	private String pathToServices = "";
	private String pathToQueries = "";
	private String pathToTestCollection = "";
	private double treshold=0.8;
	private int minDegree=4;
	private short simMeasure=1;
	private boolean displayAnswerset = true;
	private boolean getAQR = false;
	private boolean getMemoryConsumption = false;
	private boolean getPrecisionRecall = false;
	private Map wizardContent = new HashMap();
	private int currentTask = NO_TASK; 
	private int currentStep = 1;	
	private boolean addImmediately = false;
	private String replaceWith = "";
	private String replaceFrom = "";
	private boolean useReplaceWith = false;
	public static boolean debug = false;	
	public static final String logoPath = "/images/owlsMX1_small_rectangle.jpg"; 
	public static final String version = "1.1b";
	
	//Sorting
	public final static int SORT_HYBRID = 0;
	public final static int SORT_SEMANTIC = 1;
	public final static int SORT_SYNTACTIC = 2;	
	//Tasks
	public final static int NO_TASK = -1;	
	public final static int QUERY_TASK = 0;
	public final static int CREATE_TC_TASK = 1;
	public final static int RUN_TEST_TASK = 2;
	public final static int OTHER_TASK = 4;
	

	private int sorting = SORT_HYBRID;
	
	public static GUIState getInstance(){
		if (instance!=null)
			return instance;
		else return new GUIState();
	}
    
	private GUIState() {
		loadWizardContent();
	}
	
	public int setCurrentStep(){
		return currentStep;
	}
	
	public void setCurrentStep(int step) {
		this.currentStep = step;
	}
	
	public int getCurrentTask(){
		return currentTask;
	}
	
	public void setCurrentTask(int task) {
		this.currentTask = task;
	}
	
	public boolean getDisplayAnswerSet() {
		return displayAnswerset;
	}
	
	public void setDisplayAnswerSet(boolean state) {
		displayAnswerset = state;
	}
	
	public boolean getDisplayAQR() {
		return getAQR;
	}
	
	public void setDisplayAQR(boolean state) {
		getAQR = state;
	}
	
	public boolean getMemoryConsumption() {
		return getMemoryConsumption;
	}
	
	public void setMemoryConsumption(boolean state) {
		getMemoryConsumption = state;
	}

	public boolean getPrecisionRecall() {
		return getPrecisionRecall;
	}
	
	public void setPrecisionRecall(boolean state) {
		getPrecisionRecall = state;
	}

	public void setMeasures(int minDegree, short simMeasure, double treshold) {
		this.minDegree = minDegree;
//		System.err.println("MinDOM:               " + this.minDegree);
		this.simMeasure = simMeasure;
//		System.err.println("SimilarityMeasure:    " + this.simMeasure);
		this.treshold = treshold;
//		System.err.println("Similiarity treshold: " + this.treshold);
	}
	
	public double getTreshold() {
		return treshold;
	}
	
	public int getMinDegree() {
		return minDegree;
	}
	
	public short getSimilarityMeasure() {
		return simMeasure;
	}
	
	public void setPathToServices(String pathToServices) {
		this.pathToServices = pathToServices;
	}

	public String getPathToServices() {
		return pathToServices;
	}

	public void setPathToQueries(String pathToQueries) {
		this.pathToQueries = pathToQueries;
	}

	public String getPathToQueries() {
		return pathToQueries;
	}

	public void setPathToTestCollection(String pathToTestCollection) {
		this.pathToTestCollection = pathToTestCollection;
	}

	public String getPathToTestCollection() {
		return pathToTestCollection;
	}
	
	public static void load(String path) {		
		try {
			ObjectInputStream s = new ObjectInputStream(new FileInputStream(path));
			GUIState state = (GUIState)s.readObject();
		} catch (FileNotFoundException e) {
			GUIState.displayWarning("TestCollection: " +e.getClass().toString(), e.getMessage());
			e.printStackTrace();
		} catch (IOException e) {
			GUIState.displayWarning("TestCollection: " +e.getClass().toString(), e.getMessage());
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			GUIState.displayWarning("TestCollection: " +e.getClass().toString(), e.getMessage());
			e.printStackTrace();
		}
	}
	
	public static void save(String path){
		try {
			ObjectOutputStream s = new ObjectOutputStream(new FileOutputStream(path));		
			s.writeObject(GUIState.getInstance());
			s.flush();
		} catch (Exception e) {
			GUIState.displayWarning("GUIState" + "|save:", e.getClass().toString() + "\n" + "Couldn't save file " + path + "\n" + e.getMessage());
			e.printStackTrace();
		}	
	}
	
	public static void load() {
		load("guistate.conf");
	}
	
	public static void save() {
		save("guistate.conf");
	}

	/**
	 * Test for the TestCollection class, including saving and loading
	 * 
	 * @param args
	 * @throws FileNotFoundException
	 * @throws IOException
	 * @throws ClassNotFoundException
	 * @throws URISyntaxException
	 */
	public static void main(String args[]) throws FileNotFoundException, IOException, ClassNotFoundException, URISyntaxException {		
		generateDummyData();		
	}
	
	/**
	 * Displays a warning message for debug purposes, iff debuging is enabled
	 * 
	 * @param headline
	 * @param message
	 */
	public static void displayWarning(String headline, String message){
			JOptionPane.showMessageDialog(null, message, headline, JOptionPane.WARNING_MESSAGE);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -