repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
begab/kpe
src/edu/stanford/nlp/pipeline/StopWordAnnotator.java
// Path: src/hu/u_szeged/utils/Stopword.java // public class Stopword implements Serializable { // // public static final long serialVersionUID = 1L; // public static Set<String> stopwords = null; // // public Stopword() { // if (stopwords != null) { // return; // } // // stopwords = new HashSet<String>(); // NLPUtils.readDocToCollection(System.getProperty("user.dir") + "/resources/stopwords/stopwords_" + SzTECoreNLP.lang + ".txt", stopwords, // Charset.forName("UTF-8")); // } // // /** // * Returns true if the given string is a stop word. // */ // public boolean isStopword(String str) { // return stopwords.contains(str.toLowerCase()); // } // // public boolean isStopword(CoreLabel ew) { // String lemma = ew.get(LemmaAnnotation.class); // if (lemma == null) { // System.err.println("No lemma for token " + ew); // } else { // lemma = lemma.toLowerCase(); // } // return isStopword(ew.word().toLowerCase()) || (lemma != null && isStopword(lemma)); // } // }
import hu.u_szeged.utils.Stopword; import java.util.Collections; import java.util.List; import java.util.Set; import edu.stanford.nlp.ling.CoreAnnotation; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.util.CoreMap; import edu.stanford.nlp.util.Timing;
package edu.stanford.nlp.pipeline; public class StopWordAnnotator implements Annotator { private Timing timer; private boolean verbose;
// Path: src/hu/u_szeged/utils/Stopword.java // public class Stopword implements Serializable { // // public static final long serialVersionUID = 1L; // public static Set<String> stopwords = null; // // public Stopword() { // if (stopwords != null) { // return; // } // // stopwords = new HashSet<String>(); // NLPUtils.readDocToCollection(System.getProperty("user.dir") + "/resources/stopwords/stopwords_" + SzTECoreNLP.lang + ".txt", stopwords, // Charset.forName("UTF-8")); // } // // /** // * Returns true if the given string is a stop word. // */ // public boolean isStopword(String str) { // return stopwords.contains(str.toLowerCase()); // } // // public boolean isStopword(CoreLabel ew) { // String lemma = ew.get(LemmaAnnotation.class); // if (lemma == null) { // System.err.println("No lemma for token " + ew); // } else { // lemma = lemma.toLowerCase(); // } // return isStopword(ew.word().toLowerCase()) || (lemma != null && isStopword(lemma)); // } // } // Path: src/edu/stanford/nlp/pipeline/StopWordAnnotator.java import hu.u_szeged.utils.Stopword; import java.util.Collections; import java.util.List; import java.util.Set; import edu.stanford.nlp.ling.CoreAnnotation; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.util.CoreMap; import edu.stanford.nlp.util.Timing; package edu.stanford.nlp.pipeline; public class StopWordAnnotator implements Annotator { private Timing timer; private boolean verbose;
public static Stopword stopWord;
begab/kpe
src/hu/u_szeged/nlp/pos/CompoundWord.java
// Path: src/hu/u_szeged/nlp/pos/KRUtils.java // public enum KRPOS { // VERB, NOUN, ADJ, NUM, ADV, PREV, ART, POSTP, UTT_INT, DET, CONJ, ONO, PREP, X; // }
import hu.u_szeged.nlp.pos.KRUtils.KRPOS; import java.util.Collection; import java.util.LinkedHashSet;
package hu.u_szeged.nlp.pos; /** * összetett szavak elemzése * * @author zsjanos * */ public class CompoundWord { public static boolean isCompatibleAnalyises(String firstPartKR, String secondPartKR) {
// Path: src/hu/u_szeged/nlp/pos/KRUtils.java // public enum KRPOS { // VERB, NOUN, ADJ, NUM, ADV, PREV, ART, POSTP, UTT_INT, DET, CONJ, ONO, PREP, X; // } // Path: src/hu/u_szeged/nlp/pos/CompoundWord.java import hu.u_szeged.nlp.pos.KRUtils.KRPOS; import java.util.Collection; import java.util.LinkedHashSet; package hu.u_szeged.nlp.pos; /** * összetett szavak elemzése * * @author zsjanos * */ public class CompoundWord { public static boolean isCompatibleAnalyises(String firstPartKR, String secondPartKR) {
KRPOS secondPartPOS = KRUtils.getPOS(secondPartKR);
begab/kpe
src/edu/stanford/nlp/pipeline/OwnMorphaAnnotator.java
// Path: src/hu/u_szeged/nlp/pos/HungarianMorphology.java // public class HungarianMorphology { // // public static String[] getPossibleTags(String word, Set<String> possibleTags) { // Set<MorAna> morAnas = null; // Set<String> res = null; // String reduced = null; // // morAnas = HunLemMor.getMorphologicalAnalyses(word); // res = new HashSet<String>(); // // for (MorAna morAna : morAnas) { // reduced = MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()); // if (possibleTags.contains(reduced)) { // res.add(reduced); // } // } // // if (res.size() == 0) { // res.add("X"); // } // // return res.toArray(new String[res.size()]); // } // // public static List<CoreLabel> recoverTags(List<CoreLabel> sentence) { // Set<MorAna> set = null; // for (CoreLabel tw : sentence) { // set = HunLemMor.getMorphologicalAnalyses(tw.word()); // int max = -1; // MorAna argmax = null; // // for (MorAna morAna : set) { // // int freq = MagyarlancResourceHolder.getFrequencies().containsKey(morAna.getMsd()) ? MagyarlancResourceHolder.getFrequencies().get(morAna.getMsd()) : 0; // // if (!morAna.getMsd().equals(null)) { // if (MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()).equals(tw.tag()) && (max < freq)) { // argmax = morAna; // max = freq; // } // } // } // // if (argmax != null) { // tw.setLemma(argmax.getLemma()); // tw.setTag(argmax.getMsd()); // } else { // tw.setLemma(tw.word()); // } // } // return sentence; // } // }
import hu.u_szeged.nlp.pos.HungarianMorphology; import java.util.List; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.util.CoreMap; import edu.stanford.nlp.util.Timing;
package edu.stanford.nlp.pipeline; public class OwnMorphaAnnotator extends MorphaAnnotator { private Timing timer = new Timing(); private boolean VERBOSE = false; private boolean isEnglish; public OwnMorphaAnnotator(boolean english) { this(false, english); } public OwnMorphaAnnotator(boolean verbose, boolean english) { super(verbose); VERBOSE = verbose; isEnglish = english; } public void annotate(Annotation annotation) { if (VERBOSE) { timer.start(); System.err.print("Finding lemma..."); } if (isEnglish) { super.annotate(annotation); } else { if (annotation.has(CoreAnnotations.SentencesAnnotation.class)) { List<CoreMap> sentences = annotation.get(SentencesAnnotation.class); for (CoreMap sentence : sentences) { List<CoreLabel> tokens = sentence.get(TokensAnnotation.class);
// Path: src/hu/u_szeged/nlp/pos/HungarianMorphology.java // public class HungarianMorphology { // // public static String[] getPossibleTags(String word, Set<String> possibleTags) { // Set<MorAna> morAnas = null; // Set<String> res = null; // String reduced = null; // // morAnas = HunLemMor.getMorphologicalAnalyses(word); // res = new HashSet<String>(); // // for (MorAna morAna : morAnas) { // reduced = MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()); // if (possibleTags.contains(reduced)) { // res.add(reduced); // } // } // // if (res.size() == 0) { // res.add("X"); // } // // return res.toArray(new String[res.size()]); // } // // public static List<CoreLabel> recoverTags(List<CoreLabel> sentence) { // Set<MorAna> set = null; // for (CoreLabel tw : sentence) { // set = HunLemMor.getMorphologicalAnalyses(tw.word()); // int max = -1; // MorAna argmax = null; // // for (MorAna morAna : set) { // // int freq = MagyarlancResourceHolder.getFrequencies().containsKey(morAna.getMsd()) ? MagyarlancResourceHolder.getFrequencies().get(morAna.getMsd()) : 0; // // if (!morAna.getMsd().equals(null)) { // if (MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()).equals(tw.tag()) && (max < freq)) { // argmax = morAna; // max = freq; // } // } // } // // if (argmax != null) { // tw.setLemma(argmax.getLemma()); // tw.setTag(argmax.getMsd()); // } else { // tw.setLemma(tw.word()); // } // } // return sentence; // } // } // Path: src/edu/stanford/nlp/pipeline/OwnMorphaAnnotator.java import hu.u_szeged.nlp.pos.HungarianMorphology; import java.util.List; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation; import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.util.CoreMap; import edu.stanford.nlp.util.Timing; package edu.stanford.nlp.pipeline; public class OwnMorphaAnnotator extends MorphaAnnotator { private Timing timer = new Timing(); private boolean VERBOSE = false; private boolean isEnglish; public OwnMorphaAnnotator(boolean english) { this(false, english); } public OwnMorphaAnnotator(boolean verbose, boolean english) { super(verbose); VERBOSE = verbose; isEnglish = english; } public void annotate(Annotation annotation) { if (VERBOSE) { timer.start(); System.err.print("Finding lemma..."); } if (isEnglish) { super.annotate(annotation); } else { if (annotation.has(CoreAnnotations.SentencesAnnotation.class)) { List<CoreMap> sentences = annotation.get(SentencesAnnotation.class); for (CoreMap sentence : sentences) { List<CoreLabel> tokens = sentence.get(TokensAnnotation.class);
HungarianMorphology.recoverTags(tokens);
begab/kpe
src/hu/u_szeged/kpe/candidates/CoreLabelComparator.java
// Path: src/edu/stanford/nlp/pipeline/NormalizerAnnotator.java // public static class NormalizerAnnotation implements CoreAnnotation<String> { // public Class<String> getType() { // return String.class; // } // }
import java.io.Serializable; import java.util.Comparator; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.pipeline.NormalizerAnnotator.NormalizerAnnotation;
package hu.u_szeged.kpe.candidates; /** * This class is responsible for the proper ordering of ExtendedWord objects, i.e. based on their normalized lemmas. */ public class CoreLabelComparator implements Comparator<CoreLabel>, Serializable { /** * */ private static final long serialVersionUID = 1L; @Override public int compare(CoreLabel labelA, CoreLabel labelB) {
// Path: src/edu/stanford/nlp/pipeline/NormalizerAnnotator.java // public static class NormalizerAnnotation implements CoreAnnotation<String> { // public Class<String> getType() { // return String.class; // } // } // Path: src/hu/u_szeged/kpe/candidates/CoreLabelComparator.java import java.io.Serializable; import java.util.Comparator; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.pipeline.NormalizerAnnotator.NormalizerAnnotation; package hu.u_szeged.kpe.candidates; /** * This class is responsible for the proper ordering of ExtendedWord objects, i.e. based on their normalized lemmas. */ public class CoreLabelComparator implements Comparator<CoreLabel>, Serializable { /** * */ private static final long serialVersionUID = 1L; @Override public int compare(CoreLabel labelA, CoreLabel labelB) {
String baseOfComparisonA = labelA.getString(NormalizerAnnotation.class);
depoll/bindroid
Bindroid/src/com/bindroid/trackable/Trackable.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // }
import java.util.LinkedList; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; import com.bindroid.utils.Action; import com.bindroid.utils.Function;
package com.bindroid.trackable; /** * Provides an object to which {@link Tracker} can subscribe for notifications as well as methods * that allow a Tracker to evaluate an {@link Action} or {@link Function} while subscribing to * notifications for any trackers used during that evaluation. * * Most uses of raw Trackables will be {@link TrackableField}s and {@link TrackableCollection}s. Raw * Trackables are primarily useful when manually wrapping the behavior of an object that uses the * Listener pattern for its notifications, calling {@link #track()} in the getter for the property * and {@link #updateTrackers()} when the Listener notifies of a change to its value. * * Trackable instances are meant to be as lightweight as possible in order to minimize their * overhead when used in large numbers of objects. */ public class Trackable { private static ThreadLocal<Stack<Tracker>> trackersInFrame = new ThreadLocal<Stack<Tracker>>() { @Override protected synchronized Stack<Tracker> initialValue() { return new Stack<Tracker>(); } }; /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * executing the given {@link Action}. {@link Tracker#update()} will be called at most once for * all Trackables tracked while executing the action. * * @param tracker * The tracker to subscribe. * @param action * The action to run. */
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // Path: Bindroid/src/com/bindroid/trackable/Trackable.java import java.util.LinkedList; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; import com.bindroid.utils.Action; import com.bindroid.utils.Function; package com.bindroid.trackable; /** * Provides an object to which {@link Tracker} can subscribe for notifications as well as methods * that allow a Tracker to evaluate an {@link Action} or {@link Function} while subscribing to * notifications for any trackers used during that evaluation. * * Most uses of raw Trackables will be {@link TrackableField}s and {@link TrackableCollection}s. Raw * Trackables are primarily useful when manually wrapping the behavior of an object that uses the * Listener pattern for its notifications, calling {@link #track()} in the getter for the property * and {@link #updateTrackers()} when the Listener notifies of a change to its value. * * Trackable instances are meant to be as lightweight as possible in order to minimize their * overhead when used in large numbers of objects. */ public class Trackable { private static ThreadLocal<Stack<Tracker>> trackersInFrame = new ThreadLocal<Stack<Tracker>>() { @Override protected synchronized Stack<Tracker> initialValue() { return new Stack<Tracker>(); } }; /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * executing the given {@link Action}. {@link Tracker#update()} will be called at most once for * all Trackables tracked while executing the action. * * @param tracker * The tracker to subscribe. * @param action * The action to run. */
public static void track(Tracker tracker, Action<Void> action) {
depoll/bindroid
Bindroid/src/com/bindroid/trackable/Trackable.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // }
import java.util.LinkedList; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; import com.bindroid.utils.Action; import com.bindroid.utils.Function;
package com.bindroid.trackable; /** * Provides an object to which {@link Tracker} can subscribe for notifications as well as methods * that allow a Tracker to evaluate an {@link Action} or {@link Function} while subscribing to * notifications for any trackers used during that evaluation. * * Most uses of raw Trackables will be {@link TrackableField}s and {@link TrackableCollection}s. Raw * Trackables are primarily useful when manually wrapping the behavior of an object that uses the * Listener pattern for its notifications, calling {@link #track()} in the getter for the property * and {@link #updateTrackers()} when the Listener notifies of a change to its value. * * Trackable instances are meant to be as lightweight as possible in order to minimize their * overhead when used in large numbers of objects. */ public class Trackable { private static ThreadLocal<Stack<Tracker>> trackersInFrame = new ThreadLocal<Stack<Tracker>>() { @Override protected synchronized Stack<Tracker> initialValue() { return new Stack<Tracker>(); } }; /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * executing the given {@link Action}. {@link Tracker#update()} will be called at most once for * all Trackables tracked while executing the action. * * @param tracker * The tracker to subscribe. * @param action * The action to run. */ public static void track(Tracker tracker, Action<Void> action) { Trackable.trackersInFrame.get().push(wrapTracker(tracker)); try { action.invoke(null); } finally { Trackable.trackersInFrame.get().pop(); } } /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * evaluating the given {@link Function}. The result of the function is returned. * {@link Tracker#update()} will be called at most once for all Trackables tracked while * evaluating the function. * * @param tracker * The tracker to subscribe. * @param function * The function to evaluate. * @return The result of the function. */
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // Path: Bindroid/src/com/bindroid/trackable/Trackable.java import java.util.LinkedList; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; import com.bindroid.utils.Action; import com.bindroid.utils.Function; package com.bindroid.trackable; /** * Provides an object to which {@link Tracker} can subscribe for notifications as well as methods * that allow a Tracker to evaluate an {@link Action} or {@link Function} while subscribing to * notifications for any trackers used during that evaluation. * * Most uses of raw Trackables will be {@link TrackableField}s and {@link TrackableCollection}s. Raw * Trackables are primarily useful when manually wrapping the behavior of an object that uses the * Listener pattern for its notifications, calling {@link #track()} in the getter for the property * and {@link #updateTrackers()} when the Listener notifies of a change to its value. * * Trackable instances are meant to be as lightweight as possible in order to minimize their * overhead when used in large numbers of objects. */ public class Trackable { private static ThreadLocal<Stack<Tracker>> trackersInFrame = new ThreadLocal<Stack<Tracker>>() { @Override protected synchronized Stack<Tracker> initialValue() { return new Stack<Tracker>(); } }; /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * executing the given {@link Action}. {@link Tracker#update()} will be called at most once for * all Trackables tracked while executing the action. * * @param tracker * The tracker to subscribe. * @param action * The action to run. */ public static void track(Tracker tracker, Action<Void> action) { Trackable.trackersInFrame.get().push(wrapTracker(tracker)); try { action.invoke(null); } finally { Trackable.trackersInFrame.get().pop(); } } /** * Causes a {@link Tracker} to track any Trackables on which {@link #track()} was called while * evaluating the given {@link Function}. The result of the function is returned. * {@link Tracker#update()} will be called at most once for all Trackables tracked while * evaluating the function. * * @param tracker * The tracker to subscribe. * @param function * The function to evaluate. * @return The result of the function. */
public static <T> T track(Tracker tracker, Function<T> function) {
depoll/bindroid
Bindroid/src/com/bindroid/ui/UiProperty.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // // Path: Bindroid/src/com/bindroid/utils/Property.java // public class Property<T> { // protected Action<T> setter; // // protected Function<T> getter; // // protected Class<?> propertyType; // // protected Property() { // } // // /** // * Creates a property from a getter and setter. The type will be assumed to be {@link Object}. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // */ // public Property(Function<T> getter, Action<T> setter) { // this(getter, setter, Object.class); // } // // /** // * Creates a property from a getter and setter. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // * @param type // * the type of the property. // */ // public Property(Function<T> getter, Action<T> setter, Class<?> type) { // this.getter = getter; // this.setter = setter; // this.propertyType = type; // } // // /** // * @return the getter for the property. // */ // public Function<T> getGetter() { // return this.getter; // } // // /** // * @return the setter for the property. // */ // public Action<T> getSetter() { // return this.setter; // } // // /** // * @return the type of the property. // */ // public Class<?> getType() { // return this.propertyType; // } // // /** // * Invokes the getter. // * // * @return the value returned by the getter. // */ // public final T getValue() { // return this.getter.evaluate(); // } // // /** // * Invokes the setter with the given value. // * // * @param value // * the value to pass to the setter. // */ // public final void setValue(T value) { // this.setter.invoke(value); // } // }
import java.util.concurrent.atomic.AtomicReference; import android.os.Handler; import android.os.Looper; import com.bindroid.utils.Action; import com.bindroid.utils.Function; import com.bindroid.utils.Property;
package com.bindroid.ui; /** * A property that wraps another property, delegating calls to the UI thread. */ public class UiProperty<T> extends Property<T> { private Property<T> property; private static final Handler UI_THREAD_HANDLER = new Handler(Looper.getMainLooper()); /** * Creates a UIProperty for the given property. * * @param property * the property to wrap. * @return the new property, whose getters and setters will dispatch to the UI thread. */ public static <T> UiProperty<T> make(Property<T> property) { return new UiProperty<T>(property); } private UiProperty(Property<T> property) { this.property = property; if (property.getGetter() != null) {
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // // Path: Bindroid/src/com/bindroid/utils/Property.java // public class Property<T> { // protected Action<T> setter; // // protected Function<T> getter; // // protected Class<?> propertyType; // // protected Property() { // } // // /** // * Creates a property from a getter and setter. The type will be assumed to be {@link Object}. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // */ // public Property(Function<T> getter, Action<T> setter) { // this(getter, setter, Object.class); // } // // /** // * Creates a property from a getter and setter. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // * @param type // * the type of the property. // */ // public Property(Function<T> getter, Action<T> setter, Class<?> type) { // this.getter = getter; // this.setter = setter; // this.propertyType = type; // } // // /** // * @return the getter for the property. // */ // public Function<T> getGetter() { // return this.getter; // } // // /** // * @return the setter for the property. // */ // public Action<T> getSetter() { // return this.setter; // } // // /** // * @return the type of the property. // */ // public Class<?> getType() { // return this.propertyType; // } // // /** // * Invokes the getter. // * // * @return the value returned by the getter. // */ // public final T getValue() { // return this.getter.evaluate(); // } // // /** // * Invokes the setter with the given value. // * // * @param value // * the value to pass to the setter. // */ // public final void setValue(T value) { // this.setter.invoke(value); // } // } // Path: Bindroid/src/com/bindroid/ui/UiProperty.java import java.util.concurrent.atomic.AtomicReference; import android.os.Handler; import android.os.Looper; import com.bindroid.utils.Action; import com.bindroid.utils.Function; import com.bindroid.utils.Property; package com.bindroid.ui; /** * A property that wraps another property, delegating calls to the UI thread. */ public class UiProperty<T> extends Property<T> { private Property<T> property; private static final Handler UI_THREAD_HANDLER = new Handler(Looper.getMainLooper()); /** * Creates a UIProperty for the given property. * * @param property * the property to wrap. * @return the new property, whose getters and setters will dispatch to the UI thread. */ public static <T> UiProperty<T> make(Property<T> property) { return new UiProperty<T>(property); } private UiProperty(Property<T> property) { this.property = property; if (property.getGetter() != null) {
this.getter = new Function<T>() {
depoll/bindroid
Bindroid/src/com/bindroid/ui/UiProperty.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // // Path: Bindroid/src/com/bindroid/utils/Property.java // public class Property<T> { // protected Action<T> setter; // // protected Function<T> getter; // // protected Class<?> propertyType; // // protected Property() { // } // // /** // * Creates a property from a getter and setter. The type will be assumed to be {@link Object}. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // */ // public Property(Function<T> getter, Action<T> setter) { // this(getter, setter, Object.class); // } // // /** // * Creates a property from a getter and setter. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // * @param type // * the type of the property. // */ // public Property(Function<T> getter, Action<T> setter, Class<?> type) { // this.getter = getter; // this.setter = setter; // this.propertyType = type; // } // // /** // * @return the getter for the property. // */ // public Function<T> getGetter() { // return this.getter; // } // // /** // * @return the setter for the property. // */ // public Action<T> getSetter() { // return this.setter; // } // // /** // * @return the type of the property. // */ // public Class<?> getType() { // return this.propertyType; // } // // /** // * Invokes the getter. // * // * @return the value returned by the getter. // */ // public final T getValue() { // return this.getter.evaluate(); // } // // /** // * Invokes the setter with the given value. // * // * @param value // * the value to pass to the setter. // */ // public final void setValue(T value) { // this.setter.invoke(value); // } // }
import java.util.concurrent.atomic.AtomicReference; import android.os.Handler; import android.os.Looper; import com.bindroid.utils.Action; import com.bindroid.utils.Function; import com.bindroid.utils.Property;
this.property = property; if (property.getGetter() != null) { this.getter = new Function<T>() { @Override public T evaluate() { if (Looper.myLooper() == Looper.getMainLooper()) { return UiProperty.this.property.getValue(); } final AtomicReference<T> ref = new AtomicReference<T>(); synchronized (ref) { UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { synchronized (ref) { ref.set(UiProperty.this.property.getValue()); ref.notify(); } } }); try { ref.wait(); return ref.get(); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }; } if (property.getSetter() != null) {
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/Function.java // public interface Function<T> { // /** // * The function to evaluate. // * // * @return the result of the evaluation. // */ // T evaluate(); // } // // Path: Bindroid/src/com/bindroid/utils/Property.java // public class Property<T> { // protected Action<T> setter; // // protected Function<T> getter; // // protected Class<?> propertyType; // // protected Property() { // } // // /** // * Creates a property from a getter and setter. The type will be assumed to be {@link Object}. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // */ // public Property(Function<T> getter, Action<T> setter) { // this(getter, setter, Object.class); // } // // /** // * Creates a property from a getter and setter. // * // * @param getter // * the getter for the property. // * @param setter // * the setter for the property. // * @param type // * the type of the property. // */ // public Property(Function<T> getter, Action<T> setter, Class<?> type) { // this.getter = getter; // this.setter = setter; // this.propertyType = type; // } // // /** // * @return the getter for the property. // */ // public Function<T> getGetter() { // return this.getter; // } // // /** // * @return the setter for the property. // */ // public Action<T> getSetter() { // return this.setter; // } // // /** // * @return the type of the property. // */ // public Class<?> getType() { // return this.propertyType; // } // // /** // * Invokes the getter. // * // * @return the value returned by the getter. // */ // public final T getValue() { // return this.getter.evaluate(); // } // // /** // * Invokes the setter with the given value. // * // * @param value // * the value to pass to the setter. // */ // public final void setValue(T value) { // this.setter.invoke(value); // } // } // Path: Bindroid/src/com/bindroid/ui/UiProperty.java import java.util.concurrent.atomic.AtomicReference; import android.os.Handler; import android.os.Looper; import com.bindroid.utils.Action; import com.bindroid.utils.Function; import com.bindroid.utils.Property; this.property = property; if (property.getGetter() != null) { this.getter = new Function<T>() { @Override public T evaluate() { if (Looper.myLooper() == Looper.getMainLooper()) { return UiProperty.this.property.getValue(); } final AtomicReference<T> ref = new AtomicReference<T>(); synchronized (ref) { UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { synchronized (ref) { ref.set(UiProperty.this.property.getValue()); ref.notify(); } } }); try { ref.wait(); return ref.get(); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }; } if (property.getSetter() != null) {
this.setter = new Action<T>() {
depoll/bindroid
Bindroid/src/com/bindroid/trackable/TrackableField.java
// Path: Bindroid/src/com/bindroid/utils/EqualityComparer.java // public interface EqualityComparer<T> { // boolean equals(T obj1, T obj2); // } // // Path: Bindroid/src/com/bindroid/utils/ObjectUtilities.java // public class ObjectUtilities { // private static EqualityComparer<Object> defaultComparer; // // static { // ObjectUtilities.defaultComparer = new EqualityComparer<Object>() { // @Override // public boolean equals(Object obj1, Object obj2) { // return ObjectUtilities.equals(obj1, obj2); // } // }; // } // // /** // * Safely compares two objects for equality, even if the objects are null. // * // * @param obj1 // * an object to check for equality. // * @param obj2 // * an object to check for equality. // * @return whether the objects are equal. // */ // public static boolean equals(Object obj1, Object obj2) { // try { // return obj1 == obj2 || (obj1 != null && obj1.equals(obj2)); // } catch (Exception e) { // return false; // } // } // // /** // * Gets the default equality comparer. // * // * @return the default equality comparer. // */ // @SuppressWarnings("unchecked") // public static <T> EqualityComparer<T> getDefaultComparer() { // return (EqualityComparer<T>) ObjectUtilities.defaultComparer; // } // // private ObjectUtilities() { // } // }
import com.bindroid.utils.EqualityComparer; import com.bindroid.utils.ObjectUtilities;
package com.bindroid.trackable; /** * Implements a {@link Trackable} that stores a value. A TrackableField calls {@link #track()} when * {@link #get()} is called and {@link #updateTrackers()} when {@link #set(Object)} is called and * its value has changed. As a result, TrackableFields are ideal for implementing properties -- most * of the time, getters and setters can simply delegate directly to the TrackableField, and the * TrackableField replaces the field that would otherwise have been private on the object. * TrackableFields are rarely exposed as a part of a public API. * * TrackableFields are meant to be as lightweight as possible in order to avoid overhead when using * them for all of the fields of an object. For this reason, if you wish to specify a custom * {@link EqualityComparer}, you should use a {@link ComparingTrackableField}, which has the extra * field (and thus extra overhead) to store the comparer. * * @param <T> * The type of the field. */ public class TrackableField<T> extends Trackable { protected T value;
// Path: Bindroid/src/com/bindroid/utils/EqualityComparer.java // public interface EqualityComparer<T> { // boolean equals(T obj1, T obj2); // } // // Path: Bindroid/src/com/bindroid/utils/ObjectUtilities.java // public class ObjectUtilities { // private static EqualityComparer<Object> defaultComparer; // // static { // ObjectUtilities.defaultComparer = new EqualityComparer<Object>() { // @Override // public boolean equals(Object obj1, Object obj2) { // return ObjectUtilities.equals(obj1, obj2); // } // }; // } // // /** // * Safely compares two objects for equality, even if the objects are null. // * // * @param obj1 // * an object to check for equality. // * @param obj2 // * an object to check for equality. // * @return whether the objects are equal. // */ // public static boolean equals(Object obj1, Object obj2) { // try { // return obj1 == obj2 || (obj1 != null && obj1.equals(obj2)); // } catch (Exception e) { // return false; // } // } // // /** // * Gets the default equality comparer. // * // * @return the default equality comparer. // */ // @SuppressWarnings("unchecked") // public static <T> EqualityComparer<T> getDefaultComparer() { // return (EqualityComparer<T>) ObjectUtilities.defaultComparer; // } // // private ObjectUtilities() { // } // } // Path: Bindroid/src/com/bindroid/trackable/TrackableField.java import com.bindroid.utils.EqualityComparer; import com.bindroid.utils.ObjectUtilities; package com.bindroid.trackable; /** * Implements a {@link Trackable} that stores a value. A TrackableField calls {@link #track()} when * {@link #get()} is called and {@link #updateTrackers()} when {@link #set(Object)} is called and * its value has changed. As a result, TrackableFields are ideal for implementing properties -- most * of the time, getters and setters can simply delegate directly to the TrackableField, and the * TrackableField replaces the field that would otherwise have been private on the object. * TrackableFields are rarely exposed as a part of a public API. * * TrackableFields are meant to be as lightweight as possible in order to avoid overhead when using * them for all of the fields of an object. For this reason, if you wish to specify a custom * {@link EqualityComparer}, you should use a {@link ComparingTrackableField}, which has the extra * field (and thus extra overhead) to store the comparer. * * @param <T> * The type of the field. */ public class TrackableField<T> extends Trackable { protected T value;
private static EqualityComparer<Object> comparer;
depoll/bindroid
Bindroid/src/com/bindroid/trackable/TrackableField.java
// Path: Bindroid/src/com/bindroid/utils/EqualityComparer.java // public interface EqualityComparer<T> { // boolean equals(T obj1, T obj2); // } // // Path: Bindroid/src/com/bindroid/utils/ObjectUtilities.java // public class ObjectUtilities { // private static EqualityComparer<Object> defaultComparer; // // static { // ObjectUtilities.defaultComparer = new EqualityComparer<Object>() { // @Override // public boolean equals(Object obj1, Object obj2) { // return ObjectUtilities.equals(obj1, obj2); // } // }; // } // // /** // * Safely compares two objects for equality, even if the objects are null. // * // * @param obj1 // * an object to check for equality. // * @param obj2 // * an object to check for equality. // * @return whether the objects are equal. // */ // public static boolean equals(Object obj1, Object obj2) { // try { // return obj1 == obj2 || (obj1 != null && obj1.equals(obj2)); // } catch (Exception e) { // return false; // } // } // // /** // * Gets the default equality comparer. // * // * @return the default equality comparer. // */ // @SuppressWarnings("unchecked") // public static <T> EqualityComparer<T> getDefaultComparer() { // return (EqualityComparer<T>) ObjectUtilities.defaultComparer; // } // // private ObjectUtilities() { // } // }
import com.bindroid.utils.EqualityComparer; import com.bindroid.utils.ObjectUtilities;
package com.bindroid.trackable; /** * Implements a {@link Trackable} that stores a value. A TrackableField calls {@link #track()} when * {@link #get()} is called and {@link #updateTrackers()} when {@link #set(Object)} is called and * its value has changed. As a result, TrackableFields are ideal for implementing properties -- most * of the time, getters and setters can simply delegate directly to the TrackableField, and the * TrackableField replaces the field that would otherwise have been private on the object. * TrackableFields are rarely exposed as a part of a public API. * * TrackableFields are meant to be as lightweight as possible in order to avoid overhead when using * them for all of the fields of an object. For this reason, if you wish to specify a custom * {@link EqualityComparer}, you should use a {@link ComparingTrackableField}, which has the extra * field (and thus extra overhead) to store the comparer. * * @param <T> * The type of the field. */ public class TrackableField<T> extends Trackable { protected T value; private static EqualityComparer<Object> comparer; static {
// Path: Bindroid/src/com/bindroid/utils/EqualityComparer.java // public interface EqualityComparer<T> { // boolean equals(T obj1, T obj2); // } // // Path: Bindroid/src/com/bindroid/utils/ObjectUtilities.java // public class ObjectUtilities { // private static EqualityComparer<Object> defaultComparer; // // static { // ObjectUtilities.defaultComparer = new EqualityComparer<Object>() { // @Override // public boolean equals(Object obj1, Object obj2) { // return ObjectUtilities.equals(obj1, obj2); // } // }; // } // // /** // * Safely compares two objects for equality, even if the objects are null. // * // * @param obj1 // * an object to check for equality. // * @param obj2 // * an object to check for equality. // * @return whether the objects are equal. // */ // public static boolean equals(Object obj1, Object obj2) { // try { // return obj1 == obj2 || (obj1 != null && obj1.equals(obj2)); // } catch (Exception e) { // return false; // } // } // // /** // * Gets the default equality comparer. // * // * @return the default equality comparer. // */ // @SuppressWarnings("unchecked") // public static <T> EqualityComparer<T> getDefaultComparer() { // return (EqualityComparer<T>) ObjectUtilities.defaultComparer; // } // // private ObjectUtilities() { // } // } // Path: Bindroid/src/com/bindroid/trackable/TrackableField.java import com.bindroid.utils.EqualityComparer; import com.bindroid.utils.ObjectUtilities; package com.bindroid.trackable; /** * Implements a {@link Trackable} that stores a value. A TrackableField calls {@link #track()} when * {@link #get()} is called and {@link #updateTrackers()} when {@link #set(Object)} is called and * its value has changed. As a result, TrackableFields are ideal for implementing properties -- most * of the time, getters and setters can simply delegate directly to the TrackableField, and the * TrackableField replaces the field that would otherwise have been private on the object. * TrackableFields are rarely exposed as a part of a public API. * * TrackableFields are meant to be as lightweight as possible in order to avoid overhead when using * them for all of the fields of an object. For this reason, if you wish to specify a custom * {@link EqualityComparer}, you should use a {@link ComparingTrackableField}, which has the extra * field (and thus extra overhead) to store the comparer. * * @param <T> * The type of the field. */ public class TrackableField<T> extends Trackable { protected T value; private static EqualityComparer<Object> comparer; static {
TrackableField.comparer = ObjectUtilities.getDefaultComparer();
depoll/bindroid
BindroidTest/src/com/bindroid/test/GarbageCollectionListenerTest.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/GarbageCollectionListener.java // public final class GarbageCollectionListener { // private static List<Action<Void>> listeners; // // static { // GarbageCollectionListener.listeners = new LinkedList<Action<Void>>(); // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // // /** // * Adds a listener for garbage collections. // * // * @param action the method to call whenever a garbage collection is detected. // */ // public static synchronized void addListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.add(action); // } // } // // private static synchronized void notifyListeners() { // synchronized (listeners) { // for (Action<Void> l : new LinkedList<Action<Void>>(GarbageCollectionListener.listeners)) { // try { // l.invoke(null); // } catch (Exception e) { // } // } // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // } // // /** // * Removes a listener for garbage collections. // * // * @param action the action to remove. // */ // public static synchronized void removeListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.remove(action); // } // } // // private GarbageCollectionListener() { // } // // @Override // protected void finalize() throws Throwable { // GarbageCollectionListener.notifyListeners(); // super.finalize(); // } // }
import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.TestCase; import com.bindroid.utils.Action; import com.bindroid.utils.GarbageCollectionListener;
package com.bindroid.test; public class GarbageCollectionListenerTest extends TestCase { public void testNotification() throws Exception { final Object lock = new Object(); final AtomicBoolean bool = new AtomicBoolean(false); synchronized (lock) {
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/GarbageCollectionListener.java // public final class GarbageCollectionListener { // private static List<Action<Void>> listeners; // // static { // GarbageCollectionListener.listeners = new LinkedList<Action<Void>>(); // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // // /** // * Adds a listener for garbage collections. // * // * @param action the method to call whenever a garbage collection is detected. // */ // public static synchronized void addListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.add(action); // } // } // // private static synchronized void notifyListeners() { // synchronized (listeners) { // for (Action<Void> l : new LinkedList<Action<Void>>(GarbageCollectionListener.listeners)) { // try { // l.invoke(null); // } catch (Exception e) { // } // } // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // } // // /** // * Removes a listener for garbage collections. // * // * @param action the action to remove. // */ // public static synchronized void removeListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.remove(action); // } // } // // private GarbageCollectionListener() { // } // // @Override // protected void finalize() throws Throwable { // GarbageCollectionListener.notifyListeners(); // super.finalize(); // } // } // Path: BindroidTest/src/com/bindroid/test/GarbageCollectionListenerTest.java import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.TestCase; import com.bindroid.utils.Action; import com.bindroid.utils.GarbageCollectionListener; package com.bindroid.test; public class GarbageCollectionListenerTest extends TestCase { public void testNotification() throws Exception { final Object lock = new Object(); final AtomicBoolean bool = new AtomicBoolean(false); synchronized (lock) {
GarbageCollectionListener.addListener(new Action<Void>() {
depoll/bindroid
BindroidTest/src/com/bindroid/test/GarbageCollectionListenerTest.java
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/GarbageCollectionListener.java // public final class GarbageCollectionListener { // private static List<Action<Void>> listeners; // // static { // GarbageCollectionListener.listeners = new LinkedList<Action<Void>>(); // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // // /** // * Adds a listener for garbage collections. // * // * @param action the method to call whenever a garbage collection is detected. // */ // public static synchronized void addListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.add(action); // } // } // // private static synchronized void notifyListeners() { // synchronized (listeners) { // for (Action<Void> l : new LinkedList<Action<Void>>(GarbageCollectionListener.listeners)) { // try { // l.invoke(null); // } catch (Exception e) { // } // } // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // } // // /** // * Removes a listener for garbage collections. // * // * @param action the action to remove. // */ // public static synchronized void removeListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.remove(action); // } // } // // private GarbageCollectionListener() { // } // // @Override // protected void finalize() throws Throwable { // GarbageCollectionListener.notifyListeners(); // super.finalize(); // } // }
import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.TestCase; import com.bindroid.utils.Action; import com.bindroid.utils.GarbageCollectionListener;
package com.bindroid.test; public class GarbageCollectionListenerTest extends TestCase { public void testNotification() throws Exception { final Object lock = new Object(); final AtomicBoolean bool = new AtomicBoolean(false); synchronized (lock) {
// Path: Bindroid/src/com/bindroid/utils/Action.java // public interface Action<T> { // /** // * The method to invoke. // * // * @param parameter // * the parameter to the action. // */ // void invoke(T parameter); // } // // Path: Bindroid/src/com/bindroid/utils/GarbageCollectionListener.java // public final class GarbageCollectionListener { // private static List<Action<Void>> listeners; // // static { // GarbageCollectionListener.listeners = new LinkedList<Action<Void>>(); // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // // /** // * Adds a listener for garbage collections. // * // * @param action the method to call whenever a garbage collection is detected. // */ // public static synchronized void addListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.add(action); // } // } // // private static synchronized void notifyListeners() { // synchronized (listeners) { // for (Action<Void> l : new LinkedList<Action<Void>>(GarbageCollectionListener.listeners)) { // try { // l.invoke(null); // } catch (Exception e) { // } // } // new WeakReference<GarbageCollectionListener>(new GarbageCollectionListener()); // } // } // // /** // * Removes a listener for garbage collections. // * // * @param action the action to remove. // */ // public static synchronized void removeListener(Action<Void> action) { // synchronized (listeners) { // GarbageCollectionListener.listeners.remove(action); // } // } // // private GarbageCollectionListener() { // } // // @Override // protected void finalize() throws Throwable { // GarbageCollectionListener.notifyListeners(); // super.finalize(); // } // } // Path: BindroidTest/src/com/bindroid/test/GarbageCollectionListenerTest.java import java.util.concurrent.atomic.AtomicBoolean; import junit.framework.TestCase; import com.bindroid.utils.Action; import com.bindroid.utils.GarbageCollectionListener; package com.bindroid.test; public class GarbageCollectionListenerTest extends TestCase { public void testNotification() throws Exception { final Object lock = new Object(); final AtomicBoolean bool = new AtomicBoolean(false); synchronized (lock) {
GarbageCollectionListener.addListener(new Action<Void>() {
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/Message.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/Message.java import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){
this.idx = getStringFromData("idx", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/Message.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.text = getStringFromData("text", data); this.resource = getStringFromData("resource", data); this.senderId = getStringFromData("senderId", data); this.senderName = getStringFromData("senderName", data); this.senderPhoto = getStringFromData("senderPhoto", data);
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/Message.java import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.text = getStringFromData("text", data); this.resource = getStringFromData("resource", data); this.senderId = getStringFromData("senderId", data); this.senderName = getStringFromData("senderName", data); this.senderPhoto = getStringFromData("senderPhoto", data);
this.chatType = ChatType.values()[getIntFromData("chatType", data)];
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/Message.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.text = getStringFromData("text", data); this.resource = getStringFromData("resource", data); this.senderId = getStringFromData("senderId", data); this.senderName = getStringFromData("senderName", data); this.senderPhoto = getStringFromData("senderPhoto", data); this.chatType = ChatType.values()[getIntFromData("chatType", data)]; this.messageType = MessageType.values()[getIntFromData("messageType", data)]; this.status = MessageStatus.values()[getIntFromData("status", data)]; if (this.uid != null && this.senderId != null) this.userType = senderId.equals(this.uid) ? SELF : OTHER;
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/Message.java import android.net.Uri; import java.io.File; import java.util.Date; import java.util.Map; import static com.raffler.app.models.ChatType.PERSONAL; import static com.raffler.app.models.MessageStatus.SENDING; import static com.raffler.app.models.MessageType.TEXT; import static com.raffler.app.models.UserType.OTHER; import static com.raffler.app.models.UserType.SELF; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 16/8/2017. */ public class Message { private String idx, uid, text, resource; private ChatType chatType = PERSONAL; private MessageType messageType = TEXT; private MessageStatus status = SENDING; private UserType userType = SELF; private String senderId, senderName, senderPhoto; private Date createdAt, updatedAt; private Uri attachFilePath; public Message(String userId, Map<String, Object> data){ this.uid = userId; this.updateValue(data); } public void updateValue(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.text = getStringFromData("text", data); this.resource = getStringFromData("resource", data); this.senderId = getStringFromData("senderId", data); this.senderName = getStringFromData("senderName", data); this.senderPhoto = getStringFromData("senderPhoto", data); this.chatType = ChatType.values()[getIntFromData("chatType", data)]; this.messageType = MessageType.values()[getIntFromData("messageType", data)]; this.status = MessageStatus.values()[getIntFromData("status", data)]; if (this.uid != null && this.senderId != null) this.userType = senderId.equals(this.uid) ? SELF : OTHER;
this.createdAt = getDateFromData("createdAt", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/News.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/News.java import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){
this.idx = getStringFromData("idx", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/News.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data);
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/News.java import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data);
this.type = NewsType.values()[getIntFromData("newsType", data)];
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/News.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data); this.type = NewsType.values()[getIntFromData("newsType", data)];
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/News.java import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data); this.type = NewsType.values()[getIntFromData("newsType", data)];
this.isRead = getBooleanFromData("isRead", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/News.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data); this.type = NewsType.values()[getIntFromData("newsType", data)]; this.isRead = getBooleanFromData("isRead", data);
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static boolean getBooleanFromData(String key, Map<String, Object> data){ // boolean value = false; // try{ // value = (boolean) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/News.java import java.util.Date; import java.util.Map; import static com.raffler.app.models.NewsType.LOSER; import static com.raffler.app.utils.Util.getBooleanFromData; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 9/14/2017. */ public class News { private String idx; private String title, content, relatedId; private NewsType type = LOSER; private boolean isRead = false; private Date createdAt, updatedAt; public News(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("idx", data); this.title = getStringFromData("title", data); this.content = getStringFromData("content", data); this.relatedId = getStringFromData("raffleId", data); this.type = NewsType.values()[getIntFromData("newsType", data)]; this.isRead = getBooleanFromData("isRead", data);
this.createdAt = getDateFromData("createdAt", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/fragments/BaseFragment.java
// Path: app/src/main/java/com/raffler/app/utils/References.java // public class References { // private static References instance; // private final User user; // private final Chat chat; // private FirebaseDatabase database; // private Context context; // public FirebaseAnalytics analytics; // // public DatabaseReference usersRef, contactsRef, chatsRef, messagesRef, rafflesRef, prizesRef; // public DatabaseReference holdersRef, newsRef, versionRef, phonesRef, contactListRef; // // public static void init(Context context, FirebaseDatabase database) { // instance = new References(context, database); // } // // public static References getInstance() { // return instance; // } // // private References(Context context, FirebaseDatabase database) { // this.context = context; // this.database = database; // // user = new User(); // chat = new Chat(); // // usersRef = database.getReference(Constant.USER); // contactsRef = database.getReference(Constant.CONTACTS); // chatsRef = database.getReference(Constant.CHAT); // messagesRef = database.getReference(Constant.MESSAGES); // rafflesRef = database.getReference(Constant.RAFFLES); // prizesRef = database.getReference(Constant.PRIZES); // holdersRef = database.getReference(Constant.Holders); // newsRef = database.getReference(Constant.NEWS); // versionRef = database.getReference(Constant.VERSION); // phonesRef = database.getReference(Constant.PHONES); // contactListRef = database.getReference(Constant.CONTACT_LIST); // analytics = FirebaseAnalytics.getInstance(context); // } // // public User getUser() { // return user; // } // // public Chat getChat() { // return chat; // } // // public class User { // DatabaseReference reference = database.getReference(Constant.USER); // public DatabaseReference getReference() { // return reference; // } // // public DatabaseReference getReference(String key) { // return reference.child(key); // } // // public DatabaseReference information(String serial) { // return getReference(serial) // .child(Constant.INFORMATION); // } // // public DatabaseReference message(String serial) { // return getReference(serial) // .child(Constant.MESSAGES); // } // // public DatabaseReference status(String serial) { // return getReference(serial) // .child(Constant.STATUS); // } // // public DatabaseReference notification(String serial) { // return getReference(serial).child(Constant.NOTIFICATION); // } // } // // public class Chat { // DatabaseReference reference = database.getReference(Constant.CHAT); // // public DatabaseReference getReference() { // return reference; // } // public DatabaseReference getReference(String key) { // return reference.child(key); // } // // public DatabaseReference message(String key) { // return getReference(key).child(Constant.MESSAGES); // } // // public DatabaseReference meta(String key) { // return getReference(key).child(Constant.META); // } // } // // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import com.google.firebase.auth.FirebaseAuth; import com.raffler.app.utils.References;
package com.raffler.app.fragments; public class BaseFragment extends Fragment { protected FirebaseAuth auth;
// Path: app/src/main/java/com/raffler/app/utils/References.java // public class References { // private static References instance; // private final User user; // private final Chat chat; // private FirebaseDatabase database; // private Context context; // public FirebaseAnalytics analytics; // // public DatabaseReference usersRef, contactsRef, chatsRef, messagesRef, rafflesRef, prizesRef; // public DatabaseReference holdersRef, newsRef, versionRef, phonesRef, contactListRef; // // public static void init(Context context, FirebaseDatabase database) { // instance = new References(context, database); // } // // public static References getInstance() { // return instance; // } // // private References(Context context, FirebaseDatabase database) { // this.context = context; // this.database = database; // // user = new User(); // chat = new Chat(); // // usersRef = database.getReference(Constant.USER); // contactsRef = database.getReference(Constant.CONTACTS); // chatsRef = database.getReference(Constant.CHAT); // messagesRef = database.getReference(Constant.MESSAGES); // rafflesRef = database.getReference(Constant.RAFFLES); // prizesRef = database.getReference(Constant.PRIZES); // holdersRef = database.getReference(Constant.Holders); // newsRef = database.getReference(Constant.NEWS); // versionRef = database.getReference(Constant.VERSION); // phonesRef = database.getReference(Constant.PHONES); // contactListRef = database.getReference(Constant.CONTACT_LIST); // analytics = FirebaseAnalytics.getInstance(context); // } // // public User getUser() { // return user; // } // // public Chat getChat() { // return chat; // } // // public class User { // DatabaseReference reference = database.getReference(Constant.USER); // public DatabaseReference getReference() { // return reference; // } // // public DatabaseReference getReference(String key) { // return reference.child(key); // } // // public DatabaseReference information(String serial) { // return getReference(serial) // .child(Constant.INFORMATION); // } // // public DatabaseReference message(String serial) { // return getReference(serial) // .child(Constant.MESSAGES); // } // // public DatabaseReference status(String serial) { // return getReference(serial) // .child(Constant.STATUS); // } // // public DatabaseReference notification(String serial) { // return getReference(serial).child(Constant.NOTIFICATION); // } // } // // public class Chat { // DatabaseReference reference = database.getReference(Constant.CHAT); // // public DatabaseReference getReference() { // return reference; // } // public DatabaseReference getReference(String key) { // return reference.child(key); // } // // public DatabaseReference message(String key) { // return getReference(key).child(Constant.MESSAGES); // } // // public DatabaseReference meta(String key) { // return getReference(key).child(Constant.META); // } // } // // } // Path: app/src/main/java/com/raffler/app/fragments/BaseFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import com.google.firebase.auth.FirebaseAuth; import com.raffler.app.utils.References; package com.raffler.app.fragments; public class BaseFragment extends Fragment { protected FirebaseAuth auth;
protected References ref;
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/User.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/User.java import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){
this.idx = getStringFromData("uid", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/User.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data);
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/User.java import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data);
this.userStatus = UserStatus.values()[getIntFromData("userStatus", data)];
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/User.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data); this.userStatus = UserStatus.values()[getIntFromData("userStatus", data)]; this.userAction = UserAction.values()[getIntFromData("userAction", data)];
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/User.java import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data); this.userStatus = UserStatus.values()[getIntFromData("userStatus", data)]; this.userAction = UserAction.values()[getIntFromData("userAction", data)];
this.lastOnlinedAt = getDateFromData("lastOnlinedAt", data);
AppHero2/Raffler-Android
app/src/main/java/com/raffler/app/models/User.java
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // }
import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData;
package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data); this.userStatus = UserStatus.values()[getIntFromData("userStatus", data)]; this.userAction = UserAction.values()[getIntFromData("userAction", data)]; this.lastOnlinedAt = getDateFromData("lastOnlinedAt", data); this.lastUpdatedAt = getDateFromData("lastUpdatedAt", data);
// Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Date getDateFromData(String key, Map<String, Object> data){ // Date date = new Date(); // String strDate = null; // long timeSince1970 = System.currentTimeMillis(); // try{ // timeSince1970 = (long) data.get(key); // date = new Date(timeSince1970); // }catch (Exception e){ // e.printStackTrace(); // } // // if (date == null) date = new Date(); // // return date; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static int getIntFromData(String key, Map<String, Object> data){ // Integer value = 0; // try{ // String strValue = data.get(key).toString(); // value = Integer.parseInt(strValue); // }catch (Exception e){ // e.printStackTrace(); // } // if(value == null) value = 0; // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static Map<String, Object> getMapDataFromData(String key, Map<String, Object> data){ // Map<String, Object> value = new HashMap<>(); // try{ // value = (Map<String, Object>) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // if (value == null) value = new HashMap<>(); // return value; // } // // Path: app/src/main/java/com/raffler/app/utils/Util.java // public static String getStringFromData(String key, Map<String, Object> data){ // String value = "?"; // try{ // value = (String) data.get(key); // }catch (Exception e){ // e.printStackTrace(); // } // return value; // } // Path: app/src/main/java/com/raffler/app/models/User.java import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.raffler.app.models.UserAction.IDLE; import static com.raffler.app.models.UserStatus.OFFLINE; import static com.raffler.app.utils.Util.getDateFromData; import static com.raffler.app.utils.Util.getIntFromData; import static com.raffler.app.utils.Util.getMapDataFromData; import static com.raffler.app.utils.Util.getStringFromData; package com.raffler.app.models; /** * Created by Ghost on 15/8/2017. */ public class User { private String idx, name, photo, phone, bio, pushToken; private UserStatus userStatus = OFFLINE; private UserAction userAction = IDLE; private Date lastOnlinedAt, lastUpdatedAt; private Map<String,Object> chats = new HashMap<>(); private Map<String,Object> lastseens = new HashMap<>(); private Map<String,Object> raffles = new HashMap<>(); private int raffle_point = 0; public User(Map<String, Object> data){ updateData(data); } public void updateData(Map<String, Object> data){ this.idx = getStringFromData("uid", data); this.name = getStringFromData("name", data); this.photo = getStringFromData("photo", data); this.phone = getStringFromData("phone", data); this.bio = getStringFromData("bio", data); this.pushToken = getStringFromData("pushToken", data); this.userStatus = UserStatus.values()[getIntFromData("userStatus", data)]; this.userAction = UserAction.values()[getIntFromData("userAction", data)]; this.lastOnlinedAt = getDateFromData("lastOnlinedAt", data); this.lastUpdatedAt = getDateFromData("lastUpdatedAt", data);
this.chats = getMapDataFromData("chats", data);
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/Application.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan;
package edu.ucdavis.fiehnlab.spectra.hash.core.validation; @ComponentScan @EnableAutoConfiguration public class Application {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/Application.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; package edu.ucdavis.fiehnlab.spectra.hash.core.validation; @ComponentScan @EnableAutoConfiguration public class Application {
private Splash splash = SplashFactory.create();
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/Application.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan;
package edu.ucdavis.fiehnlab.spectra.hash.core.validation; @ComponentScan @EnableAutoConfiguration public class Application {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/Application.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan; package edu.ucdavis.fiehnlab.spectra.hash.core.validation; @ComponentScan @EnableAutoConfiguration public class Application {
private Splash splash = SplashFactory.create();
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum;
package edu.ucdavis.fiehnlab.spectra.hash.core.listener; /** * a simple listener to react to different splashing events */ public interface SplashListener { /** * let's listener know that a new hash was created * @param e */ void eventReceived(SplashingEvent e); /** * notificaton that the hashing is finished * @param spectrum * @param splash */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; package edu.ucdavis.fiehnlab.spectra.hash.core.listener; /** * a simple listener to react to different splashing events */ public interface SplashListener { /** * let's listener know that a new hash was created * @param e */ void eventReceived(SplashingEvent e); /** * notificaton that the hashing is finished * @param spectrum * @param splash */
void complete(Spectrum spectrum, String splash);
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import java.util.List;
package edu.ucdavis.fiehnlab.spectra.hash.core; /** * describes a spectrum for a splash */ public interface Spectrum { /** * ion of a spectra * @return */ public List<Ion> getIons(); /** * convmerts the spectrum to a relative spectra * @return * @param scale */ Spectrum toRelative(int scale); /** * * @return */ String getOrigin(); /** * what kind of a spectra do we have * @return */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import java.util.List; package edu.ucdavis.fiehnlab.spectra.hash.core; /** * describes a spectrum for a splash */ public interface Spectrum { /** * ion of a spectra * @return */ public List<Ion> getIons(); /** * convmerts the spectrum to a relative spectra * @return * @param scale */ Spectrum toRelative(int scale); /** * * @return */ String getOrigin(); /** * what kind of a spectra do we have * @return */
public SpectraType getType();
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; import java.util.List;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * little utility class to help with converting spectra */ public class SpectraUtil { /** * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions * due to the complexity or the spectra * * @param spectra * @param type * @return */ public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { String[] pairs = spectra.split(" ");
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; import java.util.List; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * little utility class to help with converting spectra */ public class SpectraUtil { /** * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions * due to the complexity or the spectra * * @param spectra * @param type * @return */ public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { String[] pairs = spectra.split(" ");
List<Ion> ionList = new ArrayList<Ion>(200);
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; import java.util.List;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * little utility class to help with converting spectra */ public class SpectraUtil { /** * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions * due to the complexity or the spectra * * @param spectra * @param type * @return */ public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { String[] pairs = spectra.split(" "); List<Ion> ionList = new ArrayList<Ion>(200); for (String pair : pairs) { String[] p = pair.split(":"); Double m = Double.parseDouble(p[0]); Double intensity = Double.parseDouble(p[1]); ionList.add(new Ion(m, intensity)); }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; import java.util.List; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * little utility class to help with converting spectra */ public class SpectraUtil { /** * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions * due to the complexity or the spectra * * @param spectra * @param type * @return */ public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { String[] pairs = spectra.split(" "); List<Ion> ionList = new ArrayList<Ion>(200); for (String pair : pairs) { String[] p = pair.split(":"); Double m = Double.parseDouble(p[0]); Double intensity = Double.parseDouble(p[1]); ionList.add(new Ion(m, intensity)); }
SpectrumImpl impl = new SpectrumImpl(ionList, type);
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner;
seperator = cmd.getOptionValue("separator"); } int columnSplash = -1; if (cmd.hasOption("splash")) { columnSplash = Integer.parseInt(cmd.getOptionValue("splash")); } else { if (!cmd.hasOption("create")) { throw new ParseException("please provide the information in which column the splash can be found"); } else { logger.info("in creation mode, no splash needed at this point"); } } int columnSpectra = 0; if (cmd.hasOption("spectra")) { columnSpectra = Integer.parseInt(cmd.getOptionValue("spectra")); } else { throw new ParseException("please provide the information in which column the spectra can be found"); } int columnOrigin = -1; if (cmd.hasOption("origin")) { columnOrigin = Integer.parseInt(cmd.getOptionValue("origin")); }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner; seperator = cmd.getOptionValue("separator"); } int columnSplash = -1; if (cmd.hasOption("splash")) { columnSplash = Integer.parseInt(cmd.getOptionValue("splash")); } else { if (!cmd.hasOption("create")) { throw new ParseException("please provide the information in which column the splash can be found"); } else { logger.info("in creation mode, no splash needed at this point"); } } int columnSpectra = 0; if (cmd.hasOption("spectra")) { columnSpectra = Integer.parseInt(cmd.getOptionValue("spectra")); } else { throw new ParseException("please provide the information in which column the spectra can be found"); } int columnOrigin = -1; if (cmd.hasOption("origin")) { columnOrigin = Integer.parseInt(cmd.getOptionValue("origin")); }
SpectraType msType = null;
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner;
return counter; } /** * provides us with simple status messages and use for debuggingt * * @param cmd * @param message */ public static void status(CommandLine cmd, String message) { if (!cmd.hasOption("output")) { System.out.print(message); } else { logger.info(message); } } /** * computes new splashes * * @param spectra * @param origin * @param msType * @param stream * @param seperator * @param cmd */ private void splashIt(String spectra, String origin, SpectraType msType, Serializer stream, String seperator, CommandLine cmd, boolean last) throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner; return counter; } /** * provides us with simple status messages and use for debuggingt * * @param cmd * @param message */ public static void status(CommandLine cmd, String message) { if (!cmd.hasOption("output")) { System.out.print(message); } else { logger.info(message); } } /** * computes new splashes * * @param spectra * @param origin * @param msType * @param stream * @param seperator * @param cmd */ private void splashIt(String spectra, String origin, SpectraType msType, Serializer stream, String seperator, CommandLine cmd, boolean last) throws Exception {
String code = SplashUtil.splash(spectra, msType, new Listener(cmd));
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner;
options.addOption("o", "origin", true, "which column contains the origin information"); options.addOption("D", "duplicates", false, "only output discovered duplicates, careful it can be slow!"); options.addOption("S", "sort", false, "sorts the output by given column. Columns can be 'splash' or 'origin' or 'spectra', careful it can be slow!"); options.addOption("SD", "sortDirectory", true, "specify which directory should be used for temporary data, during sorting or duplicate searches"); options.addOption("X", "debug", false, "displays additional debug information, cut to 50 char for strings"); options.addOption("XX", "debugExact", false, "displays additional debug information, complete printout"); options.addOption("XXX", "debugExtraFine", false, "displays even more debug information"); options.addOption("c", "create", false, "computes a validation file with the default splash implementation, instead of validation the file"); options.addOption("v", "validate", false, "validates a provided validation file, if not specified this is the default option"); options.addOption("t", "type", true, "what kind of spectra type is it, options is MS | IR | UV | NMR | RAMAN"); options.addOption("T", "separator", true, "what is the separator between columns"); options.addOption("O", "output", false, "output will be system out, instead of a file"); options.addOption("I", "ignoreErrors", false, "errors in spectra, will be ignored, but displayed"); options.addOption("IS", "ignoreErrorsSuppressed", false, "errors in spectra, will be ignored and not shown"); options.addOption("L", "longFormat", false, "utilizes the long serialization format"); return options; } /** * a simple listener for debug purposes */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner; options.addOption("o", "origin", true, "which column contains the origin information"); options.addOption("D", "duplicates", false, "only output discovered duplicates, careful it can be slow!"); options.addOption("S", "sort", false, "sorts the output by given column. Columns can be 'splash' or 'origin' or 'spectra', careful it can be slow!"); options.addOption("SD", "sortDirectory", true, "specify which directory should be used for temporary data, during sorting or duplicate searches"); options.addOption("X", "debug", false, "displays additional debug information, cut to 50 char for strings"); options.addOption("XX", "debugExact", false, "displays additional debug information, complete printout"); options.addOption("XXX", "debugExtraFine", false, "displays even more debug information"); options.addOption("c", "create", false, "computes a validation file with the default splash implementation, instead of validation the file"); options.addOption("v", "validate", false, "validates a provided validation file, if not specified this is the default option"); options.addOption("t", "type", true, "what kind of spectra type is it, options is MS | IR | UV | NMR | RAMAN"); options.addOption("T", "separator", true, "what is the separator between columns"); options.addOption("O", "output", false, "output will be system out, instead of a file"); options.addOption("I", "ignoreErrors", false, "errors in spectra, will be ignored, but displayed"); options.addOption("IS", "ignoreErrorsSuppressed", false, "errors in spectra, will be ignored and not shown"); options.addOption("L", "longFormat", false, "utilizes the long serialization format"); return options; } /** * a simple listener for debug purposes */
class Listener implements SplashListener {
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner;
options.addOption("t", "type", true, "what kind of spectra type is it, options is MS | IR | UV | NMR | RAMAN"); options.addOption("T", "separator", true, "what is the separator between columns"); options.addOption("O", "output", false, "output will be system out, instead of a file"); options.addOption("I", "ignoreErrors", false, "errors in spectra, will be ignored, but displayed"); options.addOption("IS", "ignoreErrorsSuppressed", false, "errors in spectra, will be ignored and not shown"); options.addOption("L", "longFormat", false, "utilizes the long serialization format"); return options; } /** * a simple listener for debug purposes */ class Listener implements SplashListener { public Listener(CommandLine cmd) { this.cmd = cmd; } private CommandLine cmd; /** * in case we have * * @param e */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner; options.addOption("t", "type", true, "what kind of spectra type is it, options is MS | IR | UV | NMR | RAMAN"); options.addOption("T", "separator", true, "what is the separator between columns"); options.addOption("O", "output", false, "output will be system out, instead of a file"); options.addOption("I", "ignoreErrors", false, "errors in spectra, will be ignored, but displayed"); options.addOption("IS", "ignoreErrorsSuppressed", false, "errors in spectra, will be ignored and not shown"); options.addOption("L", "longFormat", false, "utilizes the long serialization format"); return options; } /** * a simple listener for debug purposes */ class Listener implements SplashListener { public Listener(CommandLine cmd) { this.cmd = cmd; } private CommandLine cmd; /** * in case we have * * @param e */
public void eventReceived(SplashingEvent e) {
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner;
} /** * a simple listener for debug purposes */ class Listener implements SplashListener { public Listener(CommandLine cmd) { this.cmd = cmd; } private CommandLine cmd; /** * in case we have * * @param e */ public void eventReceived(SplashingEvent e) { if (cmd.hasOption("debugExact") || cmd.hasOption("debugExtraFine")) { status(cmd, String.format(FORMAT, e.getBlock() + " raw : ") + e.getRawValue() + "\n"); status(cmd, String.format(FORMAT, e.getBlock() + " processed : ") + e.getProcessedValue() + "\n"); } else if (cmd.hasOption("debug")) { status(cmd, String.format(FORMAT, e.getBlock() + " raw : ") + e.getRawValue().substring(0, Math.min(e.getRawValue().length(), 90)) + "\n"); status(cmd, String.format(FORMAT, e.getBlock() + " processed : ") + e.getProcessedValue().substring(0, Math.min(e.getProcessedValue().length(), 90)) + "\n"); } }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashingEvent.java // public class SplashingEvent { // // private final Spectrum spectrum; // private final String processedValue; // // public SplashingEvent(String processedValue, String rawValue, SplashBlock block, Spectrum spectrum) { // this.processedValue = processedValue; // this.rawValue = rawValue; // this.block = block; // this.spectrum = spectrum; // } // // private final String rawValue; // // public SplashBlock getBlock() { // return block; // } // // // public String getRawValue() { // return rawValue; // } // // public String getProcessedValue() { // return processedValue; // } // // private final SplashBlock block; // // // public Spectrum getSpectrum() { // return spectrum; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java // public class SplashUtil { // // /** // * quick splashing of the latest splash implementation // * // * @param spectra // * @param type // * @return // */ // public static String splash(String spectra, SpectraType type) { // // Splash s = SplashFactory.create(); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // /** // * allows you to add a listener to see what is happening // * @param spectra // * @param type // * @param listener // * @return // */ // public static String splash(String spectra, SpectraType type,SplashListener listener) { // // Splash s = SplashFactory.create(); // s.addListener(listener); // // return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); // } // // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/controller/ValidationController.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashingEvent; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SplashUtil; import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.*; import org.apache.commons.cli.*; import org.apache.log4j.Logger; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Controller; import java.io.*; import java.util.Scanner; } /** * a simple listener for debug purposes */ class Listener implements SplashListener { public Listener(CommandLine cmd) { this.cmd = cmd; } private CommandLine cmd; /** * in case we have * * @param e */ public void eventReceived(SplashingEvent e) { if (cmd.hasOption("debugExact") || cmd.hasOption("debugExtraFine")) { status(cmd, String.format(FORMAT, e.getBlock() + " raw : ") + e.getRawValue() + "\n"); status(cmd, String.format(FORMAT, e.getBlock() + " processed : ") + e.getProcessedValue() + "\n"); } else if (cmd.hasOption("debug")) { status(cmd, String.format(FORMAT, e.getBlock() + " raw : ") + e.getRawValue().substring(0, Math.min(e.getRawValue().length(), 90)) + "\n"); status(cmd, String.format(FORMAT, e.getBlock() + " processed : ") + e.getProcessedValue().substring(0, Math.min(e.getProcessedValue().length(), 90)) + "\n"); } }
public void complete(Spectrum spectrum, String splash) {
berlinguyinca/spectra-hash
web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays;
package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // } // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays; package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController {
private Splash spectraHash;
berlinguyinca/spectra-hash
web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays;
package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController { private Splash spectraHash; private Logger logger = Logger.getLogger(getClass()); public RestController() {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // } // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays; package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController { private Splash spectraHash; private Logger logger = Logger.getLogger(getClass()); public RestController() {
spectraHash = SplashFactory.create();
berlinguyinca/spectra-hash
web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays;
package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController { private Splash spectraHash; private Logger logger = Logger.getLogger(getClass()); public RestController() { spectraHash = SplashFactory.create(); logger.info("created hash generator of type: " + spectraHash); } /** * converts a spectra to the hash code * @param spectrum * @return splash code */ @RequestMapping(value = "/splash/it", method = RequestMethod.POST) public String convert(@RequestBody Spectrum spectrum) { try { logger.info("received spectrum: " + spectrum); if (spectrum.getIons().isEmpty()) { throw new RuntimeException("spectrum must have at least one ion"); } String hash = spectraHash.splashIt(spectrum); logger.info("generated hash: " + hash); return hash; } catch (Exception e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } } @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET) public Spectrum splashRequestExample() { Spectrum spectrum = new Spectrum();
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // } // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays; package edu.ucdavis.fiehnlab.spectra.hash.rest; /** * simple rest service, which hashes submitted spectra data, as well as validate provided spectra hashes against the current reference implementation */ @CrossOrigin @org.springframework.web.bind.annotation.RestController public class RestController { private Splash spectraHash; private Logger logger = Logger.getLogger(getClass()); public RestController() { spectraHash = SplashFactory.create(); logger.info("created hash generator of type: " + spectraHash); } /** * converts a spectra to the hash code * @param spectrum * @return splash code */ @RequestMapping(value = "/splash/it", method = RequestMethod.POST) public String convert(@RequestBody Spectrum spectrum) { try { logger.info("received spectrum: " + spectrum); if (spectrum.getIons().isEmpty()) { throw new RuntimeException("spectrum must have at least one ion"); } String hash = spectraHash.splashIt(spectrum); logger.info("generated hash: " + hash); return hash; } catch (Exception e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } } @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET) public Spectrum splashRequestExample() { Spectrum spectrum = new Spectrum();
spectrum.setIons(Arrays.asList(new Ion(100, 1), new Ion(101, 2), new Ion(102, 3)));
berlinguyinca/spectra-hash
web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays;
if (spectrum.getIons().isEmpty()) { throw new RuntimeException("spectrum must have at least one ion"); } String hash = spectraHash.splashIt(spectrum); logger.info("generated hash: " + hash); return hash; } catch (Exception e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } } @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET) public Spectrum splashRequestExample() { Spectrum spectrum = new Spectrum(); spectrum.setIons(Arrays.asList(new Ion(100, 1), new Ion(101, 2), new Ion(102, 3))); spectrum.setOrigin("where do I come from or null"); spectrum.setType(SpectraType.MS); return spectrum; } /** * converts a spectra to the hash code * @param validationRequest * @return validation response */ @RequestMapping(value = "/splash/validate", method = RequestMethod.POST)
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/dao/ValidationResponse.java // public class ValidationResponse { // String referenceSplash; // // boolean validationSuccessful; // // public boolean isValidationSuccessful() { // return validationSuccessful; // } // // public void setValidationSuccessful(boolean validationSuccessful) { // this.validationSuccessful = validationSuccessful; // } // // public ValidationRequest getRequest() { // return request; // } // // public void setRequest(ValidationRequest request) { // this.request = request; // } // // public String getReferenceSplash() { // return referenceSplash; // } // // public void setReferenceSplash(String refrenceSplash) { // this.referenceSplash = refrenceSplash; // } // // ValidationRequest request; // } // Path: web/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/rest/RestController.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationRequest; import edu.ucdavis.fiehnlab.spectra.hash.rest.dao.ValidationResponse; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.*; import java.util.Arrays; if (spectrum.getIons().isEmpty()) { throw new RuntimeException("spectrum must have at least one ion"); } String hash = spectraHash.splashIt(spectrum); logger.info("generated hash: " + hash); return hash; } catch (Exception e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } } @RequestMapping(value = "/splash/it/example" ,method = RequestMethod.GET) public Spectrum splashRequestExample() { Spectrum spectrum = new Spectrum(); spectrum.setIons(Arrays.asList(new Ion(100, 1), new Ion(101, 2), new Ion(102, 3))); spectrum.setOrigin("where do I come from or null"); spectrum.setType(SpectraType.MS); return spectrum; } /** * converts a spectra to the hash code * @param validationRequest * @return validation response */ @RequestMapping(value = "/splash/validate", method = RequestMethod.POST)
public ValidationResponse validate(@RequestBody ValidationRequest validationRequest) {
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/IonTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core; /** * test case for 1 ion */ public class IonTest { @org.junit.Test public void testToString() throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/IonTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core; /** * test case for 1 ion */ public class IonTest { @org.junit.Test public void testToString() throws Exception {
Ion ion = new Ion(100.0222222,122.011111);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception {
Ion ion = new Ion(120, 111);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception { Ion ion = new Ion(120, 111); ArrayList<Ion> list = new ArrayList<Ion>(); list.add(ion);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception { Ion ion = new Ion(120, 111); ArrayList<Ion> list = new ArrayList<Ion>(); list.add(ion);
SpectrumImpl impl = new SpectrumImpl(list, "test", SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception { Ion ion = new Ion(120, 111); ArrayList<Ion> list = new ArrayList<Ion>(); list.add(ion);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/SpectrumImplTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * */ public class SpectrumImplTest { @Test public void testGetIons() throws Exception { Ion ion = new Ion(120, 111); ArrayList<Ion> list = new ArrayList<Ion>(); list.add(ion);
SpectrumImpl impl = new SpectrumImpl(list, "test", SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/TestSpectraImpl.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * simple implementations needed for testing */ public class TestSpectraImpl extends SpectrumImpl { public void setHash(String hash) { this.hash = hash; } private String hash; public TestSpectraImpl() { }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/TestSpectraImpl.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * simple implementations needed for testing */ public class TestSpectraImpl extends SpectrumImpl { public void setHash(String hash) { this.hash = hash; } private String hash; public TestSpectraImpl() { }
public TestSpectraImpl(Spectrum s, String hash) {
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/TestSpectraImpl.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * simple implementations needed for testing */ public class TestSpectraImpl extends SpectrumImpl { public void setHash(String hash) { this.hash = hash; } private String hash; public TestSpectraImpl() { } public TestSpectraImpl(Spectrum s, String hash) {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/TestSpectraImpl.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import java.util.ArrayList; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * simple implementations needed for testing */ public class TestSpectraImpl extends SpectrumImpl { public void setHash(String hash) { this.hash = hash; } private String hash; public TestSpectraImpl() { } public TestSpectraImpl(Spectrum s, String hash) {
super((ArrayList<Ion>) s.getIons(), s.getOrigin(), s.getType());
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Serializer.java
// Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Result.java // public class Result { // // String splash; // // String spectra; // // String origin; // // SpectraType type; // // public Result(String splash, String spectra, String origin, SpectraType type, String separator) { // this.splash = splash; // this.spectra = spectra; // this.origin = origin; // this.type = type; // this.separator = separator; // } // // public Result() { // } // // public String getSeparator() { // return separator; // } // // public void setSeparator(String separator) { // this.separator = separator; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public String getSpectra() { // return spectra; // } // // public void setSpectra(String spectra) { // this.spectra = spectra; // } // // public String getSplash() { // return splash; // } // // public void setSplash(String splash) { // this.splash = splash; // } // // String separator; // // // @Override // public String toString() { // return this.getSplash() + this.getSeparator() + this.getOrigin() + this.getSeparator() + this.getSpectra(); // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.Result; import org.apache.commons.cli.CommandLine; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream;
package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * writes out objects to the given stream */ public class Serializer { public PrintStream getStream() { return stream; } public CommandLine getCmd() { return cmd; } /** * where to write our o */ private PrintStream stream; public Serializer(CommandLine cmd, PrintStream stream) { this.cmd = cmd; this.stream = stream; } private CommandLine cmd; /** * begins the serialization */ public void init() throws Exception { } /** * serializes an object * * @param result */
// Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Result.java // public class Result { // // String splash; // // String spectra; // // String origin; // // SpectraType type; // // public Result(String splash, String spectra, String origin, SpectraType type, String separator) { // this.splash = splash; // this.spectra = spectra; // this.origin = origin; // this.type = type; // this.separator = separator; // } // // public Result() { // } // // public String getSeparator() { // return separator; // } // // public void setSeparator(String separator) { // this.separator = separator; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public String getSpectra() { // return spectra; // } // // public void setSpectra(String spectra) { // this.spectra = spectra; // } // // public String getSplash() { // return splash; // } // // public void setSplash(String splash) { // this.splash = splash; // } // // String separator; // // // @Override // public String toString() { // return this.getSplash() + this.getSeparator() + this.getOrigin() + this.getSeparator() + this.getSpectra(); // } // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Serializer.java import edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize.Result; import org.apache.commons.cli.CommandLine; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * writes out objects to the given stream */ public class Serializer { public PrintStream getStream() { return stream; } public CommandLine getCmd() { return cmd; } /** * where to write our o */ private PrintStream stream; public Serializer(CommandLine cmd, PrintStream stream) { this.cmd = cmd; this.stream = stream; } private CommandLine cmd; /** * begins the serialization */ public void init() throws Exception { } /** * serializes an object * * @param result */
public void serialize(Result result) throws IOException {
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/ValidationResult.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/15/15 * Time: 12:30 PM */ public class ValidationResult extends Result { boolean valid; public String getSplashToValidate() { return splashToValidate; } public void setSplashToValidate(String splashToValidate) { this.splashToValidate = splashToValidate; } String splashToValidate; public ValidationResult() { } @Override public String toString() { return this.getSplash() + this.getSeparator() + this.getOrigin() + this.getSeparator() + this.isValid() + this.getSeparator() + this.getSplashToValidate() + this.getSeparator() + this.getSpectra(); }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/ValidationResult.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/15/15 * Time: 12:30 PM */ public class ValidationResult extends Result { boolean valid; public String getSplashToValidate() { return splashToValidate; } public void setSplashToValidate(String splashToValidate) { this.splashToValidate = splashToValidate; } String splashToValidate; public ValidationResult() { } @Override public String toString() { return this.getSplash() + this.getSeparator() + this.getOrigin() + this.getSeparator() + this.isValid() + this.getSeparator() + this.getSplashToValidate() + this.getSeparator() + this.getSpectra(); }
public ValidationResult(String code, String spectra, String origin, SpectraType msType, String seperator, boolean valid, String splash) {
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // }
import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener;
package edu.ucdavis.fiehnlab.spectra.hash.core; /** * declares an easy to use api to calculate a spectra hash */ public interface Splash { /** * generates a new spectra hash based on the given spectrum * @return */ String splashIt(Spectrum spectrum); /** * adds an optional listener to the * @param listener */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; package edu.ucdavis.fiehnlab.spectra.hash.core; /** * declares an easy to use api to calculate a spectra hash */ public interface Splash { /** * generates a new spectra hash based on the given spectrum * @return */ String splashIt(Spectrum spectrum); /** * adds an optional listener to the * @param listener */
void addListener(SplashListener listener);
berlinguyinca/spectra-hash
validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Result.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/15/15 * Time: 12:30 PM */ public class Result { String splash; String spectra; String origin;
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: validation/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/validation/serialize/Result.java import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; package edu.ucdavis.fiehnlab.spectra.hash.core.validation.serialize; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/15/15 * Time: 12:30 PM */ public class Result { String splash; String spectra; String origin;
SpectraType type;
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */
protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException {
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class);
final SpectrumReader reader = new SpectrumReader();
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class); final SpectrumReader reader = new SpectrumReader();
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class); final SpectrumReader reader = new SpectrumReader();
reader.readSpectrum(new InputStreamReader(getClass().getResourceAsStream(inputFile)), new SpectraHandler() {
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail;
package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class); final SpectrumReader reader = new SpectrumReader(); reader.readSpectrum(new InputStreamReader(getClass().getResourceAsStream(inputFile)), new SpectraHandler() { public void begin() throws IOException { } /** * splashIt hash and serialize as json for later usage * @param s */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java // public interface SpectraHandler { // // /** // * beginning to read // */ // void begin() throws IOException; // /** // * a spectrum was found, lets do something with it // * @param spectrum // */ // void handle(Spectrum spectrum); // // /** // * no more data // */ // void done() throws IOException; // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java // public class SpectrumReader { // // private Logger logger = Logger.getLogger(getClass().getName()); // // /** // * read a spectrum and notify our handler // * // * @param reader // * @param handler // */ // public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { // Scanner scanner = new Scanner(reader); // // handler.begin(); // while (scanner.hasNextLine()) { // String line = scanner.nextLine().trim(); // // String origin = "unknown"; // // //in case some people use several spaces instead of a tab... // line = line.replaceAll(" {2,}", "\t"); // // //in case people use csv instead of a tab // line = line.replaceAll(",", "\t"); // // if (line.contains("\t")) { // String t[] = line.split("\t"); // // origin = t[0]; // line = t[1]; // // if (t.length == 3) { // origin = origin + "_" + t[2]; // } // } // // if (line.contains(":") && line.contains(" ")) { // // Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin); // // handler.handle(spectrum); // } // } // // handler.done(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/impl/AbstractSpectraHashImplTester.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectraHandler; import edu.ucdavis.fiehnlab.spectra.hash.core.io.SpectrumReader; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.geirove.exmeso.CloseableIterator; import org.geirove.exmeso.ExternalMergeSort; import org.geirove.exmeso.kryo.KryoSerializer; import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import static org.junit.Assert.fail; package edu.ucdavis.fiehnlab.spectra.hash.core.impl; /** * general testing strategy for splash implementations */ public abstract class AbstractSpectraHashImplTester{ /** * get our impl to test * * @return */ abstract Splash getHashImpl(); /** * runs our actual tests on the input and output files * * @param resultFile * @param inputFile * @throws IOException */ protected TestResult runTest(String resultFile, String inputFile, SpectraType spectraType, boolean onlyDuplicates) throws IOException { final File tempFile = File.createTempFile("splash", "tmp"); tempFile.deleteOnExit(); final OutputStream temp = new BufferedOutputStream(new FileOutputStream(tempFile)); final ExternalMergeSort.Serializer<TestSpectraImpl> serializer = new KryoSerializer<TestSpectraImpl>(TestSpectraImpl.class); final SpectrumReader reader = new SpectrumReader(); reader.readSpectrum(new InputStreamReader(getClass().getResourceAsStream(inputFile)), new SpectraHandler() { public void begin() throws IOException { } /** * splashIt hash and serialize as json for later usage * @param s */
public void handle(Spectrum s) {
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import java.io.IOException;
package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * simple handler to work on received spectra */ public interface SpectraHandler { /** * beginning to read */ void begin() throws IOException; /** * a spectrum was found, lets do something with it * @param spectrum */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectraHandler.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import java.io.IOException; package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * simple handler to work on received spectra */ public interface SpectraHandler { /** * beginning to read */ void begin() throws IOException; /** * a spectrum was found, lets do something with it * @param spectrum */
void handle(Spectrum spectrum);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReaderTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull;
package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * simple test of a spectrum reader */ public class SpectrumReaderTest { Spectrum spectrum = null; @Test public void testReadSpectrum() throws Exception { SpectrumReader reader = new SpectrumReader(); reader.readSpectrum(new StringReader("100:1 101:2 103:3"), new SpectraHandler() { public void begin() throws IOException { } public void handle(Spectrum s) { spectrum = s; } public void done() throws IOException { }
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReaderTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import java.io.IOException; import java.io.StringReader; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * simple test of a spectrum reader */ public class SpectrumReaderTest { Spectrum spectrum = null; @Test public void testReadSpectrum() throws Exception { SpectrumReader reader = new SpectrumReader(); reader.readSpectrum(new StringReader("100:1 101:2 103:3"), new SpectraHandler() { public void begin() throws IOException { } public void handle(Spectrum s) { spectrum = s; } public void done() throws IOException { }
}, SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception {
Spectrum spectrum = SpectraUtil.convertStringToSpectrum("127:12 128:12.12 129:123", SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception {
Spectrum spectrum = SpectraUtil.convertStringToSpectrum("127:12 128:12.12 129:123", SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception { Spectrum spectrum = SpectraUtil.convertStringToSpectrum("127:12 128:12.12 129:123", SpectraType.MS);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import org.junit.Test; import static org.junit.Assert.assertTrue; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:15 PM */ public class SpectraUtilTest { @Test public void testConvertStringToSpectrum() throws Exception { Spectrum spectrum = SpectraUtil.convertStringToSpectrum("127:12 128:12.12 129:123", SpectraType.MS);
assertTrue(spectrum.getIons().contains(new Ion(127,12)));
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) {
Splash s = SplashFactory.create();
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) {
Splash s = SplashFactory.create();
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) { Splash s = SplashFactory.create(); return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); } /** * allows you to add a listener to see what is happening * @param spectra * @param type * @param listener * @return */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/listener/SplashListener.java // public interface SplashListener { // // /** // * let's listener know that a new hash was created // * @param e // */ // void eventReceived(SplashingEvent e); // // /** // * notificaton that the hashing is finished // * @param spectrum // * @param splash // */ // void complete(Spectrum spectrum, String splash); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtil.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.listener.SplashListener; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * a simple splash util, to ease the splashing of data */ public class SplashUtil { /** * quick splashing of the latest splash implementation * * @param spectra * @param type * @return */ public static String splash(String spectra, SpectraType type) { Splash s = SplashFactory.create(); return s.splashIt(SpectraUtil.convertStringToSpectrum(spectra, type)); } /** * allows you to add a listener to see what is happening * @param spectra * @param type * @param listener * @return */
public static String splash(String spectra, SpectraType type,SplashListener listener) {
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger;
package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger; package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */
public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException {
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger;
package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */ public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { Scanner scanner = new Scanner(reader); handler.begin(); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String origin = "unknown"; //in case some people use several spaces instead of a tab... line = line.replaceAll(" {2,}", "\t"); //in case people use csv instead of a tab line = line.replaceAll(",", "\t"); if (line.contains("\t")) { String t[] = line.split("\t"); origin = t[0]; line = t[1]; if (t.length == 3) { origin = origin + "_" + t[2]; } } if (line.contains(":") && line.contains(" ")) {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger; package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */ public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { Scanner scanner = new Scanner(reader); handler.begin(); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String origin = "unknown"; //in case some people use several spaces instead of a tab... line = line.replaceAll(" {2,}", "\t"); //in case people use csv instead of a tab line = line.replaceAll(",", "\t"); if (line.contains("\t")) { String t[] = line.split("\t"); origin = t[0]; line = t[1]; if (t.length == 3) { origin = origin + "_" + t[2]; } } if (line.contains(":") && line.contains(" ")) {
Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin);
berlinguyinca/spectra-hash
core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger;
package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */ public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { Scanner scanner = new Scanner(reader); handler.begin(); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String origin = "unknown"; //in case some people use several spaces instead of a tab... line = line.replaceAll(" {2,}", "\t"); //in case people use csv instead of a tab line = line.replaceAll(",", "\t"); if (line.contains("\t")) { String t[] = line.split("\t"); origin = t[0]; line = t[1]; if (t.length == 3) { origin = origin + "_" + t[2]; } } if (line.contains(":") && line.contains(" ")) {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Spectrum.java // public interface Spectrum { // // /** // * ion of a spectra // * @return // */ // public List<Ion> getIons(); // // /** // * convmerts the spectrum to a relative spectra // * @return // * @param scale // */ // Spectrum toRelative(int scale); // // /** // * // * @return // */ // String getOrigin(); // // /** // * what kind of a spectra do we have // * @return // */ // public SpectraType getType(); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SpectraUtil.java // public class SpectraUtil { // // /** // * converts a string to a spectrum object for us, we can't really verify it, since this will cause stack overflow exceptions // * due to the complexity or the spectra // * // * @param spectra // * @param type // * @return // */ // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type, String origin) { // // String[] pairs = spectra.split(" "); // // List<Ion> ionList = new ArrayList<Ion>(200); // // for (String pair : pairs) { // String[] p = pair.split(":"); // // Double m = Double.parseDouble(p[0]); // Double intensity = Double.parseDouble(p[1]); // // ionList.add(new Ion(m, intensity)); // // } // // SpectrumImpl impl = new SpectrumImpl(ionList, type); // impl.setOrigin(origin); // // return impl; // } // // public static Spectrum convertStringToSpectrum(String spectra, SpectraType type) { // return convertStringToSpectrum( spectra, type, "unknown"); // } // } // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/io/SpectrumReader.java import edu.ucdavis.fiehnlab.spectra.hash.core.Spectrum; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.util.SpectraUtil; import java.io.IOException; import java.io.Reader; import java.util.Scanner; import java.util.logging.Logger; package edu.ucdavis.fiehnlab.spectra.hash.core.io; /** * reads a spectrum from the file input stream and notifies our spectrum handler */ public class SpectrumReader { private Logger logger = Logger.getLogger(getClass().getName()); /** * read a spectrum and notify our handler * * @param reader * @param handler */ public void readSpectrum(Reader reader, SpectraHandler handler, SpectraType spectraType) throws IOException { Scanner scanner = new Scanner(reader); handler.begin(); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String origin = "unknown"; //in case some people use several spaces instead of a tab... line = line.replaceAll(" {2,}", "\t"); //in case people use csv instead of a tab line = line.replaceAll(",", "\t"); if (line.contains("\t")) { String t[] = line.split("\t"); origin = t[0]; line = t[1]; if (t.length == 3) { origin = origin + "_" + t[2]; } } if (line.contains(":") && line.contains(" ")) {
Spectrum spectrum = SpectraUtil.convertStringToSpectrum(line,spectraType,origin);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception {
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception {
String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS);
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS);
Splash splash = SplashFactory.create();
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS);
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS);
Splash splash = SplashFactory.create();
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS); Splash splash = SplashFactory.create();
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS); Splash splash = SplashFactory.create();
String splashDirectlyCreated = splash.splashIt(new SpectrumImpl(Arrays.asList(new Ion(127, 1), new Ion(128, 2)), SpectraType.MS));
berlinguyinca/spectra-hash
core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // }
import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals;
package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS); Splash splash = SplashFactory.create();
// Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/Splash.java // public interface Splash { // // /** // * generates a new spectra hash based on the given spectrum // * @return // */ // String splashIt(Spectrum spectrum); // // /** // * adds an optional listener to the // * @param listener // */ // void addListener(SplashListener listener); // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/SplashFactory.java // public class SplashFactory { // // public static Splash create() { // return createVersion1Splash(); // } // // /** // * the first official splash release // * // * @return // */ // public static Splash createVersion1Splash() { // return new SplashVersion1(); // } // // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/Ion.java // public class Ion implements Comparable<Ion> { // private static String SEPERATOR = ":"; // private static int PRECESSION = 6; // // private Double mass; // private Double intensity; // // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Ion)) return false; // // Ion ion = (Ion) o; // // if (!getMass().equals(ion.getMass())) return false; // return getIntensity().equals(ion.getIntensity()); // // } // // @Override // public int hashCode() { // int result = getMass().hashCode(); // result = 31 * result + getIntensity().hashCode(); // return result; // } // // public Ion() {} // // public Ion(double mass, double intensity) { // this.mass = mass; // this.intensity = intensity; // } // // public Double getIntensity() { // return intensity; // } // // public void setIntensity(Double intensity) { // this.intensity = intensity; // } // // public Double getMass() { // return mass; // } // // public void setMass(Double mass) { // this.mass = mass; // } // // public String toString() { // return String.format("%."+PRECESSION+"f",this.getMass()) + SEPERATOR + String.format("%." + PRECESSION + "f", this.getIntensity()); // } // // public int compareTo(Ion o) { // return getMass().compareTo(o.getMass()); // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectraType.java // public enum SpectraType { // MS('1'), // NMR('2'), // UV('3'), // IR('4'), // RAMAN('5'); // // /** // * identifier has to be a single character // */ // private final char identifier; // // /** // * creates a new spectra type with the assoicated reference number // * // * @param referenceNumber // */ // SpectraType(char referenceNumber) { // this.identifier = referenceNumber; // } // // /** // * access to it's identifier // * // * @return // */ // public char getIdentifier() { // return this.identifier; // } // } // // Path: core/src/main/java/edu/ucdavis/fiehnlab/spectra/hash/core/types/SpectrumImpl.java // public class SpectrumImpl implements Spectrum { // // private String origin; // private List<Ion> ions; // private SpectraType type; // // public SpectrumImpl(List<Ion> ions, String origin, SpectraType type) { // this.ions = ions; // this.origin = origin; // this.type = type; // } // // // protected SpectrumImpl(){ // // } // // public SpectrumImpl(List<Ion> ions, SpectraType ms) { // this(ions,"unknown",ms); // // } // // public String getOrigin() { // return origin; // } // // public void setOrigin(String origin) { // this.origin = origin; // } // // public SpectraType getType() { // return type; // } // // public void setType(SpectraType type) { // this.type = type; // } // // public List<Ion> getIons() { // return ions; // } // // public void setIons(List<Ion> ions) { // this.ions = ions; // } // // // public Spectrum toRelative(int scale) { // double max = 0; // // for (Ion ion : getIons()) { // if (ion.getIntensity() > max) { // max = ion.getIntensity(); // } // } // // ArrayList<Ion> ions = new ArrayList<Ion>(getIons().size()); // for (Ion ion : getIons()) { // ions.add(new Ion(ion.getMass(), ion.getIntensity() / max * scale)); // } // return new SpectrumImpl(ions, getOrigin(), getType()); // } // // } // Path: core/src/test/java/edu/ucdavis/fiehnlab/spectra/hash/core/util/SplashUtilTest.java import edu.ucdavis.fiehnlab.spectra.hash.core.Splash; import edu.ucdavis.fiehnlab.spectra.hash.core.SplashFactory; import edu.ucdavis.fiehnlab.spectra.hash.core.types.Ion; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectraType; import edu.ucdavis.fiehnlab.spectra.hash.core.types.SpectrumImpl; import org.junit.Test; import java.util.Arrays; import static org.junit.Assert.assertEquals; package edu.ucdavis.fiehnlab.spectra.hash.core.util; /** * Created with IntelliJ IDEA. * User: wohlgemuth * Date: 7/14/15 * Time: 2:19 PM */ public class SplashUtilTest { @Test public void testSplash() throws Exception { String splashUtilGenerated = SplashUtil.splash("127:1 128:2", SpectraType.MS); Splash splash = SplashFactory.create();
String splashDirectlyCreated = splash.splashIt(new SpectrumImpl(Arrays.asList(new Ion(127, 1), new Ion(128, 2)), SpectraType.MS));
inevo/java-psd-library
psd-parser/src/psd/parser/layer/additional/effects/GlowEffect.java
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // }
import psd.parser.BlendMode; import java.awt.*;
package psd.parser.layer.additional.effects; public class GlowEffect extends PSDEffect { public static String REGULAR = "oglw"; public static String INNER = "iglw"; private boolean inner = false; private int version; private float alpha; private int blur; private Color color; private int quality; private int strength; private int intensity;
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // Path: psd-parser/src/psd/parser/layer/additional/effects/GlowEffect.java import psd.parser.BlendMode; import java.awt.*; package psd.parser.layer.additional.effects; public class GlowEffect extends PSDEffect { public static String REGULAR = "oglw"; public static String INNER = "iglw"; private boolean inner = false; private int version; private float alpha; private int blur; private Color color; private int quality; private int strength; private int intensity;
private BlendMode blendMode;
inevo/java-psd-library
psd-parser/src/psd/parser/layer/additional/LayerUnicodeNameParser.java
// Path: psd-parser/src/psd/parser/PsdInputStream.java // public class PsdInputStream extends InputStream { // // private int pos; // private int markPos; // private final DataInputStream in; // // public PsdInputStream(InputStream in) { // this.in = new DataInputStream(in); // pos = 0; // markPos = 0; // } // // @Override // public int available() throws IOException { // return in.available(); // } // // @Override // public void close() throws IOException { // in.close(); // } // // @Override // public synchronized void mark(int readlimit) { // in.mark(readlimit); // markPos = pos; // } // // @Override // public synchronized void reset() throws IOException { // in.reset(); // pos = markPos; // } // // @Override // public boolean markSupported() { // return in.markSupported(); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // int res = in.read(b, off, len); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read(byte[] b) throws IOException { // int res = in.read(b); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read() throws IOException { // int res = in.read(); // if (res != -1) { // pos++; // } // return res; // } // // @Override // public long skip(long n) throws IOException { // long skip = in.skip(n); // pos += skip; // return skip; // } // // public String readString(int len) throws IOException { // // read string of specified length // byte[] bytes = new byte[len]; // read(bytes); // return new String(bytes, "ISO-8859-1"); // } // // public String readPsdString() throws IOException { // int size = readInt(); // if (size == 0) { // size = 4; // } // return readString(size); // } // // public int readBytes(byte[] bytes, int n) throws IOException { // // read multiple bytes from input // if (bytes == null) // return 0; // int r = 0; // r = read(bytes, 0, n); // if (r < n) { // throw new IOException("format error. readed=" + r + " needed=" + n); // } // return r; // } // // public byte readByte() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (byte) (ch); // } // // public int readUnsignedByte() throws IOException { // int res = in.readUnsignedByte(); // if (res != -1) { // pos++; // } // return res; // } // // public short readShort() throws IOException { // int ch1 = read(); // int ch2 = read(); // if ((ch1 | ch2) < 0) { // throw new EOFException(); // } // return (short) ((ch1 << 8) + (ch2 << 0)); // } // // public int readInt() throws IOException { // int ch1 = read(); // int ch2 = read(); // int ch3 = read(); // int ch4 = read(); // if ((ch1 | ch2 | ch3 | ch4) < 0) { // throw new EOFException(); // } // return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); // } // // public boolean readBoolean() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (ch != 0); // } // // public final long readLong() throws IOException { // int c1 = read(); // int c2 = read(); // int c3 = read(); // int c4 = read(); // int c5 = read(); // int c6 = read(); // int c7 = read(); // int c8 = read(); // return (((long) c1 << 56) + ((long) (c2 & 255) << 48) // + ((long) (c3 & 255) << 40) + ((long) (c4 & 255) << 32) // + ((long) (c5 & 255) << 24) + ((c6 & 255) << 16) // + ((c7 & 255) << 8) + (c8 & 255)); // } // // public final double readDouble() throws IOException { // return Double.longBitsToDouble(readLong()); // } // // public int skipBytes(int n) throws IOException { // int total = 0; // int cur; // while ((total < n) && ((cur = (int) skip(n - total)) > 0)) { // total += cur; // } // return total; // } // // public int getPos() { // return pos; // } // // } // // Path: psd-parser/src/psd/parser/layer/LayerAdditionalInformationParser.java // public interface LayerAdditionalInformationParser { // public void parse(PsdInputStream stream, String tag, int size) throws IOException; // }
import java.io.IOException; import psd.parser.PsdInputStream; import psd.parser.layer.LayerAdditionalInformationParser;
package psd.parser.layer.additional; public class LayerUnicodeNameParser implements LayerAdditionalInformationParser { public static final String TAG = "luni"; private final LayerUnicodeNameHandler handler; public LayerUnicodeNameParser(LayerUnicodeNameHandler handler) { this.handler = handler; } @Override
// Path: psd-parser/src/psd/parser/PsdInputStream.java // public class PsdInputStream extends InputStream { // // private int pos; // private int markPos; // private final DataInputStream in; // // public PsdInputStream(InputStream in) { // this.in = new DataInputStream(in); // pos = 0; // markPos = 0; // } // // @Override // public int available() throws IOException { // return in.available(); // } // // @Override // public void close() throws IOException { // in.close(); // } // // @Override // public synchronized void mark(int readlimit) { // in.mark(readlimit); // markPos = pos; // } // // @Override // public synchronized void reset() throws IOException { // in.reset(); // pos = markPos; // } // // @Override // public boolean markSupported() { // return in.markSupported(); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // int res = in.read(b, off, len); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read(byte[] b) throws IOException { // int res = in.read(b); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read() throws IOException { // int res = in.read(); // if (res != -1) { // pos++; // } // return res; // } // // @Override // public long skip(long n) throws IOException { // long skip = in.skip(n); // pos += skip; // return skip; // } // // public String readString(int len) throws IOException { // // read string of specified length // byte[] bytes = new byte[len]; // read(bytes); // return new String(bytes, "ISO-8859-1"); // } // // public String readPsdString() throws IOException { // int size = readInt(); // if (size == 0) { // size = 4; // } // return readString(size); // } // // public int readBytes(byte[] bytes, int n) throws IOException { // // read multiple bytes from input // if (bytes == null) // return 0; // int r = 0; // r = read(bytes, 0, n); // if (r < n) { // throw new IOException("format error. readed=" + r + " needed=" + n); // } // return r; // } // // public byte readByte() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (byte) (ch); // } // // public int readUnsignedByte() throws IOException { // int res = in.readUnsignedByte(); // if (res != -1) { // pos++; // } // return res; // } // // public short readShort() throws IOException { // int ch1 = read(); // int ch2 = read(); // if ((ch1 | ch2) < 0) { // throw new EOFException(); // } // return (short) ((ch1 << 8) + (ch2 << 0)); // } // // public int readInt() throws IOException { // int ch1 = read(); // int ch2 = read(); // int ch3 = read(); // int ch4 = read(); // if ((ch1 | ch2 | ch3 | ch4) < 0) { // throw new EOFException(); // } // return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); // } // // public boolean readBoolean() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (ch != 0); // } // // public final long readLong() throws IOException { // int c1 = read(); // int c2 = read(); // int c3 = read(); // int c4 = read(); // int c5 = read(); // int c6 = read(); // int c7 = read(); // int c8 = read(); // return (((long) c1 << 56) + ((long) (c2 & 255) << 48) // + ((long) (c3 & 255) << 40) + ((long) (c4 & 255) << 32) // + ((long) (c5 & 255) << 24) + ((c6 & 255) << 16) // + ((c7 & 255) << 8) + (c8 & 255)); // } // // public final double readDouble() throws IOException { // return Double.longBitsToDouble(readLong()); // } // // public int skipBytes(int n) throws IOException { // int total = 0; // int cur; // while ((total < n) && ((cur = (int) skip(n - total)) > 0)) { // total += cur; // } // return total; // } // // public int getPos() { // return pos; // } // // } // // Path: psd-parser/src/psd/parser/layer/LayerAdditionalInformationParser.java // public interface LayerAdditionalInformationParser { // public void parse(PsdInputStream stream, String tag, int size) throws IOException; // } // Path: psd-parser/src/psd/parser/layer/additional/LayerUnicodeNameParser.java import java.io.IOException; import psd.parser.PsdInputStream; import psd.parser.layer.LayerAdditionalInformationParser; package psd.parser.layer.additional; public class LayerUnicodeNameParser implements LayerAdditionalInformationParser { public static final String TAG = "luni"; private final LayerUnicodeNameHandler handler; public LayerUnicodeNameParser(LayerUnicodeNameHandler handler) { this.handler = handler; } @Override
public void parse(PsdInputStream stream, String tag, int size) throws IOException {
inevo/java-psd-library
psd-parser/src/psd/parser/layer/additional/LayerTypeToolHandler.java
// Path: psd-parser/src/psd/parser/object/PsdDescriptor.java // public class PsdDescriptor extends PsdObject { // // /** The class id or layer type. */ // private final String classId; // // /** a map containing all values of the descriptor */ // private final HashMap<String, PsdObject> objects = new HashMap<String, PsdObject>(); // // /** // * Instantiates a new psd descriptor. // * // * @param stream the stream // * @throws IOException Signals that an I/O exception has occurred. // */ // public PsdDescriptor(PsdInputStream stream) throws IOException { // // Unicode string: name from classID // int nameLen = stream.readInt() * 2; // stream.skipBytes(nameLen); // // classId = stream.readPsdString(); // int itemsCount = stream.readInt(); // logger.finest("PsdDescriptor.itemsCount: " + itemsCount); // for (int i = 0; i < itemsCount; i++) { // String key = stream.readPsdString().trim(); // logger.finest("PsdDescriptor.key: " + key); // objects.put(key, PsdObjectFactory.loadPsdObject(stream)); // } // } // // /** // * Gets the class id. // * // * @return the class id // */ // public String getClassId() { // return classId; // } // // /** // * Gets the objects. // * // * @return the objects // */ // public Map<String, PsdObject> getObjects() { // return objects; // } // // /** // * Gets the. // * // * @param key the key // * @return the psd object // */ // public PsdObject get(String key) { // return objects.get(key); // } // // /** // * Contains key. // * // * @param key the key // * @return true, if successful // */ // public boolean containsKey(String key) { // return objects.containsKey(key); // } // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // @Override // public String toString() { // return "Objc:" + objects.toString(); // } // // }
import psd.parser.object.PsdDescriptor;
package psd.parser.layer.additional; public interface LayerTypeToolHandler { public void typeToolTransformParsed(Matrix transform);
// Path: psd-parser/src/psd/parser/object/PsdDescriptor.java // public class PsdDescriptor extends PsdObject { // // /** The class id or layer type. */ // private final String classId; // // /** a map containing all values of the descriptor */ // private final HashMap<String, PsdObject> objects = new HashMap<String, PsdObject>(); // // /** // * Instantiates a new psd descriptor. // * // * @param stream the stream // * @throws IOException Signals that an I/O exception has occurred. // */ // public PsdDescriptor(PsdInputStream stream) throws IOException { // // Unicode string: name from classID // int nameLen = stream.readInt() * 2; // stream.skipBytes(nameLen); // // classId = stream.readPsdString(); // int itemsCount = stream.readInt(); // logger.finest("PsdDescriptor.itemsCount: " + itemsCount); // for (int i = 0; i < itemsCount; i++) { // String key = stream.readPsdString().trim(); // logger.finest("PsdDescriptor.key: " + key); // objects.put(key, PsdObjectFactory.loadPsdObject(stream)); // } // } // // /** // * Gets the class id. // * // * @return the class id // */ // public String getClassId() { // return classId; // } // // /** // * Gets the objects. // * // * @return the objects // */ // public Map<String, PsdObject> getObjects() { // return objects; // } // // /** // * Gets the. // * // * @param key the key // * @return the psd object // */ // public PsdObject get(String key) { // return objects.get(key); // } // // /** // * Contains key. // * // * @param key the key // * @return true, if successful // */ // public boolean containsKey(String key) { // return objects.containsKey(key); // } // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // @Override // public String toString() { // return "Objc:" + objects.toString(); // } // // } // Path: psd-parser/src/psd/parser/layer/additional/LayerTypeToolHandler.java import psd.parser.object.PsdDescriptor; package psd.parser.layer.additional; public interface LayerTypeToolHandler { public void typeToolTransformParsed(Matrix transform);
public void typeToolDescriptorParsed(int version, PsdDescriptor descriptor);
inevo/java-psd-library
psd-parser/src/psd/parser/layer/additional/effects/BevelEffect.java
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // }
import psd.parser.BlendMode; import java.awt.*;
package psd.parser.layer.additional.effects; public class BevelEffect extends PSDEffect { private int angle; private int strength; private int blur;
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // Path: psd-parser/src/psd/parser/layer/additional/effects/BevelEffect.java import psd.parser.BlendMode; import java.awt.*; package psd.parser.layer.additional.effects; public class BevelEffect extends PSDEffect { private int angle; private int strength; private int blur;
private BlendMode blendMode;
inevo/java-psd-library
psd-tool/src/psdtool/MainFrame.java
// Path: psd-image/src/psd/Psd.java // public class Psd implements LayersContainer { // private Header header; // private List<Layer> layers = new ArrayList<Layer>(); // private Layer baseLayer; // private String name; // // public Psd(InputStream stream) throws IOException { // name = "unknown name"; // // PsdFileParser parser = new PsdFileParser(); // parser.getHeaderSectionParser().setHandler(new HeaderSectionHandler() { // @Override // public void headerLoaded(Header header) { // Psd.this.header = header; // } // }); // // final List<Layer> fullLayersList = new ArrayList<Layer>(); // parser.getLayersSectionParser().setHandler(new LayersSectionHandler() { // @Override // public void createLayer(LayerParser parser) { // fullLayersList.add(new Layer(parser)); // } // // @Override // public void createBaseLayer(LayerParser parser) { // baseLayer = new Layer(parser); // if (fullLayersList.isEmpty()) { // fullLayersList.add(baseLayer); // } // } // }); // // parser.parse(stream); // // layers = makeLayersHierarchy(fullLayersList); // } // // public Psd(File psdFile) throws IOException { // name = psdFile.getName(); // // PsdFileParser parser = new PsdFileParser(); // parser.getHeaderSectionParser().setHandler(new HeaderSectionHandler() { // @Override // public void headerLoaded(Header header) { // Psd.this.header = header; // } // }); // // final List<Layer> fullLayersList = new ArrayList<Layer>(); // parser.getLayersSectionParser().setHandler(new LayersSectionHandler() { // @Override // public void createLayer(LayerParser parser) { // fullLayersList.add(new Layer(parser)); // } // // @Override // public void createBaseLayer(LayerParser parser) { // baseLayer = new Layer(parser); // if (fullLayersList.isEmpty()) { // fullLayersList.add(baseLayer); // } // } // }); // // BufferedInputStream stream = new BufferedInputStream(new FileInputStream(psdFile)); // parser.parse(stream); // stream.close(); // // layers = makeLayersHierarchy(fullLayersList); // } // // private List<Layer> makeLayersHierarchy(List<Layer> layers) { // LinkedList<LinkedList<Layer>> layersStack = new LinkedList<LinkedList<Layer>>(); // ArrayList<Layer> rootLayers = new ArrayList<Layer>(); // for (Layer layer : layers) { // switch (layer.getType()) { // case HIDDEN: { // layersStack.addFirst(new LinkedList<Layer>()); // break; // } // case FOLDER: { // assert !layersStack.isEmpty(); // LinkedList<Layer> folderLayers = layersStack.removeFirst(); // for (Layer l : folderLayers) { // layer.addLayer(l); // } // } // // break isn't needed // case NORMAL: { // if (layersStack.isEmpty()) { // rootLayers.add(layer); // } else { // layersStack.getFirst().add(layer); // } // break; // } // default: // assert false; // } // } // return rootLayers; // } // // public int getWidth() { // return header.getWidth(); // } // // public int getHeight() { // return header.getHeight(); // } // // public int getChannelsCount() { // return header.getChannelsCount(); // } // // public int getDepth(){ // return header.getDepth(); // } // // public ColorMode getColorMode() { // return header.getColorMode(); // } // // @Override // public Layer getLayer(int index) { // return layers.get(index); // } // // @Override // public int indexOfLayer(Layer layer) { // return layers.indexOf(layer); // } // // @Override // public int getLayersCount() { // return layers.size(); // } // // @Override // public String toString() { // return name; // } // // public Layer getBaseLayer() { // return this.baseLayer; // } // }
import psd.Psd; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.io.File; import java.io.FilenameFilter; import java.io.IOException;
JMenu fileMenu = new JMenu("File"); fileMenu.add(new OpenFileAction()).setAccelerator(KeyStroke.getKeyStroke("meta O")); bar.add(fileMenu); return bar; } private class OpenFileAction extends AbstractAction { private static final long serialVersionUID = 1L; public OpenFileAction() { super("Open file"); } @Override public void actionPerformed(ActionEvent e) { FileDialog fileDialog = new FileDialog(frame, "Open psd file", FileDialog.LOAD); fileDialog.setDirectory("~/Downloads"); fileDialog.setFilenameFilter(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".psd"); } }); fileDialog.setVisible(true); if (fileDialog.getFile() != null) { File directory = new File(fileDialog.getDirectory()); File psdFile = new File(directory, fileDialog.getFile()); try {
// Path: psd-image/src/psd/Psd.java // public class Psd implements LayersContainer { // private Header header; // private List<Layer> layers = new ArrayList<Layer>(); // private Layer baseLayer; // private String name; // // public Psd(InputStream stream) throws IOException { // name = "unknown name"; // // PsdFileParser parser = new PsdFileParser(); // parser.getHeaderSectionParser().setHandler(new HeaderSectionHandler() { // @Override // public void headerLoaded(Header header) { // Psd.this.header = header; // } // }); // // final List<Layer> fullLayersList = new ArrayList<Layer>(); // parser.getLayersSectionParser().setHandler(new LayersSectionHandler() { // @Override // public void createLayer(LayerParser parser) { // fullLayersList.add(new Layer(parser)); // } // // @Override // public void createBaseLayer(LayerParser parser) { // baseLayer = new Layer(parser); // if (fullLayersList.isEmpty()) { // fullLayersList.add(baseLayer); // } // } // }); // // parser.parse(stream); // // layers = makeLayersHierarchy(fullLayersList); // } // // public Psd(File psdFile) throws IOException { // name = psdFile.getName(); // // PsdFileParser parser = new PsdFileParser(); // parser.getHeaderSectionParser().setHandler(new HeaderSectionHandler() { // @Override // public void headerLoaded(Header header) { // Psd.this.header = header; // } // }); // // final List<Layer> fullLayersList = new ArrayList<Layer>(); // parser.getLayersSectionParser().setHandler(new LayersSectionHandler() { // @Override // public void createLayer(LayerParser parser) { // fullLayersList.add(new Layer(parser)); // } // // @Override // public void createBaseLayer(LayerParser parser) { // baseLayer = new Layer(parser); // if (fullLayersList.isEmpty()) { // fullLayersList.add(baseLayer); // } // } // }); // // BufferedInputStream stream = new BufferedInputStream(new FileInputStream(psdFile)); // parser.parse(stream); // stream.close(); // // layers = makeLayersHierarchy(fullLayersList); // } // // private List<Layer> makeLayersHierarchy(List<Layer> layers) { // LinkedList<LinkedList<Layer>> layersStack = new LinkedList<LinkedList<Layer>>(); // ArrayList<Layer> rootLayers = new ArrayList<Layer>(); // for (Layer layer : layers) { // switch (layer.getType()) { // case HIDDEN: { // layersStack.addFirst(new LinkedList<Layer>()); // break; // } // case FOLDER: { // assert !layersStack.isEmpty(); // LinkedList<Layer> folderLayers = layersStack.removeFirst(); // for (Layer l : folderLayers) { // layer.addLayer(l); // } // } // // break isn't needed // case NORMAL: { // if (layersStack.isEmpty()) { // rootLayers.add(layer); // } else { // layersStack.getFirst().add(layer); // } // break; // } // default: // assert false; // } // } // return rootLayers; // } // // public int getWidth() { // return header.getWidth(); // } // // public int getHeight() { // return header.getHeight(); // } // // public int getChannelsCount() { // return header.getChannelsCount(); // } // // public int getDepth(){ // return header.getDepth(); // } // // public ColorMode getColorMode() { // return header.getColorMode(); // } // // @Override // public Layer getLayer(int index) { // return layers.get(index); // } // // @Override // public int indexOfLayer(Layer layer) { // return layers.indexOf(layer); // } // // @Override // public int getLayersCount() { // return layers.size(); // } // // @Override // public String toString() { // return name; // } // // public Layer getBaseLayer() { // return this.baseLayer; // } // } // Path: psd-tool/src/psdtool/MainFrame.java import psd.Psd; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; JMenu fileMenu = new JMenu("File"); fileMenu.add(new OpenFileAction()).setAccelerator(KeyStroke.getKeyStroke("meta O")); bar.add(fileMenu); return bar; } private class OpenFileAction extends AbstractAction { private static final long serialVersionUID = 1L; public OpenFileAction() { super("Open file"); } @Override public void actionPerformed(ActionEvent e) { FileDialog fileDialog = new FileDialog(frame, "Open psd file", FileDialog.LOAD); fileDialog.setDirectory("~/Downloads"); fileDialog.setFilenameFilter(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".psd"); } }); fileDialog.setVisible(true); if (fileDialog.getFile() != null) { File directory = new File(fileDialog.getDirectory()); File psdFile = new File(directory, fileDialog.getFile()); try {
Psd psd = new Psd(psdFile);
inevo/java-psd-library
psd-image/src/psd/Layer.java
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // // Path: psd-parser/src/psd/parser/layer/additional/effects/PSDEffect.java // public abstract class PSDEffect { // // protected String name; // protected boolean isEnabled; // protected int version; // // public PSDEffect(String name){ // this.name = name; // } // // public PSDEffect() {} // // public String getName() { // return name; // } // // public boolean isEnabled() { // return isEnabled; // } // // public void setName(String name) { // this.name = name; // } // // public void setEnabled(boolean enabled){ // this.isEnabled = enabled; // } // // public void setVersion(int version) { // this.version = version; // } // // public int getVersion() { // return version; // } // }
import psd.parser.BlendMode; import psd.parser.layer.*; import psd.parser.layer.additional.*; import psd.parser.layer.additional.effects.PSDEffect; import psd.util.BufferedImageBuilder; import java.awt.image.*; import java.util.*;
/* * This file is part of java-psd-library. * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ package psd; public class Layer implements LayersContainer { private int top = 0; private int left = 0; private int bottom = 0; private int right = 0; private int alpha = 255; private boolean visible = true; private boolean clippingLoaded; private String name; private BufferedImage image; private LayerType type = LayerType.NORMAL;
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // // Path: psd-parser/src/psd/parser/layer/additional/effects/PSDEffect.java // public abstract class PSDEffect { // // protected String name; // protected boolean isEnabled; // protected int version; // // public PSDEffect(String name){ // this.name = name; // } // // public PSDEffect() {} // // public String getName() { // return name; // } // // public boolean isEnabled() { // return isEnabled; // } // // public void setName(String name) { // this.name = name; // } // // public void setEnabled(boolean enabled){ // this.isEnabled = enabled; // } // // public void setVersion(int version) { // this.version = version; // } // // public int getVersion() { // return version; // } // } // Path: psd-image/src/psd/Layer.java import psd.parser.BlendMode; import psd.parser.layer.*; import psd.parser.layer.additional.*; import psd.parser.layer.additional.effects.PSDEffect; import psd.util.BufferedImageBuilder; import java.awt.image.*; import java.util.*; /* * This file is part of java-psd-library. * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ package psd; public class Layer implements LayersContainer { private int top = 0; private int left = 0; private int bottom = 0; private int right = 0; private int alpha = 255; private boolean visible = true; private boolean clippingLoaded; private String name; private BufferedImage image; private LayerType type = LayerType.NORMAL;
private BlendMode layerBlendMode;
inevo/java-psd-library
psd-image/src/psd/Layer.java
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // // Path: psd-parser/src/psd/parser/layer/additional/effects/PSDEffect.java // public abstract class PSDEffect { // // protected String name; // protected boolean isEnabled; // protected int version; // // public PSDEffect(String name){ // this.name = name; // } // // public PSDEffect() {} // // public String getName() { // return name; // } // // public boolean isEnabled() { // return isEnabled; // } // // public void setName(String name) { // this.name = name; // } // // public void setEnabled(boolean enabled){ // this.isEnabled = enabled; // } // // public void setVersion(int version) { // this.version = version; // } // // public int getVersion() { // return version; // } // }
import psd.parser.BlendMode; import psd.parser.layer.*; import psd.parser.layer.additional.*; import psd.parser.layer.additional.effects.PSDEffect; import psd.util.BufferedImageBuilder; import java.awt.image.*; import java.util.*;
/* * This file is part of java-psd-library. * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ package psd; public class Layer implements LayersContainer { private int top = 0; private int left = 0; private int bottom = 0; private int right = 0; private int alpha = 255; private boolean visible = true; private boolean clippingLoaded; private String name; private BufferedImage image; private LayerType type = LayerType.NORMAL; private BlendMode layerBlendMode; private BlendingRanges layerBlendingRanges; private Mask mask; private ArrayList<Layer> layers = new ArrayList<Layer>();
// Path: psd-parser/src/psd/parser/BlendMode.java // public enum BlendMode { // NORMAL("norm"), // DISSOLVE("diss"), // DARKEN("dark"), // MULTIPLY("mul "), // COLOR_BURN("idiv"), // LINEAR_BURN("lbrn"), // LIGHTEN("lite"), // SCREEN("scrn"), // COLOR_DODGE("div "), // LINEAR_DODGE("lddg"), // OVERLAY("over"), // SOFT_LIGHT("sLit"), // HARD_LIGHT("hLit"), // VIVID_LIGHT("vLit"), // LINEAR_LIGHT("lLit"), // PIN_LIGHT("pLit"), // HARD_MIX("hMix"), // DIFFERENCE("diff"), // EXCLUSION("smud"), // HUE("hue "), // SATURATION("sat "), // COLOR("colr"), // LUMINOSITY("lum "), // PASS_THROUGH("pass"); // // private String name; // // private BlendMode(String name) { // this.name = name; // } // // public static BlendMode getByName(String name) { // for (BlendMode mode : values()) { // if (mode.name.equals(name)) { // return mode; // } // } // return null; // } // // } // // Path: psd-parser/src/psd/parser/layer/additional/effects/PSDEffect.java // public abstract class PSDEffect { // // protected String name; // protected boolean isEnabled; // protected int version; // // public PSDEffect(String name){ // this.name = name; // } // // public PSDEffect() {} // // public String getName() { // return name; // } // // public boolean isEnabled() { // return isEnabled; // } // // public void setName(String name) { // this.name = name; // } // // public void setEnabled(boolean enabled){ // this.isEnabled = enabled; // } // // public void setVersion(int version) { // this.version = version; // } // // public int getVersion() { // return version; // } // } // Path: psd-image/src/psd/Layer.java import psd.parser.BlendMode; import psd.parser.layer.*; import psd.parser.layer.additional.*; import psd.parser.layer.additional.effects.PSDEffect; import psd.util.BufferedImageBuilder; import java.awt.image.*; import java.util.*; /* * This file is part of java-psd-library. * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/>. */ package psd; public class Layer implements LayersContainer { private int top = 0; private int left = 0; private int bottom = 0; private int right = 0; private int alpha = 255; private boolean visible = true; private boolean clippingLoaded; private String name; private BufferedImage image; private LayerType type = LayerType.NORMAL; private BlendMode layerBlendMode; private BlendingRanges layerBlendingRanges; private Mask mask; private ArrayList<Layer> layers = new ArrayList<Layer>();
private ArrayList<PSDEffect> layerEffects = new ArrayList<PSDEffect>();
inevo/java-psd-library
psd-parser/src/psd/parser/layer/additional/LayerIdParser.java
// Path: psd-parser/src/psd/parser/PsdInputStream.java // public class PsdInputStream extends InputStream { // // private int pos; // private int markPos; // private final DataInputStream in; // // public PsdInputStream(InputStream in) { // this.in = new DataInputStream(in); // pos = 0; // markPos = 0; // } // // @Override // public int available() throws IOException { // return in.available(); // } // // @Override // public void close() throws IOException { // in.close(); // } // // @Override // public synchronized void mark(int readlimit) { // in.mark(readlimit); // markPos = pos; // } // // @Override // public synchronized void reset() throws IOException { // in.reset(); // pos = markPos; // } // // @Override // public boolean markSupported() { // return in.markSupported(); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // int res = in.read(b, off, len); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read(byte[] b) throws IOException { // int res = in.read(b); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read() throws IOException { // int res = in.read(); // if (res != -1) { // pos++; // } // return res; // } // // @Override // public long skip(long n) throws IOException { // long skip = in.skip(n); // pos += skip; // return skip; // } // // public String readString(int len) throws IOException { // // read string of specified length // byte[] bytes = new byte[len]; // read(bytes); // return new String(bytes, "ISO-8859-1"); // } // // public String readPsdString() throws IOException { // int size = readInt(); // if (size == 0) { // size = 4; // } // return readString(size); // } // // public int readBytes(byte[] bytes, int n) throws IOException { // // read multiple bytes from input // if (bytes == null) // return 0; // int r = 0; // r = read(bytes, 0, n); // if (r < n) { // throw new IOException("format error. readed=" + r + " needed=" + n); // } // return r; // } // // public byte readByte() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (byte) (ch); // } // // public int readUnsignedByte() throws IOException { // int res = in.readUnsignedByte(); // if (res != -1) { // pos++; // } // return res; // } // // public short readShort() throws IOException { // int ch1 = read(); // int ch2 = read(); // if ((ch1 | ch2) < 0) { // throw new EOFException(); // } // return (short) ((ch1 << 8) + (ch2 << 0)); // } // // public int readInt() throws IOException { // int ch1 = read(); // int ch2 = read(); // int ch3 = read(); // int ch4 = read(); // if ((ch1 | ch2 | ch3 | ch4) < 0) { // throw new EOFException(); // } // return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); // } // // public boolean readBoolean() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (ch != 0); // } // // public final long readLong() throws IOException { // int c1 = read(); // int c2 = read(); // int c3 = read(); // int c4 = read(); // int c5 = read(); // int c6 = read(); // int c7 = read(); // int c8 = read(); // return (((long) c1 << 56) + ((long) (c2 & 255) << 48) // + ((long) (c3 & 255) << 40) + ((long) (c4 & 255) << 32) // + ((long) (c5 & 255) << 24) + ((c6 & 255) << 16) // + ((c7 & 255) << 8) + (c8 & 255)); // } // // public final double readDouble() throws IOException { // return Double.longBitsToDouble(readLong()); // } // // public int skipBytes(int n) throws IOException { // int total = 0; // int cur; // while ((total < n) && ((cur = (int) skip(n - total)) > 0)) { // total += cur; // } // return total; // } // // public int getPos() { // return pos; // } // // } // // Path: psd-parser/src/psd/parser/layer/LayerAdditionalInformationParser.java // public interface LayerAdditionalInformationParser { // public void parse(PsdInputStream stream, String tag, int size) throws IOException; // }
import java.io.IOException; import psd.parser.PsdInputStream; import psd.parser.layer.LayerAdditionalInformationParser;
package psd.parser.layer.additional; public class LayerIdParser implements LayerAdditionalInformationParser { public static final String TAG = "lyid"; private final LayerIdHandler handler; public LayerIdParser(LayerIdHandler handler) { this.handler = handler; } @Override
// Path: psd-parser/src/psd/parser/PsdInputStream.java // public class PsdInputStream extends InputStream { // // private int pos; // private int markPos; // private final DataInputStream in; // // public PsdInputStream(InputStream in) { // this.in = new DataInputStream(in); // pos = 0; // markPos = 0; // } // // @Override // public int available() throws IOException { // return in.available(); // } // // @Override // public void close() throws IOException { // in.close(); // } // // @Override // public synchronized void mark(int readlimit) { // in.mark(readlimit); // markPos = pos; // } // // @Override // public synchronized void reset() throws IOException { // in.reset(); // pos = markPos; // } // // @Override // public boolean markSupported() { // return in.markSupported(); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // int res = in.read(b, off, len); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read(byte[] b) throws IOException { // int res = in.read(b); // if (res != -1) { // pos += res; // } // return res; // } // // @Override // public int read() throws IOException { // int res = in.read(); // if (res != -1) { // pos++; // } // return res; // } // // @Override // public long skip(long n) throws IOException { // long skip = in.skip(n); // pos += skip; // return skip; // } // // public String readString(int len) throws IOException { // // read string of specified length // byte[] bytes = new byte[len]; // read(bytes); // return new String(bytes, "ISO-8859-1"); // } // // public String readPsdString() throws IOException { // int size = readInt(); // if (size == 0) { // size = 4; // } // return readString(size); // } // // public int readBytes(byte[] bytes, int n) throws IOException { // // read multiple bytes from input // if (bytes == null) // return 0; // int r = 0; // r = read(bytes, 0, n); // if (r < n) { // throw new IOException("format error. readed=" + r + " needed=" + n); // } // return r; // } // // public byte readByte() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (byte) (ch); // } // // public int readUnsignedByte() throws IOException { // int res = in.readUnsignedByte(); // if (res != -1) { // pos++; // } // return res; // } // // public short readShort() throws IOException { // int ch1 = read(); // int ch2 = read(); // if ((ch1 | ch2) < 0) { // throw new EOFException(); // } // return (short) ((ch1 << 8) + (ch2 << 0)); // } // // public int readInt() throws IOException { // int ch1 = read(); // int ch2 = read(); // int ch3 = read(); // int ch4 = read(); // if ((ch1 | ch2 | ch3 | ch4) < 0) { // throw new EOFException(); // } // return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); // } // // public boolean readBoolean() throws IOException { // int ch = read(); // if (ch < 0) { // throw new EOFException(); // } // return (ch != 0); // } // // public final long readLong() throws IOException { // int c1 = read(); // int c2 = read(); // int c3 = read(); // int c4 = read(); // int c5 = read(); // int c6 = read(); // int c7 = read(); // int c8 = read(); // return (((long) c1 << 56) + ((long) (c2 & 255) << 48) // + ((long) (c3 & 255) << 40) + ((long) (c4 & 255) << 32) // + ((long) (c5 & 255) << 24) + ((c6 & 255) << 16) // + ((c7 & 255) << 8) + (c8 & 255)); // } // // public final double readDouble() throws IOException { // return Double.longBitsToDouble(readLong()); // } // // public int skipBytes(int n) throws IOException { // int total = 0; // int cur; // while ((total < n) && ((cur = (int) skip(n - total)) > 0)) { // total += cur; // } // return total; // } // // public int getPos() { // return pos; // } // // } // // Path: psd-parser/src/psd/parser/layer/LayerAdditionalInformationParser.java // public interface LayerAdditionalInformationParser { // public void parse(PsdInputStream stream, String tag, int size) throws IOException; // } // Path: psd-parser/src/psd/parser/layer/additional/LayerIdParser.java import java.io.IOException; import psd.parser.PsdInputStream; import psd.parser.layer.LayerAdditionalInformationParser; package psd.parser.layer.additional; public class LayerIdParser implements LayerAdditionalInformationParser { public static final String TAG = "lyid"; private final LayerIdHandler handler; public LayerIdParser(LayerIdHandler handler) { this.handler = handler; } @Override
public void parse(PsdInputStream stream, String tag, int size) throws IOException {
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditActionAcitvity.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // }
import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView;
package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditActionAcitvity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private ListView lvAction;
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditActionAcitvity.java import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView; package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditActionAcitvity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private ListView lvAction;
private ArrayList<GosScheduleCheckBoxListDateHolder> actionDates;
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditActionAcitvity.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // }
import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView;
package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditActionAcitvity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private ListView lvAction; private ArrayList<GosScheduleCheckBoxListDateHolder> actionDates; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comd_schedule_edit_action); initDate(); initView(); initEvent(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { setResult(RESULT_OK, null); finish(); } return false; } private void initEvent() { tvBack.setOnClickListener(this);
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditActionAcitvity.java import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView; package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditActionAcitvity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private ListView lvAction; private ArrayList<GosScheduleCheckBoxListDateHolder> actionDates; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comd_schedule_edit_action); initDate(); initView(); initEvent(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { setResult(RESULT_OK, null); finish(); } return false; } private void initEvent() { tvBack.setOnClickListener(this);
final GosScheduleCheckBoxListAdapter mAdapter = new GosScheduleCheckBoxListAdapter(this, actionDates);
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/view/ColorTempCircularSeekBar.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/utils/DensityUtils.java // public class DensityUtils { // // // /** // * dp转px // * // * @param context // * 上下文 // * @param dpVal // * dp值 // * @return px值 // * // * */ // public static int dp2px(Context context, float dpVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, // dpVal, context.getResources().getDisplayMetrics()); // } // // /** // * sp转px // * // * @param context // * 上下文 // * @param spVal // * sp值 // * @return px值 // * // * */ // public static int sp2px(Context context, float spVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, // spVal, context.getResources().getDisplayMetrics()); // } // // /** // * px转dp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return dp值 // * // * */ // public static float px2dp(Context context, float pxVal) // { // final float scale = context.getResources().getDisplayMetrics().density; // return (pxVal / scale); // } // // /** // * px转sp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return sp值 // * // * */ // public static float px2sp(Context context, float pxVal) // { // return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); // } // // // // }
import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.utils.DensityUtils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.SweepGradient; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View;
super(context); // TODO Auto-generated constructor stub mContext = context; initDrawable(); } /** * Inits the drawable. */ public void initDrawable() { // progressMark = BitmapFactory.decodeResource(mContext.getResources(), // R.drawable.comd1_light_sewen_bg2); // progressMarkPressed = BitmapFactory.decodeResource( // mContext.getResources(), R.drawable.comd1_light_sewen_bg2); progressMark = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); progressMarkPressed = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); } /* * (non-Javadoc) * * @see android.view.View#onMeasure(int, int) */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Path: src/com/gizwits/opensource/devicecontrol/ui/utils/DensityUtils.java // public class DensityUtils { // // // /** // * dp转px // * // * @param context // * 上下文 // * @param dpVal // * dp值 // * @return px值 // * // * */ // public static int dp2px(Context context, float dpVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, // dpVal, context.getResources().getDisplayMetrics()); // } // // /** // * sp转px // * // * @param context // * 上下文 // * @param spVal // * sp值 // * @return px值 // * // * */ // public static int sp2px(Context context, float spVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, // spVal, context.getResources().getDisplayMetrics()); // } // // /** // * px转dp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return dp值 // * // * */ // public static float px2dp(Context context, float pxVal) // { // final float scale = context.getResources().getDisplayMetrics().density; // return (pxVal / scale); // } // // /** // * px转sp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return sp值 // * // * */ // public static float px2sp(Context context, float pxVal) // { // return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); // } // // // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/view/ColorTempCircularSeekBar.java import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.utils.DensityUtils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.SweepGradient; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; super(context); // TODO Auto-generated constructor stub mContext = context; initDrawable(); } /** * Inits the drawable. */ public void initDrawable() { // progressMark = BitmapFactory.decodeResource(mContext.getResources(), // R.drawable.comd1_light_sewen_bg2); // progressMarkPressed = BitmapFactory.decodeResource( // mContext.getResources(), R.drawable.comd1_light_sewen_bg2); progressMark = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); progressMarkPressed = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); } /* * (non-Javadoc) * * @see android.view.View#onMeasure(int, int) */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);
barWidth = DensityUtils.dp2px(getContext(), 10);
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditRepeatActivity.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // }
import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView;
package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditRepeatActivity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private TextView tvSave; private ListView lvRepeat; private String repeat;
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditRepeatActivity.java import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView; package com.gizwits.opensource.devicecontrol.ui.activity; public class GosScheduleEditRepeatActivity extends GosDeviceControlModuleBaseActivity implements OnClickListener { private TextView tvBack; private TextView tvSave; private ListView lvRepeat; private String repeat;
private ArrayList<GosScheduleCheckBoxListDateHolder> repeatDates = new ArrayList<GosScheduleCheckBoxListDateHolder>();
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditRepeatActivity.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // }
import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView;
tvBack.setOnClickListener(this); tvSave.setOnClickListener(this); } private void initView() { tvBack = (TextView) findViewById(R.id.tv_back); tvSave = (TextView) findViewById(R.id.tv_save); lvRepeat = (ListView) findViewById(R.id.lv_repeat); } private void initDate() { Intent intent = getIntent(); repeat = intent.getStringExtra("repeat"); String[] week = { "sun", "mon", "tue", "wed", "thu", "fri", "sat"}; String[] itemNames = { getResources().getString(R.string.apm_every_sun),getResources().getString(R.string.apm_every_mon), getResources().getString(R.string.apm_every_tue), getResources().getString(R.string.apm_every_wed), getResources().getString(R.string.apm_every_thu), getResources().getString(R.string.apm_every_fri), getResources().getString(R.string.apm_every_sat) }; for (int i = 0; i < itemNames.length; i++) { String itemName = itemNames[i]; Boolean checked = false; if (repeat.contains(week[i])) { checked = true; } GosScheduleCheckBoxListDateHolder item = new GosScheduleCheckBoxListDateHolder(itemName, checked); repeatDates.add(item); } } private void UpdateUI() {
// Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListAdapter.java // public class GosScheduleCheckBoxListAdapter extends BaseAdapter { // // ArrayList<GosScheduleCheckBoxListDateHolder> items; // private LayoutInflater mInflater; // // public GosScheduleCheckBoxListAdapter(Context context, ArrayList<GosScheduleCheckBoxListDateHolder> items) { // super(); // this.items = items; // mInflater = LayoutInflater.from(context); // } // // @Override // public int getCount() { // return items.size(); // } // // @Override // public Object getItem(int position) { // // TODO Auto-generated method stub // return items.get(position); // } // // @Override // public long getItemId(int position) { // return position; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // View view; // if (convertView == null) { // view = mInflater.inflate(R.layout.item_comd_listview_with_checkbox, null); // } else { // view = convertView; // } // TextView itemName = (TextView) view.findViewById(R.id.tv_item); // CheckBox checkBox = (CheckBox) view.findViewById(R.id.cb_date); // itemName.setText(items.get(position).itemName); // checkBox.setChecked(items.get(position).checked); // return view; // } // // } // // Path: src/com/gizwits/opensource/devicecontrol/ui/adapter/GosScheduleCheckBoxListDateHolder.java // public class GosScheduleCheckBoxListDateHolder { // // public String itemName; // public boolean checked; // // /** // * @param itemName // * @param checked // */ // public GosScheduleCheckBoxListDateHolder(String itemName, boolean checked) { // super(); // this.itemName = itemName; // this.checked = checked; // } // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/activity/GosScheduleEditRepeatActivity.java import java.util.ArrayList; import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListAdapter; import com.gizwits.opensource.devicecontrol.ui.adapter.GosScheduleCheckBoxListDateHolder; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.TextView; tvBack.setOnClickListener(this); tvSave.setOnClickListener(this); } private void initView() { tvBack = (TextView) findViewById(R.id.tv_back); tvSave = (TextView) findViewById(R.id.tv_save); lvRepeat = (ListView) findViewById(R.id.lv_repeat); } private void initDate() { Intent intent = getIntent(); repeat = intent.getStringExtra("repeat"); String[] week = { "sun", "mon", "tue", "wed", "thu", "fri", "sat"}; String[] itemNames = { getResources().getString(R.string.apm_every_sun),getResources().getString(R.string.apm_every_mon), getResources().getString(R.string.apm_every_tue), getResources().getString(R.string.apm_every_wed), getResources().getString(R.string.apm_every_thu), getResources().getString(R.string.apm_every_fri), getResources().getString(R.string.apm_every_sat) }; for (int i = 0; i < itemNames.length; i++) { String itemName = itemNames[i]; Boolean checked = false; if (repeat.contains(week[i])) { checked = true; } GosScheduleCheckBoxListDateHolder item = new GosScheduleCheckBoxListDateHolder(itemName, checked); repeatDates.add(item); } } private void UpdateUI() {
final GosScheduleCheckBoxListAdapter mAdapter = new GosScheduleCheckBoxListAdapter(this, repeatDates);
gizwits/Gizwits-SmartBuld_Android
src/com/gizwits/opensource/devicecontrol/ui/view/ColorCircularSeekBar.java
// Path: src/com/gizwits/opensource/devicecontrol/ui/utils/DensityUtils.java // public class DensityUtils { // // // /** // * dp转px // * // * @param context // * 上下文 // * @param dpVal // * dp值 // * @return px值 // * // * */ // public static int dp2px(Context context, float dpVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, // dpVal, context.getResources().getDisplayMetrics()); // } // // /** // * sp转px // * // * @param context // * 上下文 // * @param spVal // * sp值 // * @return px值 // * // * */ // public static int sp2px(Context context, float spVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, // spVal, context.getResources().getDisplayMetrics()); // } // // /** // * px转dp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return dp值 // * // * */ // public static float px2dp(Context context, float pxVal) // { // final float scale = context.getResources().getDisplayMetrics().density; // return (pxVal / scale); // } // // /** // * px转sp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return sp值 // * // * */ // public static float px2sp(Context context, float pxVal) // { // return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); // } // // // // }
import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.utils.DensityUtils; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.SweepGradient; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View;
public ColorCircularSeekBar(Context context) { super(context); // TODO Auto-generated constructor stub mContext = context; initDrawable(); } /** * Inits the drawable. */ public void initDrawable() { // progressMark = BitmapFactory.decodeResource(mContext.getResources(), // R.drawable.comd1_light_sewen_bg2); // progressMarkPressed = BitmapFactory.decodeResource( // mContext.getResources(), R.drawable.comd1_light_sewen_bg2); progressMark = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); progressMarkPressed = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); } /* * (non-Javadoc) * * @see android.view.View#onMeasure(int, int) */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Path: src/com/gizwits/opensource/devicecontrol/ui/utils/DensityUtils.java // public class DensityUtils { // // // /** // * dp转px // * // * @param context // * 上下文 // * @param dpVal // * dp值 // * @return px值 // * // * */ // public static int dp2px(Context context, float dpVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, // dpVal, context.getResources().getDisplayMetrics()); // } // // /** // * sp转px // * // * @param context // * 上下文 // * @param spVal // * sp值 // * @return px值 // * // * */ // public static int sp2px(Context context, float spVal) // { // return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, // spVal, context.getResources().getDisplayMetrics()); // } // // /** // * px转dp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return dp值 // * // * */ // public static float px2dp(Context context, float pxVal) // { // final float scale = context.getResources().getDisplayMetrics().density; // return (pxVal / scale); // } // // /** // * px转sp // * // * @param context // * 上下文 // * @param pxVal // * px值 // * @return sp值 // * // * */ // public static float px2sp(Context context, float pxVal) // { // return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); // } // // // // } // Path: src/com/gizwits/opensource/devicecontrol/ui/view/ColorCircularSeekBar.java import com.gizwits.opensource.smartlight.R; import com.gizwits.opensource.devicecontrol.ui.utils.DensityUtils; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.SweepGradient; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; public ColorCircularSeekBar(Context context) { super(context); // TODO Auto-generated constructor stub mContext = context; initDrawable(); } /** * Inits the drawable. */ public void initDrawable() { // progressMark = BitmapFactory.decodeResource(mContext.getResources(), // R.drawable.comd1_light_sewen_bg2); // progressMarkPressed = BitmapFactory.decodeResource( // mContext.getResources(), R.drawable.comd1_light_sewen_bg2); progressMark = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); progressMarkPressed = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.test_comd1_light_sewen_bg2); } /* * (non-Javadoc) * * @see android.view.View#onMeasure(int, int) */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);
barWidth = DensityUtils.dp2px(getContext(), 10);
Martin20150405/Pano360
filepicker/src/main/java/com/nbsp/materialfilepicker/ui/DirectoryFragment.java
// Path: filepicker/src/main/java/com/nbsp/materialfilepicker/widget/EmptyRecyclerView.java // public class EmptyRecyclerView extends RecyclerView { // @Nullable // View mEmptyView; // // public EmptyRecyclerView(Context context) { super(context); } // // public EmptyRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); } // // public EmptyRecyclerView(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // void checkIfEmpty() { // if (mEmptyView != null) { // mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE); // } // } // // final @NonNull // AdapterDataObserver observer = new AdapterDataObserver() { // @Override public void onChanged() { // super.onChanged(); // checkIfEmpty(); // } // }; // // @Override public void setAdapter(@Nullable Adapter adapter) { // final Adapter oldAdapter = getAdapter(); // if (oldAdapter != null) { // oldAdapter.unregisterAdapterDataObserver(observer); // } // super.setAdapter(adapter); // if (adapter != null) { // adapter.registerAdapterDataObserver(observer); // } // } // // public void setEmptyView(@Nullable View mEmptyView) { // this.mEmptyView = mEmptyView; // checkIfEmpty(); // } // }
import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import com.nbsp.materialfilepicker.R; import com.nbsp.materialfilepicker.filter.CompositeFilter; import com.nbsp.materialfilepicker.utils.FileUtils; import com.nbsp.materialfilepicker.widget.EmptyRecyclerView; import java.io.File; import java.io.FileFilter; import java.util.ArrayList;
package com.nbsp.materialfilepicker.ui; /** * Created by Dimorinny on 24.10.15. */ public class DirectoryFragment extends Fragment { interface FileClickListener { void onFileClicked(File clickedFile); } private static final String ARG_FILE_PATH = "arg_file_path"; private static final String ARG_FILTER = "arg_filter"; private View mEmptyView; private String mPath; private CompositeFilter mFilter;
// Path: filepicker/src/main/java/com/nbsp/materialfilepicker/widget/EmptyRecyclerView.java // public class EmptyRecyclerView extends RecyclerView { // @Nullable // View mEmptyView; // // public EmptyRecyclerView(Context context) { super(context); } // // public EmptyRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); } // // public EmptyRecyclerView(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // void checkIfEmpty() { // if (mEmptyView != null) { // mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE); // } // } // // final @NonNull // AdapterDataObserver observer = new AdapterDataObserver() { // @Override public void onChanged() { // super.onChanged(); // checkIfEmpty(); // } // }; // // @Override public void setAdapter(@Nullable Adapter adapter) { // final Adapter oldAdapter = getAdapter(); // if (oldAdapter != null) { // oldAdapter.unregisterAdapterDataObserver(observer); // } // super.setAdapter(adapter); // if (adapter != null) { // adapter.registerAdapterDataObserver(observer); // } // } // // public void setEmptyView(@Nullable View mEmptyView) { // this.mEmptyView = mEmptyView; // checkIfEmpty(); // } // } // Path: filepicker/src/main/java/com/nbsp/materialfilepicker/ui/DirectoryFragment.java import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import com.nbsp.materialfilepicker.R; import com.nbsp.materialfilepicker.filter.CompositeFilter; import com.nbsp.materialfilepicker.utils.FileUtils; import com.nbsp.materialfilepicker.widget.EmptyRecyclerView; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; package com.nbsp.materialfilepicker.ui; /** * Created by Dimorinny on 24.10.15. */ public class DirectoryFragment extends Fragment { interface FileClickListener { void onFileClicked(File clickedFile); } private static final String ARG_FILE_PATH = "arg_file_path"; private static final String ARG_FILTER = "arg_filter"; private View mEmptyView; private String mPath; private CompositeFilter mFilter;
private EmptyRecyclerView mDirectoryRecyclerView;
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/utils/BufferUtils.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/Constants.java // public class Constants { // public static final int FLOAT_SIZE_BYTES = 4; // public static final int SHORT_SIZE_BYTES = 2; // //Sensor // public static final int SENSOR_ACC= Sensor.TYPE_ACCELEROMETER; // public static final int SENSOR_MAG=Sensor.TYPE_MAGNETIC_FIELD; // public static final int SENSOR_ROT=Sensor.TYPE_ROTATION_VECTOR; // // }
import com.martin.ads.vrlib.constant.Constants; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer;
package com.martin.ads.vrlib.utils; /** * Created by Ads on 2016/6/25. */ public class BufferUtils { public static FloatBuffer getFloatBuffer(final float[] array,int offset){ FloatBuffer bb=ByteBuffer.allocateDirect(
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/Constants.java // public class Constants { // public static final int FLOAT_SIZE_BYTES = 4; // public static final int SHORT_SIZE_BYTES = 2; // //Sensor // public static final int SENSOR_ACC= Sensor.TYPE_ACCELEROMETER; // public static final int SENSOR_MAG=Sensor.TYPE_MAGNETIC_FIELD; // public static final int SENSOR_ROT=Sensor.TYPE_ROTATION_VECTOR; // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/BufferUtils.java import com.martin.ads.vrlib.constant.Constants; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; package com.martin.ads.vrlib.utils; /** * Created by Ads on 2016/6/25. */ public class BufferUtils { public static FloatBuffer getFloatBuffer(final float[] array,int offset){ FloatBuffer bb=ByteBuffer.allocateDirect(
array.length * Constants.FLOAT_SIZE_BYTES)
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/textures/GLOESTexture.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.opengl.GLES20; import com.martin.ads.vrlib.constant.GLEtc; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.textures; /** * Created by Ads on 2016/11/19. */ public class GLOESTexture { public final static String TAG = "GLOESTexture"; private int textureId; //TODO:delete it private boolean textureLoaded; public GLOESTexture() {
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/textures/GLOESTexture.java import android.opengl.GLES20; import com.martin.ads.vrlib.constant.GLEtc; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.textures; /** * Created by Ads on 2016/11/19. */ public class GLOESTexture { public final static String TAG = "GLOESTexture"; private int textureId; //TODO:delete it private boolean textureLoaded; public GLOESTexture() {
textureId= GLEtc.NO_TEXTURE;
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/textures/GLOESTexture.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.opengl.GLES20; import com.martin.ads.vrlib.constant.GLEtc; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.textures; /** * Created by Ads on 2016/11/19. */ public class GLOESTexture { public final static String TAG = "GLOESTexture"; private int textureId; //TODO:delete it private boolean textureLoaded; public GLOESTexture() { textureId= GLEtc.NO_TEXTURE; textureLoaded=false; } //only call once for a single video texture (camera, media_decoder,etc.) public void loadTexture(){ if(textureLoaded) return; int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); textureId = textures[0]; GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/textures/GLOESTexture.java import android.opengl.GLES20; import com.martin.ads.vrlib.constant.GLEtc; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.textures; /** * Created by Ads on 2016/11/19. */ public class GLOESTexture { public final static String TAG = "GLOESTexture"; private int textureId; //TODO:delete it private boolean textureLoaded; public GLOESTexture() { textureId= GLEtc.NO_TEXTURE; textureLoaded=false; } //only call once for a single video texture (camera, media_decoder,etc.) public void loadTexture(){ if(textureLoaded) return; int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); textureId = textures[0]; GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId);
ShaderUtils.checkGlError("glBindTexture mTextureID");
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/FilterType.java // public enum FilterType { // NONE, // FILL_LIGHT_FILTER, // GREEN_HOUSE_FILTER, // BLACK_WHITE_FILTER, // PAST_TIME_FILTER, // MOON_LIGHT_FILTER, // PRINTING_FILTER, // TOY_FILTER, // BRIGHTNESS_FILTER, // VIGNETTE_FILTER, // MULTIPLY_FILTER, // REMINISCENCE_FILTER, // SUNNY_FILTER, // MX_LOMO_FILTER, // SHIFT_COLOR_FILTER, // MX_FACE_BEAUTY_FILTER, // MX_PRO_FILTER, // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/UIUtils.java // public class UIUtils // { // public static String getShowTime(long milliseconds) { // /* // // 获取日历函数 // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(milliseconds); // SimpleDateFormat dateFormat = null; // // 判断是否大于60分钟,如果大于就显示小时。设置日期格式 // if (milliseconds / 60000 > 60) { // dateFormat = new SimpleDateFormat("hh:mm:ss"); // } else { // dateFormat = new SimpleDateFormat("00:mm:ss"); // } // return dateFormat.format(calendar.getTime()); // */ // //abhiank209 (pr #10) // return String.format("%02d:%02d:%02d", // TimeUnit.MILLISECONDS.toHours(milliseconds), // TimeUnit.MILLISECONDS.toMinutes(milliseconds) - // TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds)), // TimeUnit.MILLISECONDS.toSeconds(milliseconds) - // TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds))); // } // // public static void startImageAnim(ImageView Img, int anim) // { // Img.setVisibility(View.VISIBLE); // try // { // Img.setImageResource(anim); // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.start(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // } // // public static void stopImageAnim(ImageView Img) // { // try // { // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.stop(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // Img.setVisibility(View.GONE); // } // // // //缓冲动画控制 // public static void setBufferVisibility(ImageView imgBuffer, boolean Visible) // { // if (Visible) // { // imgBuffer.setVisibility(View.VISIBLE); // startImageAnim(imgBuffer, R.drawable.loading); // } // else // { // stopImageAnim(imgBuffer); // imgBuffer.setVisibility(View.GONE); // } // } // // }
import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; import android.widget.ToggleButton; import com.martin.ads.vrlib.R; import com.martin.ads.vrlib.filters.advanced.FilterType; import com.martin.ads.vrlib.utils.UIUtils; import java.util.Timer; import java.util.TimerTask;
if(imageMode) progressToolbar.setVisibility(View.GONE); } public void hide(){ if (!visible) return; visible=false; progressToolbar.setVisibility(View.GONE); controlToolbar.setVisibility(View.GONE); } public void show(){ if (visible) return; visible=true; if(!imageMode) progressToolbar.setVisibility(View.VISIBLE); controlToolbar.setVisibility(View.VISIBLE); } public boolean isVisible() { return visible; } public interface UICallback{ void requestScreenshot(); void requestFinish(); void changeDisPlayMode(); void changeInteractiveMode(); void changePlayingStatus(); void playerSeekTo(int pos); int getPlayerDuration(); int getPlayerCurrentPosition();
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/FilterType.java // public enum FilterType { // NONE, // FILL_LIGHT_FILTER, // GREEN_HOUSE_FILTER, // BLACK_WHITE_FILTER, // PAST_TIME_FILTER, // MOON_LIGHT_FILTER, // PRINTING_FILTER, // TOY_FILTER, // BRIGHTNESS_FILTER, // VIGNETTE_FILTER, // MULTIPLY_FILTER, // REMINISCENCE_FILTER, // SUNNY_FILTER, // MX_LOMO_FILTER, // SHIFT_COLOR_FILTER, // MX_FACE_BEAUTY_FILTER, // MX_PRO_FILTER, // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/UIUtils.java // public class UIUtils // { // public static String getShowTime(long milliseconds) { // /* // // 获取日历函数 // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(milliseconds); // SimpleDateFormat dateFormat = null; // // 判断是否大于60分钟,如果大于就显示小时。设置日期格式 // if (milliseconds / 60000 > 60) { // dateFormat = new SimpleDateFormat("hh:mm:ss"); // } else { // dateFormat = new SimpleDateFormat("00:mm:ss"); // } // return dateFormat.format(calendar.getTime()); // */ // //abhiank209 (pr #10) // return String.format("%02d:%02d:%02d", // TimeUnit.MILLISECONDS.toHours(milliseconds), // TimeUnit.MILLISECONDS.toMinutes(milliseconds) - // TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds)), // TimeUnit.MILLISECONDS.toSeconds(milliseconds) - // TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds))); // } // // public static void startImageAnim(ImageView Img, int anim) // { // Img.setVisibility(View.VISIBLE); // try // { // Img.setImageResource(anim); // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.start(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // } // // public static void stopImageAnim(ImageView Img) // { // try // { // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.stop(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // Img.setVisibility(View.GONE); // } // // // //缓冲动画控制 // public static void setBufferVisibility(ImageView imgBuffer, boolean Visible) // { // if (Visible) // { // imgBuffer.setVisibility(View.VISIBLE); // startImageAnim(imgBuffer, R.drawable.loading); // } // else // { // stopImageAnim(imgBuffer); // imgBuffer.setVisibility(View.GONE); // } // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; import android.widget.ToggleButton; import com.martin.ads.vrlib.R; import com.martin.ads.vrlib.filters.advanced.FilterType; import com.martin.ads.vrlib.utils.UIUtils; import java.util.Timer; import java.util.TimerTask; if(imageMode) progressToolbar.setVisibility(View.GONE); } public void hide(){ if (!visible) return; visible=false; progressToolbar.setVisibility(View.GONE); controlToolbar.setVisibility(View.GONE); } public void show(){ if (visible) return; visible=true; if(!imageMode) progressToolbar.setVisibility(View.VISIBLE); controlToolbar.setVisibility(View.VISIBLE); } public boolean isVisible() { return visible; } public interface UICallback{ void requestScreenshot(); void requestFinish(); void changeDisPlayMode(); void changeInteractiveMode(); void changePlayingStatus(); void playerSeekTo(int pos); int getPlayerDuration(); int getPlayerCurrentPosition();
void addFilter(FilterType filterType);
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/FilterType.java // public enum FilterType { // NONE, // FILL_LIGHT_FILTER, // GREEN_HOUSE_FILTER, // BLACK_WHITE_FILTER, // PAST_TIME_FILTER, // MOON_LIGHT_FILTER, // PRINTING_FILTER, // TOY_FILTER, // BRIGHTNESS_FILTER, // VIGNETTE_FILTER, // MULTIPLY_FILTER, // REMINISCENCE_FILTER, // SUNNY_FILTER, // MX_LOMO_FILTER, // SHIFT_COLOR_FILTER, // MX_FACE_BEAUTY_FILTER, // MX_PRO_FILTER, // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/UIUtils.java // public class UIUtils // { // public static String getShowTime(long milliseconds) { // /* // // 获取日历函数 // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(milliseconds); // SimpleDateFormat dateFormat = null; // // 判断是否大于60分钟,如果大于就显示小时。设置日期格式 // if (milliseconds / 60000 > 60) { // dateFormat = new SimpleDateFormat("hh:mm:ss"); // } else { // dateFormat = new SimpleDateFormat("00:mm:ss"); // } // return dateFormat.format(calendar.getTime()); // */ // //abhiank209 (pr #10) // return String.format("%02d:%02d:%02d", // TimeUnit.MILLISECONDS.toHours(milliseconds), // TimeUnit.MILLISECONDS.toMinutes(milliseconds) - // TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds)), // TimeUnit.MILLISECONDS.toSeconds(milliseconds) - // TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds))); // } // // public static void startImageAnim(ImageView Img, int anim) // { // Img.setVisibility(View.VISIBLE); // try // { // Img.setImageResource(anim); // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.start(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // } // // public static void stopImageAnim(ImageView Img) // { // try // { // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.stop(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // Img.setVisibility(View.GONE); // } // // // //缓冲动画控制 // public static void setBufferVisibility(ImageView imgBuffer, boolean Visible) // { // if (Visible) // { // imgBuffer.setVisibility(View.VISIBLE); // startImageAnim(imgBuffer, R.drawable.loading); // } // else // { // stopImageAnim(imgBuffer); // imgBuffer.setVisibility(View.GONE); // } // } // // }
import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; import android.widget.ToggleButton; import com.martin.ads.vrlib.R; import com.martin.ads.vrlib.filters.advanced.FilterType; import com.martin.ads.vrlib.utils.UIUtils; import java.util.Timer; import java.util.TimerTask;
} public void show(){ if (visible) return; visible=true; if(!imageMode) progressToolbar.setVisibility(View.VISIBLE); controlToolbar.setVisibility(View.VISIBLE); } public boolean isVisible() { return visible; } public interface UICallback{ void requestScreenshot(); void requestFinish(); void changeDisPlayMode(); void changeInteractiveMode(); void changePlayingStatus(); void playerSeekTo(int pos); int getPlayerDuration(); int getPlayerCurrentPosition(); void addFilter(FilterType filterType); } public void setInfo(){ processSeekBar.setProgress(0); int duration=uiCallback.getPlayerDuration(); processSeekBar.setMax(duration);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/FilterType.java // public enum FilterType { // NONE, // FILL_LIGHT_FILTER, // GREEN_HOUSE_FILTER, // BLACK_WHITE_FILTER, // PAST_TIME_FILTER, // MOON_LIGHT_FILTER, // PRINTING_FILTER, // TOY_FILTER, // BRIGHTNESS_FILTER, // VIGNETTE_FILTER, // MULTIPLY_FILTER, // REMINISCENCE_FILTER, // SUNNY_FILTER, // MX_LOMO_FILTER, // SHIFT_COLOR_FILTER, // MX_FACE_BEAUTY_FILTER, // MX_PRO_FILTER, // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/UIUtils.java // public class UIUtils // { // public static String getShowTime(long milliseconds) { // /* // // 获取日历函数 // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(milliseconds); // SimpleDateFormat dateFormat = null; // // 判断是否大于60分钟,如果大于就显示小时。设置日期格式 // if (milliseconds / 60000 > 60) { // dateFormat = new SimpleDateFormat("hh:mm:ss"); // } else { // dateFormat = new SimpleDateFormat("00:mm:ss"); // } // return dateFormat.format(calendar.getTime()); // */ // //abhiank209 (pr #10) // return String.format("%02d:%02d:%02d", // TimeUnit.MILLISECONDS.toHours(milliseconds), // TimeUnit.MILLISECONDS.toMinutes(milliseconds) - // TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds)), // TimeUnit.MILLISECONDS.toSeconds(milliseconds) - // TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds))); // } // // public static void startImageAnim(ImageView Img, int anim) // { // Img.setVisibility(View.VISIBLE); // try // { // Img.setImageResource(anim); // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.start(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // } // // public static void stopImageAnim(ImageView Img) // { // try // { // AnimationDrawable animationDrawable = (AnimationDrawable) Img.getDrawable(); // animationDrawable.stop(); // } // catch (ClassCastException e) // { // e.printStackTrace(); // } // Img.setVisibility(View.GONE); // } // // // //缓冲动画控制 // public static void setBufferVisibility(ImageView imgBuffer, boolean Visible) // { // if (Visible) // { // imgBuffer.setVisibility(View.VISIBLE); // startImageAnim(imgBuffer, R.drawable.loading); // } // else // { // stopImageAnim(imgBuffer); // imgBuffer.setVisibility(View.GONE); // } // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; import android.widget.ToggleButton; import com.martin.ads.vrlib.R; import com.martin.ads.vrlib.filters.advanced.FilterType; import com.martin.ads.vrlib.utils.UIUtils; import java.util.Timer; import java.util.TimerTask; } public void show(){ if (visible) return; visible=true; if(!imageMode) progressToolbar.setVisibility(View.VISIBLE); controlToolbar.setVisibility(View.VISIBLE); } public boolean isVisible() { return visible; } public interface UICallback{ void requestScreenshot(); void requestFinish(); void changeDisPlayMode(); void changeInteractiveMode(); void changePlayingStatus(); void playerSeekTo(int pos); int getPlayerDuration(); int getPlayerCurrentPosition(); void addFilter(FilterType filterType); } public void setInfo(){ processSeekBar.setProgress(0); int duration=uiCallback.getPlayerDuration(); processSeekBar.setMax(duration);
lengthStr = UIUtils.getShowTime(duration);
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // }
import android.content.Context; import android.graphics.Bitmap; import android.opengl.GLES20; import android.opengl.GLUtils; import android.util.Log; import com.martin.ads.vrlib.constant.GLEtc;
package com.martin.ads.vrlib.utils; /** * Created by Ads on 2016/11/19. */ public class TextureUtils { private static final String TAG = "TextureUtils"; public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/GLEtc.java // public class GLEtc { // public static final int NO_TEXTURE=0; // //i.e. GLES11Ext.GL_TEXTURE_EXTERNAL_OES // public static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65; // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java import android.content.Context; import android.graphics.Bitmap; import android.opengl.GLES20; import android.opengl.GLUtils; import android.util.Log; import com.martin.ads.vrlib.constant.GLEtc; package com.martin.ads.vrlib.utils; /** * Created by Ads on 2016/11/19. */ public class TextureUtils { private static final String TAG = "TextureUtils"; public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){
if (textureId != GLEtc.NO_TEXTURE) {
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/programs/GLAbsProgram.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. */ public abstract class GLAbsProgram { private int mProgramId; private String mVertexShader; private String mFragmentShader; private int maPositionHandle; private int maTextureCoordinateHandle; public GLAbsProgram(Context context , final String vertexShaderPath , final String fragmentShaderPath){
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/programs/GLAbsProgram.java import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. */ public abstract class GLAbsProgram { private int mProgramId; private String mVertexShader; private String mFragmentShader; private int maPositionHandle; private int maTextureCoordinateHandle; public GLAbsProgram(Context context , final String vertexShaderPath , final String fragmentShaderPath){
mVertexShader = ShaderUtils.readAssetsTextFile(context,vertexShaderPath);
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/object/Sphere.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // }
import android.content.Context; import android.opengl.GLES20; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError;
// initialize vertex byte buffer for shape coordinates ByteBuffer cc = ByteBuffer.allocateDirect( texcoords.length * 4); cc.order(ByteOrder.nativeOrder()); FloatBuffer texBuffer = cc.asFloatBuffer(); texBuffer.put(texcoords); texBuffer.position(0); // initialize byte buffer for the draw list ByteBuffer dlb = ByteBuffer.allocateDirect( // (# of coordinate values * 2 bytes per short) indices.length * 2); dlb.order(ByteOrder.nativeOrder()); indexBuffer = dlb.asShortBuffer(); indexBuffer.put(indices); indexBuffer.position(0); mTexCoordinateBuffer=texBuffer; mVerticesBuffer=vertexBuffer; mNumIndices=indices.length; } public void uploadVerticesBuffer(int positionHandle){ FloatBuffer vertexBuffer = getVerticesBuffer(); if (vertexBuffer == null) return; vertexBuffer.position(0); GLES20.glVertexAttribPointer(positionHandle, sPositionDataSize, GLES20.GL_FLOAT, false, 0, vertexBuffer);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/object/Sphere.java import android.content.Context; import android.opengl.GLES20; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError; // initialize vertex byte buffer for shape coordinates ByteBuffer cc = ByteBuffer.allocateDirect( texcoords.length * 4); cc.order(ByteOrder.nativeOrder()); FloatBuffer texBuffer = cc.asFloatBuffer(); texBuffer.put(texcoords); texBuffer.position(0); // initialize byte buffer for the draw list ByteBuffer dlb = ByteBuffer.allocateDirect( // (# of coordinate values * 2 bytes per short) indices.length * 2); dlb.order(ByteOrder.nativeOrder()); indexBuffer = dlb.asShortBuffer(); indexBuffer.put(indices); indexBuffer.position(0); mTexCoordinateBuffer=texBuffer; mVerticesBuffer=vertexBuffer; mNumIndices=indices.length; } public void uploadVerticesBuffer(int positionHandle){ FloatBuffer vertexBuffer = getVerticesBuffer(); if (vertexBuffer == null) return; vertexBuffer.position(0); GLES20.glVertexAttribPointer(positionHandle, sPositionDataSize, GLES20.GL_FLOAT, false, 0, vertexBuffer);
checkGlError("glVertexAttribPointer maPosition");
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/programs/GLOESProgram.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/8. * Translate YUV420SP(NV21) to RGBA * it may also work with YUV420P(YV12) * with STM/OES */ public class GLOESProgram extends GLAbsProgram{ private int uMVPMatrixHandle; private int muSTMatrixHandle; private int uTextureSamplerHandle; public GLOESProgram(Context context){ super(context, "filter/vsh/oes.glsl","filter/fsh/oes.glsl"); } @Override public void create(){ super.create(); muSTMatrixHandle = GLES20.glGetUniformLocation(getProgramId(), "uSTMatrix");
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/programs/GLOESProgram.java import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/8. * Translate YUV420SP(NV21) to RGBA * it may also work with YUV420P(YV12) * with STM/OES */ public class GLOESProgram extends GLAbsProgram{ private int uMVPMatrixHandle; private int muSTMatrixHandle; private int uTextureSamplerHandle; public GLOESProgram(Context context){ super(context, "filter/vsh/oes.glsl","filter/fsh/oes.glsl"); } @Override public void create(){ super.create(); muSTMatrixHandle = GLES20.glGetUniformLocation(getProgramId(), "uSTMatrix");
ShaderUtils.checkGlError("glGetUniformLocation uSTMatrix");
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/PanoMediaPlayerWrapper.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/PanoStatus.java // public enum PanoStatus // { // IDLE, PREPARED,BUFFERING, PLAYING, PAUSED_BY_USER, PAUSED, STOPPED, COMPLETE, ERROR // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java // public class StatusHelper { // private PanoStatus panoStatus; // private PanoMode panoDisPlayMode; // private PanoMode panoInteractiveMode; // private Context context; // public StatusHelper(Context context) { // this.context = context; // } // // public Context getContext() { // return context; // } // // public PanoStatus getPanoStatus() { // return panoStatus; // } // // public void setPanoStatus(PanoStatus panoStatus) { // this.panoStatus = panoStatus; // } // // public PanoMode getPanoDisPlayMode() { // return panoDisPlayMode; // } // // public void setPanoDisPlayMode(PanoMode panoDisPlayMode) { // this.panoDisPlayMode = panoDisPlayMode; // } // // public PanoMode getPanoInteractiveMode() { // return panoInteractiveMode; // } // // public void setPanoInteractiveMode(PanoMode panoInteractiveMode) { // this.panoInteractiveMode = panoInteractiveMode; // } // }
import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.view.Surface; import com.martin.ads.vrlib.constant.PanoStatus; import com.martin.ads.vrlib.utils.StatusHelper; import java.io.IOException;
package com.martin.ads.vrlib; /** * Created by Ads on 2016/5/2. */ public class PanoMediaPlayerWrapper implements SurfaceTexture.OnFrameAvailableListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnVideoSizeChangedListener, MediaPlayer.OnInfoListener, MediaPlayer.OnBufferingUpdateListener{ public static String TAG = "PanoMediaPlayerWrapper";
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/PanoStatus.java // public enum PanoStatus // { // IDLE, PREPARED,BUFFERING, PLAYING, PAUSED_BY_USER, PAUSED, STOPPED, COMPLETE, ERROR // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java // public class StatusHelper { // private PanoStatus panoStatus; // private PanoMode panoDisPlayMode; // private PanoMode panoInteractiveMode; // private Context context; // public StatusHelper(Context context) { // this.context = context; // } // // public Context getContext() { // return context; // } // // public PanoStatus getPanoStatus() { // return panoStatus; // } // // public void setPanoStatus(PanoStatus panoStatus) { // this.panoStatus = panoStatus; // } // // public PanoMode getPanoDisPlayMode() { // return panoDisPlayMode; // } // // public void setPanoDisPlayMode(PanoMode panoDisPlayMode) { // this.panoDisPlayMode = panoDisPlayMode; // } // // public PanoMode getPanoInteractiveMode() { // return panoInteractiveMode; // } // // public void setPanoInteractiveMode(PanoMode panoInteractiveMode) { // this.panoInteractiveMode = panoInteractiveMode; // } // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/PanoMediaPlayerWrapper.java import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.view.Surface; import com.martin.ads.vrlib.constant.PanoStatus; import com.martin.ads.vrlib.utils.StatusHelper; import java.io.IOException; package com.martin.ads.vrlib; /** * Created by Ads on 2016/5/2. */ public class PanoMediaPlayerWrapper implements SurfaceTexture.OnFrameAvailableListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnVideoSizeChangedListener, MediaPlayer.OnInfoListener, MediaPlayer.OnBufferingUpdateListener{ public static String TAG = "PanoMediaPlayerWrapper";
private StatusHelper statusHelper;
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/PanoMediaPlayerWrapper.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/PanoStatus.java // public enum PanoStatus // { // IDLE, PREPARED,BUFFERING, PLAYING, PAUSED_BY_USER, PAUSED, STOPPED, COMPLETE, ERROR // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java // public class StatusHelper { // private PanoStatus panoStatus; // private PanoMode panoDisPlayMode; // private PanoMode panoInteractiveMode; // private Context context; // public StatusHelper(Context context) { // this.context = context; // } // // public Context getContext() { // return context; // } // // public PanoStatus getPanoStatus() { // return panoStatus; // } // // public void setPanoStatus(PanoStatus panoStatus) { // this.panoStatus = panoStatus; // } // // public PanoMode getPanoDisPlayMode() { // return panoDisPlayMode; // } // // public void setPanoDisPlayMode(PanoMode panoDisPlayMode) { // this.panoDisPlayMode = panoDisPlayMode; // } // // public PanoMode getPanoInteractiveMode() { // return panoInteractiveMode; // } // // public void setPanoInteractiveMode(PanoMode panoInteractiveMode) { // this.panoInteractiveMode = panoInteractiveMode; // } // }
import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.view.Surface; import com.martin.ads.vrlib.constant.PanoStatus; import com.martin.ads.vrlib.utils.StatusHelper; import java.io.IOException;
public void setMediaPlayerFromUri(Uri uri){ try{ mMediaPlayer.setDataSource(statusHelper.getContext(),uri); }catch (IOException e){ e.printStackTrace(); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setLooping(true); } public void setMediaPlayerFromAssets(AssetFileDescriptor assetFileDescriptor){ try{ mMediaPlayer.setDataSource( assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getDeclaredLength() ); }catch (IOException e){ e.printStackTrace(); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setLooping(true); } public void setStatusHelper(StatusHelper statusHelper){ this.statusHelper=statusHelper; } public void prepare(){
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/PanoStatus.java // public enum PanoStatus // { // IDLE, PREPARED,BUFFERING, PLAYING, PAUSED_BY_USER, PAUSED, STOPPED, COMPLETE, ERROR // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/StatusHelper.java // public class StatusHelper { // private PanoStatus panoStatus; // private PanoMode panoDisPlayMode; // private PanoMode panoInteractiveMode; // private Context context; // public StatusHelper(Context context) { // this.context = context; // } // // public Context getContext() { // return context; // } // // public PanoStatus getPanoStatus() { // return panoStatus; // } // // public void setPanoStatus(PanoStatus panoStatus) { // this.panoStatus = panoStatus; // } // // public PanoMode getPanoDisPlayMode() { // return panoDisPlayMode; // } // // public void setPanoDisPlayMode(PanoMode panoDisPlayMode) { // this.panoDisPlayMode = panoDisPlayMode; // } // // public PanoMode getPanoInteractiveMode() { // return panoInteractiveMode; // } // // public void setPanoInteractiveMode(PanoMode panoInteractiveMode) { // this.panoInteractiveMode = panoInteractiveMode; // } // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/PanoMediaPlayerWrapper.java import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.view.Surface; import com.martin.ads.vrlib.constant.PanoStatus; import com.martin.ads.vrlib.utils.StatusHelper; import java.io.IOException; public void setMediaPlayerFromUri(Uri uri){ try{ mMediaPlayer.setDataSource(statusHelper.getContext(),uri); }catch (IOException e){ e.printStackTrace(); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setLooping(true); } public void setMediaPlayerFromAssets(AssetFileDescriptor assetFileDescriptor){ try{ mMediaPlayer.setDataSource( assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getDeclaredLength() ); }catch (IOException e){ e.printStackTrace(); } mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setLooping(true); } public void setStatusHelper(StatusHelper statusHelper){ this.statusHelper=statusHelper; } public void prepare(){
if (statusHelper.getPanoStatus()==PanoStatus.IDLE || statusHelper.getPanoStatus()==PanoStatus.STOPPED){
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/programs/GLPassThroughProgram.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. * with Sampler2D and MVPMatrix */ public class GLPassThroughProgram extends GLAbsProgram { private int uMVPMatrixHandle; private int uTextureSamplerHandle; public GLPassThroughProgram(Context context) { super(context, "filter/vsh/pass_through.glsl","filter/fsh/pass_through.glsl"); } @Override public void create() { super.create(); uTextureSamplerHandle= GLES20.glGetUniformLocation(getProgramId(),"sTexture");
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/programs/GLPassThroughProgram.java import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. * with Sampler2D and MVPMatrix */ public class GLPassThroughProgram extends GLAbsProgram { private int uMVPMatrixHandle; private int uTextureSamplerHandle; public GLPassThroughProgram(Context context) { super(context, "filter/vsh/pass_through.glsl","filter/fsh/pass_through.glsl"); } @Override public void create() { super.create(); uTextureSamplerHandle= GLES20.glGetUniformLocation(getProgramId(),"sTexture");
ShaderUtils.checkGlError("glGetUniformLocation uniform sTexture");
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/utils/MatrixUtils.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/AdjustingMode.java // public class AdjustingMode { // public static final int ADJUSTING_MODE_STRETCH=1; // public static final int ADJUSTING_MODE_CROP=2; // public static final int ADJUSTING_MODE_FIT_TO_SCREEN=3; // // }
import android.opengl.Matrix; import com.martin.ads.vrlib.constant.AdjustingMode;
package com.martin.ads.vrlib.utils; /** * Created by Ads on 2017/1/27. */ public class MatrixUtils { public static float IDENTITY_MATRIX[]=new float[16]; static { Matrix.setIdentityM(IDENTITY_MATRIX,0); } public static void updateProjection(int imageWidth, int imageHeight,int surfaceWidth,int surfaceHeight,int adjustingMode,float[] projectionMatrix){ switch (adjustingMode){
// Path: vrlib/src/main/java/com/martin/ads/vrlib/constant/AdjustingMode.java // public class AdjustingMode { // public static final int ADJUSTING_MODE_STRETCH=1; // public static final int ADJUSTING_MODE_CROP=2; // public static final int ADJUSTING_MODE_FIT_TO_SCREEN=3; // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/MatrixUtils.java import android.opengl.Matrix; import com.martin.ads.vrlib.constant.AdjustingMode; package com.martin.ads.vrlib.utils; /** * Created by Ads on 2017/1/27. */ public class MatrixUtils { public static float IDENTITY_MATRIX[]=new float[16]; static { Matrix.setIdentityM(IDENTITY_MATRIX,0); } public static void updateProjection(int imageWidth, int imageHeight,int surfaceWidth,int surfaceHeight,int adjustingMode,float[] projectionMatrix){ switch (adjustingMode){
case AdjustingMode.ADJUSTING_MODE_STRETCH:
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/mx/MxFaceBeautyFilter.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/base/SimpleFragmentShaderFilter.java // public class SimpleFragmentShaderFilter extends AbsFilter { // // protected GLSimpleProgram glSimpleProgram; // protected Plane plane; // // public SimpleFragmentShaderFilter(Context context, // final String fragmentShaderPath) { // glSimpleProgram=new GLSimpleProgram(context, "filter/vsh/simple.glsl",fragmentShaderPath); // plane =new Plane(true); // } // // @Override // public void init() { // glSimpleProgram.create(); // } // // @Override // public void onPreDrawElements() { // super.onPreDrawElements(); // glSimpleProgram.use(); // plane.uploadTexCoordinateBuffer(glSimpleProgram.getTextureCoordinateHandle()); // plane.uploadVerticesBuffer(glSimpleProgram.getPositionHandle()); // } // // @Override // public void destroy() { // glSimpleProgram.onDestroy(); // } // // @Override // public void onDrawFrame(int textureId) { // onPreDrawElements(); // TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0); // GLES20.glViewport(0,0,surfaceWidth,surfaceHeight); // plane.draw(); // } // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java // public class TextureUtils { // private static final String TAG = "TextureUtils"; // // public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){ // if (textureId != GLEtc.NO_TEXTURE) { // GLES20.glActiveTexture(activeTextureID); // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); // GLES20.glUniform1i(handle, idx); // } // } // // public static void bindTextureOES(int textureId,int activeTextureID,int handle,int idx){ // if (textureId != GLEtc.NO_TEXTURE) { // GLES20.glActiveTexture(activeTextureID); // GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId); // GLES20.glUniform1i(handle, idx); // } // } // // public static int loadTextureFromResources(Context context, int resourceId,int imageSize[]){ // return getTextureFromBitmap( // BitmapUtils.loadBitmapFromRaw(context,resourceId), // imageSize); // } // // public static int loadTextureFromAssets(Context context, String filePath,int imageSize[]){ // return getTextureFromBitmap( // BitmapUtils.loadBitmapFromAssets(context,filePath), // imageSize); // } // // //bitmap will be recycled after calling this method // public static int getTextureFromBitmap(Bitmap bitmap,int imageSize[]){ // final int[] textureObjectIds=new int[1]; // GLES20.glGenTextures(1,textureObjectIds,0); // if (textureObjectIds[0]==0){ // Log.d(TAG,"Failed at glGenTextures"); // return 0; // } // // if (bitmap==null){ // Log.d(TAG,"Failed at decoding bitmap"); // GLES20.glDeleteTextures(1,textureObjectIds,0); // return 0; // } // // if(imageSize!=null && imageSize.length>=2){ // imageSize[0]=bitmap.getWidth(); // imageSize[1]=bitmap.getHeight(); // } // // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureObjectIds[0]); // // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); // GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0); // bitmap.recycle(); // // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0); // return textureObjectIds[0]; // } // }
import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.filters.base.SimpleFragmentShaderFilter; import com.martin.ads.vrlib.utils.TextureUtils;
package com.martin.ads.vrlib.filters.advanced.mx; /** * Created by Ads on 2017/2/1. * MxFaceBeautyFilter (Mx美颜) */ public class MxFaceBeautyFilter extends SimpleFragmentShaderFilter { public MxFaceBeautyFilter(Context context) { super(context, "filter/fsh/mx_face_beauty.glsl"); } @Override public void onDrawFrame(int textureId) { onPreDrawElements(); setUniform1f(glSimpleProgram.getProgramId(),"stepSizeX",1.0f/surfaceWidth); setUniform1f(glSimpleProgram.getProgramId(),"stepSizeY",1.0f/surfaceHeight);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/base/SimpleFragmentShaderFilter.java // public class SimpleFragmentShaderFilter extends AbsFilter { // // protected GLSimpleProgram glSimpleProgram; // protected Plane plane; // // public SimpleFragmentShaderFilter(Context context, // final String fragmentShaderPath) { // glSimpleProgram=new GLSimpleProgram(context, "filter/vsh/simple.glsl",fragmentShaderPath); // plane =new Plane(true); // } // // @Override // public void init() { // glSimpleProgram.create(); // } // // @Override // public void onPreDrawElements() { // super.onPreDrawElements(); // glSimpleProgram.use(); // plane.uploadTexCoordinateBuffer(glSimpleProgram.getTextureCoordinateHandle()); // plane.uploadVerticesBuffer(glSimpleProgram.getPositionHandle()); // } // // @Override // public void destroy() { // glSimpleProgram.onDestroy(); // } // // @Override // public void onDrawFrame(int textureId) { // onPreDrawElements(); // TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0); // GLES20.glViewport(0,0,surfaceWidth,surfaceHeight); // plane.draw(); // } // } // // Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java // public class TextureUtils { // private static final String TAG = "TextureUtils"; // // public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){ // if (textureId != GLEtc.NO_TEXTURE) { // GLES20.glActiveTexture(activeTextureID); // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); // GLES20.glUniform1i(handle, idx); // } // } // // public static void bindTextureOES(int textureId,int activeTextureID,int handle,int idx){ // if (textureId != GLEtc.NO_TEXTURE) { // GLES20.glActiveTexture(activeTextureID); // GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId); // GLES20.glUniform1i(handle, idx); // } // } // // public static int loadTextureFromResources(Context context, int resourceId,int imageSize[]){ // return getTextureFromBitmap( // BitmapUtils.loadBitmapFromRaw(context,resourceId), // imageSize); // } // // public static int loadTextureFromAssets(Context context, String filePath,int imageSize[]){ // return getTextureFromBitmap( // BitmapUtils.loadBitmapFromAssets(context,filePath), // imageSize); // } // // //bitmap will be recycled after calling this method // public static int getTextureFromBitmap(Bitmap bitmap,int imageSize[]){ // final int[] textureObjectIds=new int[1]; // GLES20.glGenTextures(1,textureObjectIds,0); // if (textureObjectIds[0]==0){ // Log.d(TAG,"Failed at glGenTextures"); // return 0; // } // // if (bitmap==null){ // Log.d(TAG,"Failed at decoding bitmap"); // GLES20.glDeleteTextures(1,textureObjectIds,0); // return 0; // } // // if(imageSize!=null && imageSize.length>=2){ // imageSize[0]=bitmap.getWidth(); // imageSize[1]=bitmap.getHeight(); // } // // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureObjectIds[0]); // // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); // GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, // GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); // GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0); // bitmap.recycle(); // // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0); // return textureObjectIds[0]; // } // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/mx/MxFaceBeautyFilter.java import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.filters.base.SimpleFragmentShaderFilter; import com.martin.ads.vrlib.utils.TextureUtils; package com.martin.ads.vrlib.filters.advanced.mx; /** * Created by Ads on 2017/2/1. * MxFaceBeautyFilter (Mx美颜) */ public class MxFaceBeautyFilter extends SimpleFragmentShaderFilter { public MxFaceBeautyFilter(Context context) { super(context, "filter/fsh/mx_face_beauty.glsl"); } @Override public void onDrawFrame(int textureId) { onPreDrawElements(); setUniform1f(glSimpleProgram.getProgramId(),"stepSizeX",1.0f/surfaceWidth); setUniform1f(glSimpleProgram.getProgramId(),"stepSizeY",1.0f/surfaceHeight);
TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0);
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/programs/GLTwoInputProgram.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // }
import android.content.Context; import android.opengl.GLES20; import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError;
package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/20. */ //It is optional to split reference to a program public class GLTwoInputProgram extends GLAbsProgram { private int uTextureSamplerHandle; private int maTexture2Handle; public GLTwoInputProgram(Context context, final String vertexShaderPath, final String fragmentShaderPath) { super(context, vertexShaderPath, fragmentShaderPath); } @Override public void create() { super.create(); maTexture2Handle = GLES20.glGetAttribLocation(getProgramId(), "aTextureCoord2");
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/programs/GLTwoInputProgram.java import android.content.Context; import android.opengl.GLES20; import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError; package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/20. */ //It is optional to split reference to a program public class GLTwoInputProgram extends GLAbsProgram { private int uTextureSamplerHandle; private int maTexture2Handle; public GLTwoInputProgram(Context context, final String vertexShaderPath, final String fragmentShaderPath) { super(context, vertexShaderPath, fragmentShaderPath); } @Override public void create() { super.create(); maTexture2Handle = GLES20.glGetAttribLocation(getProgramId(), "aTextureCoord2");
checkGlError("glGetAttribLocation aTextureCoord");
Martin20150405/Pano360
vrlib/src/main/java/com/martin/ads/vrlib/programs/GLSimpleProgram.java
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // }
import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils;
package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. * with Sampler2D */ public class GLSimpleProgram extends GLAbsProgram { private int uTextureSamplerHandle; public GLSimpleProgram(Context context, final String vertexShaderPath, final String fragmentShaderPath) { super(context, vertexShaderPath, fragmentShaderPath); } @Override public void create() { super.create(); uTextureSamplerHandle= GLES20.glGetUniformLocation(getProgramId(),"sTexture");
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java // public class ShaderUtils { // // private static final String TAG = "ShaderUtils"; // // public static void checkGlError(String label) { // int error; // while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { // Log.e(TAG, label + ": glError " + error); // throw new RuntimeException(label + ": glError " + error); // } // } // // public static int createProgram(String vertexSource, String fragmentSource) { // int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); // if (vertexShader == 0) { // return 0; // } // int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); // if (pixelShader == 0) { // return 0; // } // // int program = GLES20.glCreateProgram(); // if (program != 0) { // GLES20.glAttachShader(program, vertexShader); // checkGlError("glAttachShader"); // GLES20.glAttachShader(program, pixelShader); // checkGlError("glAttachShader"); // GLES20.glLinkProgram(program); // int[] linkStatus = new int[1]; // GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); // if (linkStatus[0] != GLES20.GL_TRUE) { // Log.e(TAG, "Could not link program: "); // Log.e(TAG, GLES20.glGetProgramInfoLog(program)); // GLES20.glDeleteProgram(program); // program = 0; // } // } // return program; // } // // // public static int loadShader(int shaderType, String source) { // int shader = GLES20.glCreateShader(shaderType); // if (shader != 0) { // GLES20.glShaderSource(shader, source); // GLES20.glCompileShader(shader); // int[] compiled = new int[1]; // GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); // if (compiled[0] == 0) { // Log.e(TAG, "Could not compile shader " + shaderType + ":"); // Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); // GLES20.glDeleteShader(shader); // shader = 0; // } // } // return shader; // } // // // public static String readRawTextFile(Context context, int resId) { // InputStream inputStream = context.getResources().openRawResource(resId); // return getStringFromStream(inputStream); // } // // public static String readAssetsTextFile(Context context, String filePath) { // InputStream inputStream = null; // try { // inputStream = context.getResources().getAssets().open(filePath); // } catch (IOException e) { // e.printStackTrace(); // } // return getStringFromStream(inputStream); // } // // private static String getStringFromStream(InputStream inputStream){ // if(inputStream==null) return null; // try { // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // reader.close(); // return sb.toString(); // } catch (IOException e) { // e.printStackTrace(); // } // return null; // } // // } // Path: vrlib/src/main/java/com/martin/ads/vrlib/programs/GLSimpleProgram.java import android.content.Context; import android.opengl.GLES20; import com.martin.ads.vrlib.utils.ShaderUtils; package com.martin.ads.vrlib.programs; /** * Created by Ads on 2016/11/19. * with Sampler2D */ public class GLSimpleProgram extends GLAbsProgram { private int uTextureSamplerHandle; public GLSimpleProgram(Context context, final String vertexShaderPath, final String fragmentShaderPath) { super(context, vertexShaderPath, fragmentShaderPath); } @Override public void create() { super.create(); uTextureSamplerHandle= GLES20.glGetUniformLocation(getProgramId(),"sTexture");
ShaderUtils.checkGlError("glGetUniformLocation uniform samplerExternalOES sTexture");