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 |
|---|---|---|---|---|---|---|
mikelewis0/easyccg | src/uk/ac/ed/easyccg/syntax/InputReader.java | // Path: src/uk/ac/ed/easyccg/main/EasyCCG.java
// public enum InputFormat {
// TOKENIZED, GOLD, SUPERTAGGED, POSTAGGED, POSANDNERTAGGED
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java
// public static class SyntaxTreeNodeFactory {
// private final int[][] categoryHash;
// private final int[][] dependencyHash;
// private final boolean hashWords;
//
// /**
// * These parameters are needed so that it can pre-compute some hash values.
// * @param maxSentenceLength
// * @param numberOfLexicalCategories
// */
// public SyntaxTreeNodeFactory(int maxSentenceLength, int numberOfLexicalCategories) {
//
// hashWords = numberOfLexicalCategories > 0;
// categoryHash = makeRandomArray(maxSentenceLength, numberOfLexicalCategories + 1);
// dependencyHash = makeRandomArray(maxSentenceLength, maxSentenceLength);
// }
//
// private int[][] makeRandomArray(int x, int y) {
// Random random = new Random();
// int[][] result = new int[x][y];
// for (int i=0; i<x; i++) {
// for (int j=0; j<y; j++) {
// result[i][j] = random.nextInt();
// }
// }
//
// return result;
// }
//
// public SyntaxTreeNodeLeaf makeTerminal(String word, Category category, String pos, String ner, double probability, int sentencePosition) {
// return new SyntaxTreeNodeLeaf(
// word, pos, ner, category, probability,
// hashWords ? categoryHash[sentencePosition][category.getID()] : 0, 0, sentencePosition);
// }
//
// public SyntaxTreeNode makeUnary(Category category, SyntaxTreeNode child) {
// return new SyntaxTreeNodeUnary(category, child.probability, child.hash, child.totalDependencyLength, child.getHeadIndex(), child);
// }
//
// public SyntaxTreeNode makeBinary(Category category, SyntaxTreeNode left, SyntaxTreeNode right, RuleType ruleType, boolean headIsLeft) {
//
// int totalDependencyLength = (right.getHeadIndex() - left.getHeadIndex())
// + left.totalDependencyLength + right.totalDependencyLength;
//
// int hash;
// if (right.getCategory().isPunctuation()) {
// // Ignore punctuation when calculating the hash, because we don't really care where a full-stop attaches.
// hash = left.hash;
// } else if (left.getCategory().isPunctuation()) {
// // Ignore punctuation when calculating the hash, because we don't really care where a full-stop attaches.
// hash = right.hash;
// } else {
// // Combine the hash codes in a commutive way, so that left and right branching derivations can still be equivalent.
// hash = left.hash ^ right.hash ^ dependencyHash[left.getHeadIndex()][right.getHeadIndex()];
// }
//
// SyntaxTreeNode result = new SyntaxTreeNodeBinary(
// category,
// left.probability + right.probability, // log probabilities
// hash,
// totalDependencyLength,
// headIsLeft ? left.getHeadIndex() : right.getHeadIndex(),
// ruleType,
// headIsLeft,
// left,
// right);
//
//
// return result;
// }
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java
// public static class SyntaxTreeNodeLeaf extends SyntaxTreeNode {
// private SyntaxTreeNodeLeaf(
// String word, String pos, String ner,
// Category category, double probability, int hash, int totalDependencyLength, int headIndex
// )
// {
// super(category, probability, hash, totalDependencyLength, headIndex);
// this.pos = pos;
// this.ner = ner;
// this.word = word;
// }
// private final String pos;
// private final String ner;
// private final String word;
// @Override
// void accept(SyntaxTreeNodeVisitor v)
// {
// v.visit(this);
// }
// @Override
// public RuleType getRuleType()
// {
// return RuleType.LEXICON;
// }
// @Override
// public List<SyntaxTreeNode> getChildren()
// {
// return Collections.emptyList();
// }
//
// @Override
// public boolean isLeaf()
// {
// return true;
// }
//
// @Override
// void getWords(List<SyntaxTreeNodeLeaf> result) {
// result.add(this);
// }
// public String getPos()
// {
// return pos;
// }
// public String getNER()
// {
// return ner;
// }
// public String getWord()
// {
// return word;
// }
// @Override
// SyntaxTreeNodeLeaf getHead()
// {
// return this;
// }
// @Override
// int dimension()
// {
// return 0;
// }
// public int getSentencePosition()
// {
// return getHeadIndex();
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.List;
import uk.ac.ed.easyccg.main.EasyCCG.InputFormat;
import uk.ac.ed.easyccg.syntax.SyntaxTreeNode.SyntaxTreeNodeFactory;
import uk.ac.ed.easyccg.syntax.SyntaxTreeNode.SyntaxTreeNodeLeaf; | }
return null;
}
@Override
public InputToParser next()
{
InputToParser result = next;
next = getNext();
return result;
}
@Override
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
};
}
public abstract InputToParser readInput(String line);
public static class InputToParser {
private final List<InputWord> words;
private boolean isAlreadyTagged; | // Path: src/uk/ac/ed/easyccg/main/EasyCCG.java
// public enum InputFormat {
// TOKENIZED, GOLD, SUPERTAGGED, POSTAGGED, POSANDNERTAGGED
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java
// public static class SyntaxTreeNodeFactory {
// private final int[][] categoryHash;
// private final int[][] dependencyHash;
// private final boolean hashWords;
//
// /**
// * These parameters are needed so that it can pre-compute some hash values.
// * @param maxSentenceLength
// * @param numberOfLexicalCategories
// */
// public SyntaxTreeNodeFactory(int maxSentenceLength, int numberOfLexicalCategories) {
//
// hashWords = numberOfLexicalCategories > 0;
// categoryHash = makeRandomArray(maxSentenceLength, numberOfLexicalCategories + 1);
// dependencyHash = makeRandomArray(maxSentenceLength, maxSentenceLength);
// }
//
// private int[][] makeRandomArray(int x, int y) {
// Random random = new Random();
// int[][] result = new int[x][y];
// for (int i=0; i<x; i++) {
// for (int j=0; j<y; j++) {
// result[i][j] = random.nextInt();
// }
// }
//
// return result;
// }
//
// public SyntaxTreeNodeLeaf makeTerminal(String word, Category category, String pos, String ner, double probability, int sentencePosition) {
// return new SyntaxTreeNodeLeaf(
// word, pos, ner, category, probability,
// hashWords ? categoryHash[sentencePosition][category.getID()] : 0, 0, sentencePosition);
// }
//
// public SyntaxTreeNode makeUnary(Category category, SyntaxTreeNode child) {
// return new SyntaxTreeNodeUnary(category, child.probability, child.hash, child.totalDependencyLength, child.getHeadIndex(), child);
// }
//
// public SyntaxTreeNode makeBinary(Category category, SyntaxTreeNode left, SyntaxTreeNode right, RuleType ruleType, boolean headIsLeft) {
//
// int totalDependencyLength = (right.getHeadIndex() - left.getHeadIndex())
// + left.totalDependencyLength + right.totalDependencyLength;
//
// int hash;
// if (right.getCategory().isPunctuation()) {
// // Ignore punctuation when calculating the hash, because we don't really care where a full-stop attaches.
// hash = left.hash;
// } else if (left.getCategory().isPunctuation()) {
// // Ignore punctuation when calculating the hash, because we don't really care where a full-stop attaches.
// hash = right.hash;
// } else {
// // Combine the hash codes in a commutive way, so that left and right branching derivations can still be equivalent.
// hash = left.hash ^ right.hash ^ dependencyHash[left.getHeadIndex()][right.getHeadIndex()];
// }
//
// SyntaxTreeNode result = new SyntaxTreeNodeBinary(
// category,
// left.probability + right.probability, // log probabilities
// hash,
// totalDependencyLength,
// headIsLeft ? left.getHeadIndex() : right.getHeadIndex(),
// ruleType,
// headIsLeft,
// left,
// right);
//
//
// return result;
// }
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java
// public static class SyntaxTreeNodeLeaf extends SyntaxTreeNode {
// private SyntaxTreeNodeLeaf(
// String word, String pos, String ner,
// Category category, double probability, int hash, int totalDependencyLength, int headIndex
// )
// {
// super(category, probability, hash, totalDependencyLength, headIndex);
// this.pos = pos;
// this.ner = ner;
// this.word = word;
// }
// private final String pos;
// private final String ner;
// private final String word;
// @Override
// void accept(SyntaxTreeNodeVisitor v)
// {
// v.visit(this);
// }
// @Override
// public RuleType getRuleType()
// {
// return RuleType.LEXICON;
// }
// @Override
// public List<SyntaxTreeNode> getChildren()
// {
// return Collections.emptyList();
// }
//
// @Override
// public boolean isLeaf()
// {
// return true;
// }
//
// @Override
// void getWords(List<SyntaxTreeNodeLeaf> result) {
// result.add(this);
// }
// public String getPos()
// {
// return pos;
// }
// public String getNER()
// {
// return ner;
// }
// public String getWord()
// {
// return word;
// }
// @Override
// SyntaxTreeNodeLeaf getHead()
// {
// return this;
// }
// @Override
// int dimension()
// {
// return 0;
// }
// public int getSentencePosition()
// {
// return getHeadIndex();
// }
// }
// Path: src/uk/ac/ed/easyccg/syntax/InputReader.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.List;
import uk.ac.ed.easyccg.main.EasyCCG.InputFormat;
import uk.ac.ed.easyccg.syntax.SyntaxTreeNode.SyntaxTreeNodeFactory;
import uk.ac.ed.easyccg.syntax.SyntaxTreeNode.SyntaxTreeNodeLeaf;
}
return null;
}
@Override
public InputToParser next()
{
InputToParser result = next;
next = getNext();
return result;
}
@Override
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
};
}
public abstract InputToParser readInput(String line);
public static class InputToParser {
private final List<InputWord> words;
private boolean isAlreadyTagged; | InputToParser(List<InputWord> words, List<Category> goldCategories, List<List<SyntaxTreeNodeLeaf>> inputSupertags, boolean isAlreadyTagged) |
mikelewis0/easyccg | src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java | // Path: src/uk/ac/ed/easyccg/syntax/Combinator.java
// public enum RuleType {
// FA, BA, FC, BX, GFC, GBX, CONJ, RP, LP, NOISE, UNARY, LEXICON
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import uk.ac.ed.easyccg.syntax.Combinator.RuleType; | package uk.ac.ed.easyccg.syntax;
public abstract class SyntaxTreeNode implements Comparable<SyntaxTreeNode> {
private final Category category;
final double probability;
final int hash;
final int totalDependencyLength;
private final int headIndex;
abstract SyntaxTreeNodeLeaf getHead();
private SyntaxTreeNode(
Category category,
double probability,
int hash,
int totalDependencyLength,
int headIndex
)
{
this.category = category;
this.probability = probability;
this.hash = hash;
this.totalDependencyLength = totalDependencyLength;
this.headIndex = headIndex;
}
static class SyntaxTreeNodeBinary extends SyntaxTreeNode { | // Path: src/uk/ac/ed/easyccg/syntax/Combinator.java
// public enum RuleType {
// FA, BA, FC, BX, GFC, GBX, CONJ, RP, LP, NOISE, UNARY, LEXICON
// }
// Path: src/uk/ac/ed/easyccg/syntax/SyntaxTreeNode.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import uk.ac.ed.easyccg.syntax.Combinator.RuleType;
package uk.ac.ed.easyccg.syntax;
public abstract class SyntaxTreeNode implements Comparable<SyntaxTreeNode> {
private final Category category;
final double probability;
final int hash;
final int totalDependencyLength;
private final int headIndex;
abstract SyntaxTreeNodeLeaf getHead();
private SyntaxTreeNode(
Category category,
double probability,
int hash,
int totalDependencyLength,
int headIndex
)
{
this.category = category;
this.probability = probability;
this.hash = hash;
this.totalDependencyLength = totalDependencyLength;
this.headIndex = headIndex;
}
static class SyntaxTreeNodeBinary extends SyntaxTreeNode { | final RuleType ruleType; |
mikelewis0/easyccg | src/uk/ac/ed/easyccg/syntax/Parser.java | // Path: src/uk/ac/ed/easyccg/syntax/InputReader.java
// public static class InputToParser {
// private final List<InputWord> words;
// private boolean isAlreadyTagged;
// InputToParser(List<InputWord> words, List<Category> goldCategories, List<List<SyntaxTreeNodeLeaf>> inputSupertags, boolean isAlreadyTagged)
// {
// this.words = words;
// this.goldCategories = goldCategories;
// this.inputSupertags = inputSupertags;
// this.isAlreadyTagged = isAlreadyTagged;
// }
// private final List<Category> goldCategories;
// private final List<List<SyntaxTreeNodeLeaf>> inputSupertags;
// public int length()
// {
// return words.size();
// }
//
// /**
// * If true, the Parser should not supertag the data itself, and use getInputSupertags() instead.
// */
// public boolean isAlreadyTagged()
// {
// return isAlreadyTagged;
// }
// public List<List<SyntaxTreeNodeLeaf>> getInputSupertags()
// {
// return inputSupertags;
// }
//
// public List<SyntaxTreeNodeLeaf> getInputSupertags1best()
// {
// List<SyntaxTreeNodeLeaf> result = new ArrayList<SyntaxTreeNodeLeaf>();
// for (List<SyntaxTreeNodeLeaf> tagsForWord : inputSupertags) {
// result.add(tagsForWord.get(0));
// }
// return result;
// }
// public boolean haveGoldCategories()
// {
// return getGoldCategories() != null;
// }
//
// public List<Category> getGoldCategories()
// {
// return goldCategories;
// }
//
// public List<InputWord> getInputWords() {
// return words;
//
// }
//
// public String getWordsAsString()
// {
// StringBuilder result = new StringBuilder();
// for (InputWord word : words) {
// result.append(word.word + " ");
// }
//
// return result.toString().trim();
// }
//
// public static InputToParser fromTokens(List<String> tokens) {
// List<InputWord> inputWords = new ArrayList<InputWord>(tokens.size());
// for (String word : tokens) {
// inputWords.add(new InputWord(word, null, null));
// }
// return new InputToParser(inputWords, null, null, false);
// }
//
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/ParserAStar.java
// public static class SuperTaggingResults {
// public AtomicInteger parsedSentences = new AtomicInteger();
// public AtomicInteger totalSentences = new AtomicInteger();
//
// public AtomicInteger rightCats = new AtomicInteger();
// public AtomicInteger totalCats = new AtomicInteger();
//
// public AtomicInteger exactMatch = new AtomicInteger();
// }
| import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.Multimap;
import uk.ac.ed.easyccg.syntax.InputReader.InputToParser;
import uk.ac.ed.easyccg.syntax.ParserAStar.SuperTaggingResults; | package uk.ac.ed.easyccg.syntax;
public interface Parser
{
/**
* Parses a sentence, interpreting the line according to the InputReader, and returns an N-best list.
*/
public abstract List<SyntaxTreeNode> parse(String line);
/**
* Ignores the InputReader and parses the supplied list of words.
*/
public abstract List<SyntaxTreeNode> parseTokens(List<String> words);
/**
*
*/ | // Path: src/uk/ac/ed/easyccg/syntax/InputReader.java
// public static class InputToParser {
// private final List<InputWord> words;
// private boolean isAlreadyTagged;
// InputToParser(List<InputWord> words, List<Category> goldCategories, List<List<SyntaxTreeNodeLeaf>> inputSupertags, boolean isAlreadyTagged)
// {
// this.words = words;
// this.goldCategories = goldCategories;
// this.inputSupertags = inputSupertags;
// this.isAlreadyTagged = isAlreadyTagged;
// }
// private final List<Category> goldCategories;
// private final List<List<SyntaxTreeNodeLeaf>> inputSupertags;
// public int length()
// {
// return words.size();
// }
//
// /**
// * If true, the Parser should not supertag the data itself, and use getInputSupertags() instead.
// */
// public boolean isAlreadyTagged()
// {
// return isAlreadyTagged;
// }
// public List<List<SyntaxTreeNodeLeaf>> getInputSupertags()
// {
// return inputSupertags;
// }
//
// public List<SyntaxTreeNodeLeaf> getInputSupertags1best()
// {
// List<SyntaxTreeNodeLeaf> result = new ArrayList<SyntaxTreeNodeLeaf>();
// for (List<SyntaxTreeNodeLeaf> tagsForWord : inputSupertags) {
// result.add(tagsForWord.get(0));
// }
// return result;
// }
// public boolean haveGoldCategories()
// {
// return getGoldCategories() != null;
// }
//
// public List<Category> getGoldCategories()
// {
// return goldCategories;
// }
//
// public List<InputWord> getInputWords() {
// return words;
//
// }
//
// public String getWordsAsString()
// {
// StringBuilder result = new StringBuilder();
// for (InputWord word : words) {
// result.append(word.word + " ");
// }
//
// return result.toString().trim();
// }
//
// public static InputToParser fromTokens(List<String> tokens) {
// List<InputWord> inputWords = new ArrayList<InputWord>(tokens.size());
// for (String word : tokens) {
// inputWords.add(new InputWord(word, null, null));
// }
// return new InputToParser(inputWords, null, null, false);
// }
//
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/ParserAStar.java
// public static class SuperTaggingResults {
// public AtomicInteger parsedSentences = new AtomicInteger();
// public AtomicInteger totalSentences = new AtomicInteger();
//
// public AtomicInteger rightCats = new AtomicInteger();
// public AtomicInteger totalCats = new AtomicInteger();
//
// public AtomicInteger exactMatch = new AtomicInteger();
// }
// Path: src/uk/ac/ed/easyccg/syntax/Parser.java
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.Multimap;
import uk.ac.ed.easyccg.syntax.InputReader.InputToParser;
import uk.ac.ed.easyccg.syntax.ParserAStar.SuperTaggingResults;
package uk.ac.ed.easyccg.syntax;
public interface Parser
{
/**
* Parses a sentence, interpreting the line according to the InputReader, and returns an N-best list.
*/
public abstract List<SyntaxTreeNode> parse(String line);
/**
* Ignores the InputReader and parses the supplied list of words.
*/
public abstract List<SyntaxTreeNode> parseTokens(List<String> words);
/**
*
*/ | public abstract Iterator<List<SyntaxTreeNode>> parseFile(File file, final SuperTaggingResults results) |
mikelewis0/easyccg | src/uk/ac/ed/easyccg/syntax/Parser.java | // Path: src/uk/ac/ed/easyccg/syntax/InputReader.java
// public static class InputToParser {
// private final List<InputWord> words;
// private boolean isAlreadyTagged;
// InputToParser(List<InputWord> words, List<Category> goldCategories, List<List<SyntaxTreeNodeLeaf>> inputSupertags, boolean isAlreadyTagged)
// {
// this.words = words;
// this.goldCategories = goldCategories;
// this.inputSupertags = inputSupertags;
// this.isAlreadyTagged = isAlreadyTagged;
// }
// private final List<Category> goldCategories;
// private final List<List<SyntaxTreeNodeLeaf>> inputSupertags;
// public int length()
// {
// return words.size();
// }
//
// /**
// * If true, the Parser should not supertag the data itself, and use getInputSupertags() instead.
// */
// public boolean isAlreadyTagged()
// {
// return isAlreadyTagged;
// }
// public List<List<SyntaxTreeNodeLeaf>> getInputSupertags()
// {
// return inputSupertags;
// }
//
// public List<SyntaxTreeNodeLeaf> getInputSupertags1best()
// {
// List<SyntaxTreeNodeLeaf> result = new ArrayList<SyntaxTreeNodeLeaf>();
// for (List<SyntaxTreeNodeLeaf> tagsForWord : inputSupertags) {
// result.add(tagsForWord.get(0));
// }
// return result;
// }
// public boolean haveGoldCategories()
// {
// return getGoldCategories() != null;
// }
//
// public List<Category> getGoldCategories()
// {
// return goldCategories;
// }
//
// public List<InputWord> getInputWords() {
// return words;
//
// }
//
// public String getWordsAsString()
// {
// StringBuilder result = new StringBuilder();
// for (InputWord word : words) {
// result.append(word.word + " ");
// }
//
// return result.toString().trim();
// }
//
// public static InputToParser fromTokens(List<String> tokens) {
// List<InputWord> inputWords = new ArrayList<InputWord>(tokens.size());
// for (String word : tokens) {
// inputWords.add(new InputWord(word, null, null));
// }
// return new InputToParser(inputWords, null, null, false);
// }
//
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/ParserAStar.java
// public static class SuperTaggingResults {
// public AtomicInteger parsedSentences = new AtomicInteger();
// public AtomicInteger totalSentences = new AtomicInteger();
//
// public AtomicInteger rightCats = new AtomicInteger();
// public AtomicInteger totalCats = new AtomicInteger();
//
// public AtomicInteger exactMatch = new AtomicInteger();
// }
| import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.Multimap;
import uk.ac.ed.easyccg.syntax.InputReader.InputToParser;
import uk.ac.ed.easyccg.syntax.ParserAStar.SuperTaggingResults; | package uk.ac.ed.easyccg.syntax;
public interface Parser
{
/**
* Parses a sentence, interpreting the line according to the InputReader, and returns an N-best list.
*/
public abstract List<SyntaxTreeNode> parse(String line);
/**
* Ignores the InputReader and parses the supplied list of words.
*/
public abstract List<SyntaxTreeNode> parseTokens(List<String> words);
/**
*
*/
public abstract Iterator<List<SyntaxTreeNode>> parseFile(File file, final SuperTaggingResults results)
throws IOException;
| // Path: src/uk/ac/ed/easyccg/syntax/InputReader.java
// public static class InputToParser {
// private final List<InputWord> words;
// private boolean isAlreadyTagged;
// InputToParser(List<InputWord> words, List<Category> goldCategories, List<List<SyntaxTreeNodeLeaf>> inputSupertags, boolean isAlreadyTagged)
// {
// this.words = words;
// this.goldCategories = goldCategories;
// this.inputSupertags = inputSupertags;
// this.isAlreadyTagged = isAlreadyTagged;
// }
// private final List<Category> goldCategories;
// private final List<List<SyntaxTreeNodeLeaf>> inputSupertags;
// public int length()
// {
// return words.size();
// }
//
// /**
// * If true, the Parser should not supertag the data itself, and use getInputSupertags() instead.
// */
// public boolean isAlreadyTagged()
// {
// return isAlreadyTagged;
// }
// public List<List<SyntaxTreeNodeLeaf>> getInputSupertags()
// {
// return inputSupertags;
// }
//
// public List<SyntaxTreeNodeLeaf> getInputSupertags1best()
// {
// List<SyntaxTreeNodeLeaf> result = new ArrayList<SyntaxTreeNodeLeaf>();
// for (List<SyntaxTreeNodeLeaf> tagsForWord : inputSupertags) {
// result.add(tagsForWord.get(0));
// }
// return result;
// }
// public boolean haveGoldCategories()
// {
// return getGoldCategories() != null;
// }
//
// public List<Category> getGoldCategories()
// {
// return goldCategories;
// }
//
// public List<InputWord> getInputWords() {
// return words;
//
// }
//
// public String getWordsAsString()
// {
// StringBuilder result = new StringBuilder();
// for (InputWord word : words) {
// result.append(word.word + " ");
// }
//
// return result.toString().trim();
// }
//
// public static InputToParser fromTokens(List<String> tokens) {
// List<InputWord> inputWords = new ArrayList<InputWord>(tokens.size());
// for (String word : tokens) {
// inputWords.add(new InputWord(word, null, null));
// }
// return new InputToParser(inputWords, null, null, false);
// }
//
// }
//
// Path: src/uk/ac/ed/easyccg/syntax/ParserAStar.java
// public static class SuperTaggingResults {
// public AtomicInteger parsedSentences = new AtomicInteger();
// public AtomicInteger totalSentences = new AtomicInteger();
//
// public AtomicInteger rightCats = new AtomicInteger();
// public AtomicInteger totalCats = new AtomicInteger();
//
// public AtomicInteger exactMatch = new AtomicInteger();
// }
// Path: src/uk/ac/ed/easyccg/syntax/Parser.java
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.Multimap;
import uk.ac.ed.easyccg.syntax.InputReader.InputToParser;
import uk.ac.ed.easyccg.syntax.ParserAStar.SuperTaggingResults;
package uk.ac.ed.easyccg.syntax;
public interface Parser
{
/**
* Parses a sentence, interpreting the line according to the InputReader, and returns an N-best list.
*/
public abstract List<SyntaxTreeNode> parse(String line);
/**
* Ignores the InputReader and parses the supplied list of words.
*/
public abstract List<SyntaxTreeNode> parseTokens(List<String> words);
/**
*
*/
public abstract Iterator<List<SyntaxTreeNode>> parseFile(File file, final SuperTaggingResults results)
throws IOException;
| public abstract List<SyntaxTreeNode> parseSentence(SuperTaggingResults results, InputToParser input); |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/competition/ActiveCompetitionProducer.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
| import com.nosoftskills.predcomposer.model.Competition;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject; | /*
* Copyright 2016 Microprofile.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nosoftskills.predcomposer.competition;
@ApplicationScoped
public class ActiveCompetitionProducer {
@Inject
private CompetitionsService competitionsService;
@RequestScoped
@Produces @Active | // Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/competition/ActiveCompetitionProducer.java
import com.nosoftskills.predcomposer.model.Competition;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
/*
* Copyright 2016 Microprofile.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nosoftskills.predcomposer.competition;
@ApplicationScoped
public class ActiveCompetitionProducer {
@Inject
private CompetitionsService competitionsService;
@RequestScoped
@Produces @Active | public Competition getActiveCompetition() { |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/game/LockGameBean.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/Game.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "getRecentGames", query = "SELECT g from Game g WHERE g.gameTime <= :kickoffTime AND g.locked = FALSE")
// })
// public class Game implements Serializable, Comparable<Game> {
//
// private static final long serialVersionUID = -7167764360968863333L;
//
// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
// "dd MMM, HH:mm");
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String homeTeam;
//
// @Column(nullable = false)
// private String awayTeam;
//
// @Column
// private String result;
//
// @Column(nullable = false)
// private LocalDateTime gameTime;
//
// @OneToMany(mappedBy = "forGame", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// private boolean locked = false;
//
// public Game() {
// }
//
// public Game(String homeTeam, String awayTeam, LocalDateTime gameTime) {
// this(homeTeam, awayTeam, null, gameTime, false);
// }
//
// public Game(String homeTeam, String awayTeam, String result, LocalDateTime gameTime, boolean locked) {
// this.homeTeam = homeTeam;
// this.awayTeam = awayTeam;
// this.result = result;
// this.gameTime = gameTime;
// this.locked = locked;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getHomeTeam() {
// return homeTeam;
// }
//
// public void setHomeTeam(String homeTeam) {
// this.homeTeam = homeTeam;
// }
//
// public String getAwayTeam() {
// return awayTeam;
// }
//
// public void setAwayTeam(String awayTeam) {
// this.awayTeam = awayTeam;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public LocalDateTime getGameTime() {
// return gameTime;
// }
//
// public String getGameTimeFormatted() {
// return gameTime.format(DATE_TIME_FORMATTER);
// }
//
// public void setGameTime(LocalDateTime gameTime) {
// this.gameTime = gameTime;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return predictions;
// }
//
// public void setPredictions(
// Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// @Override
// public String toString() {
// return "Game{" +
// "id=" + id +
// ", homeTeam='" + homeTeam + '\'' +
// ", awayTeam='" + awayTeam + '\'' +
// ", result='" + result + '\'' +
// ", gameTime=" + gameTime +
// ", locked=" + locked +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Game))
// return false;
// Game game = (Game) o;
// return Objects.equals(homeTeam, game.homeTeam) &&
// Objects.equals(awayTeam, game.awayTeam) &&
// Objects.equals(gameTime, game.gameTime);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(homeTeam, awayTeam, gameTime);
// }
//
// @Override
// public int compareTo(Game game) {
// return this.getGameTime().compareTo(game.getGameTime());
// }
// }
| import com.nosoftskills.predcomposer.model.Game;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named; | package com.nosoftskills.predcomposer.game;
/**
* @author Ivan St. Ivanov
*/
@Named("gameLocker")
@ApplicationScoped
public class LockGameBean {
@Inject
private GamesService gamesService;
@Inject | // Path: src/main/java/com/nosoftskills/predcomposer/model/Game.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "getRecentGames", query = "SELECT g from Game g WHERE g.gameTime <= :kickoffTime AND g.locked = FALSE")
// })
// public class Game implements Serializable, Comparable<Game> {
//
// private static final long serialVersionUID = -7167764360968863333L;
//
// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
// "dd MMM, HH:mm");
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String homeTeam;
//
// @Column(nullable = false)
// private String awayTeam;
//
// @Column
// private String result;
//
// @Column(nullable = false)
// private LocalDateTime gameTime;
//
// @OneToMany(mappedBy = "forGame", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// private boolean locked = false;
//
// public Game() {
// }
//
// public Game(String homeTeam, String awayTeam, LocalDateTime gameTime) {
// this(homeTeam, awayTeam, null, gameTime, false);
// }
//
// public Game(String homeTeam, String awayTeam, String result, LocalDateTime gameTime, boolean locked) {
// this.homeTeam = homeTeam;
// this.awayTeam = awayTeam;
// this.result = result;
// this.gameTime = gameTime;
// this.locked = locked;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getHomeTeam() {
// return homeTeam;
// }
//
// public void setHomeTeam(String homeTeam) {
// this.homeTeam = homeTeam;
// }
//
// public String getAwayTeam() {
// return awayTeam;
// }
//
// public void setAwayTeam(String awayTeam) {
// this.awayTeam = awayTeam;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public LocalDateTime getGameTime() {
// return gameTime;
// }
//
// public String getGameTimeFormatted() {
// return gameTime.format(DATE_TIME_FORMATTER);
// }
//
// public void setGameTime(LocalDateTime gameTime) {
// this.gameTime = gameTime;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return predictions;
// }
//
// public void setPredictions(
// Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// @Override
// public String toString() {
// return "Game{" +
// "id=" + id +
// ", homeTeam='" + homeTeam + '\'' +
// ", awayTeam='" + awayTeam + '\'' +
// ", result='" + result + '\'' +
// ", gameTime=" + gameTime +
// ", locked=" + locked +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Game))
// return false;
// Game game = (Game) o;
// return Objects.equals(homeTeam, game.homeTeam) &&
// Objects.equals(awayTeam, game.awayTeam) &&
// Objects.equals(gameTime, game.gameTime);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(homeTeam, awayTeam, gameTime);
// }
//
// @Override
// public int compareTo(Game game) {
// return this.getGameTime().compareTo(game.getGameTime());
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/game/LockGameBean.java
import com.nosoftskills.predcomposer.model.Game;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;
package com.nosoftskills.predcomposer.game;
/**
* @author Ivan St. Ivanov
*/
@Named("gameLocker")
@ApplicationScoped
public class LockGameBean {
@Inject
private GamesService gamesService;
@Inject | private Event<Game> gameEvent; |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | PredictionsServiceAlternative.class, UserContextAlternative.class |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | PredictionsServiceAlternative.class, UserContextAlternative.class |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({
PredictionsServiceAlternative.class, UserContextAlternative.class
})
public class ViewGamePredictionsBeanTest {
@Inject
private ViewGamePredictionsBean bean;
@Test
@InRequestScope
public void shouldLoadGamePredictionsUponRequest() throws Exception { | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/common/TestData.java
// public static Game game2;
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewGamePredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static com.nosoftskills.predcomposer.common.TestData.game2;
import static org.junit.Assert.assertEquals;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({
PredictionsServiceAlternative.class, UserContextAlternative.class
})
public class ViewGamePredictionsBeanTest {
@Inject
private ViewGamePredictionsBean bean;
@Test
@InRequestScope
public void shouldLoadGamePredictionsUponRequest() throws Exception { | bean.showGamePredictions(game2); |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/browser/scenarios/LoginScenarioTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/HomePage.java
// @Location("home.xhtml")
// public class HomePage {
//
// @FindBy
// private WebElement greeting;
//
// @FindBy
// private WebElement addNewGameForm;
//
// public void assertGreetingMessage(String expectedUserName) {
// assertEquals("Hello, " + expectedUserName, greeting.getText());
// }
//
// public void assertGameFormVisible(boolean shouldBeVisible) {
// try {
// assertEquals(shouldBeVisible, addNewGameForm.isDisplayed());
// } catch (NoSuchElementException nsee) {
// if (shouldBeVisible) {
// fail();
// }
// }
//
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/LoginPage.java
// @Location("login.xhtml")
// public class LoginPage {
//
// @FindBy(id = "loginForm:userName")
// private WebElement userName;
//
// @FindBy(id = "loginForm:password")
// private WebElement password;
//
// @FindBy(id = "loginForm:login")
// private WebElement loginButton;
//
// @FindBy
// private WebElement loginErrorMessage;
//
// public void login(String userName, String password) {
// this.userName.sendKeys(userName);
// this.password.sendKeys(password);
// guardHttp(loginButton).click();
// }
//
// public void assertWrongCredentialsMessage() {
// assertTrue(loginErrorMessage.isDisplayed());
// }
//
// public void assertIsLoaded() {
// assertTrue(this.userName.isDisplayed());
// }
// }
| import com.nosoftskills.predcomposer.browser.pages.HomePage;
import com.nosoftskills.predcomposer.browser.pages.LoginPage;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.InitialPage;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver; | package com.nosoftskills.predcomposer.browser.scenarios;
/**
* @author Ivan St. Ivanov
*/
@RunWith(Arquillian.class)
@RunAsClient
public class LoginScenarioTest {
@Drone
private WebDriver browser;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return Deployments.createDeployment();
}
@Page | // Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/HomePage.java
// @Location("home.xhtml")
// public class HomePage {
//
// @FindBy
// private WebElement greeting;
//
// @FindBy
// private WebElement addNewGameForm;
//
// public void assertGreetingMessage(String expectedUserName) {
// assertEquals("Hello, " + expectedUserName, greeting.getText());
// }
//
// public void assertGameFormVisible(boolean shouldBeVisible) {
// try {
// assertEquals(shouldBeVisible, addNewGameForm.isDisplayed());
// } catch (NoSuchElementException nsee) {
// if (shouldBeVisible) {
// fail();
// }
// }
//
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/LoginPage.java
// @Location("login.xhtml")
// public class LoginPage {
//
// @FindBy(id = "loginForm:userName")
// private WebElement userName;
//
// @FindBy(id = "loginForm:password")
// private WebElement password;
//
// @FindBy(id = "loginForm:login")
// private WebElement loginButton;
//
// @FindBy
// private WebElement loginErrorMessage;
//
// public void login(String userName, String password) {
// this.userName.sendKeys(userName);
// this.password.sendKeys(password);
// guardHttp(loginButton).click();
// }
//
// public void assertWrongCredentialsMessage() {
// assertTrue(loginErrorMessage.isDisplayed());
// }
//
// public void assertIsLoaded() {
// assertTrue(this.userName.isDisplayed());
// }
// }
// Path: src/test/java/com/nosoftskills/predcomposer/browser/scenarios/LoginScenarioTest.java
import com.nosoftskills.predcomposer.browser.pages.HomePage;
import com.nosoftskills.predcomposer.browser.pages.LoginPage;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.InitialPage;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
package com.nosoftskills.predcomposer.browser.scenarios;
/**
* @author Ivan St. Ivanov
*/
@RunWith(Arquillian.class)
@RunAsClient
public class LoginScenarioTest {
@Drone
private WebDriver browser;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return Deployments.createDeployment();
}
@Page | private HomePage homePage; |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/browser/scenarios/LoginScenarioTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/HomePage.java
// @Location("home.xhtml")
// public class HomePage {
//
// @FindBy
// private WebElement greeting;
//
// @FindBy
// private WebElement addNewGameForm;
//
// public void assertGreetingMessage(String expectedUserName) {
// assertEquals("Hello, " + expectedUserName, greeting.getText());
// }
//
// public void assertGameFormVisible(boolean shouldBeVisible) {
// try {
// assertEquals(shouldBeVisible, addNewGameForm.isDisplayed());
// } catch (NoSuchElementException nsee) {
// if (shouldBeVisible) {
// fail();
// }
// }
//
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/LoginPage.java
// @Location("login.xhtml")
// public class LoginPage {
//
// @FindBy(id = "loginForm:userName")
// private WebElement userName;
//
// @FindBy(id = "loginForm:password")
// private WebElement password;
//
// @FindBy(id = "loginForm:login")
// private WebElement loginButton;
//
// @FindBy
// private WebElement loginErrorMessage;
//
// public void login(String userName, String password) {
// this.userName.sendKeys(userName);
// this.password.sendKeys(password);
// guardHttp(loginButton).click();
// }
//
// public void assertWrongCredentialsMessage() {
// assertTrue(loginErrorMessage.isDisplayed());
// }
//
// public void assertIsLoaded() {
// assertTrue(this.userName.isDisplayed());
// }
// }
| import com.nosoftskills.predcomposer.browser.pages.HomePage;
import com.nosoftskills.predcomposer.browser.pages.LoginPage;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.InitialPage;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver; | package com.nosoftskills.predcomposer.browser.scenarios;
/**
* @author Ivan St. Ivanov
*/
@RunWith(Arquillian.class)
@RunAsClient
public class LoginScenarioTest {
@Drone
private WebDriver browser;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return Deployments.createDeployment();
}
@Page
private HomePage homePage;
@Page | // Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/HomePage.java
// @Location("home.xhtml")
// public class HomePage {
//
// @FindBy
// private WebElement greeting;
//
// @FindBy
// private WebElement addNewGameForm;
//
// public void assertGreetingMessage(String expectedUserName) {
// assertEquals("Hello, " + expectedUserName, greeting.getText());
// }
//
// public void assertGameFormVisible(boolean shouldBeVisible) {
// try {
// assertEquals(shouldBeVisible, addNewGameForm.isDisplayed());
// } catch (NoSuchElementException nsee) {
// if (shouldBeVisible) {
// fail();
// }
// }
//
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/browser/pages/LoginPage.java
// @Location("login.xhtml")
// public class LoginPage {
//
// @FindBy(id = "loginForm:userName")
// private WebElement userName;
//
// @FindBy(id = "loginForm:password")
// private WebElement password;
//
// @FindBy(id = "loginForm:login")
// private WebElement loginButton;
//
// @FindBy
// private WebElement loginErrorMessage;
//
// public void login(String userName, String password) {
// this.userName.sendKeys(userName);
// this.password.sendKeys(password);
// guardHttp(loginButton).click();
// }
//
// public void assertWrongCredentialsMessage() {
// assertTrue(loginErrorMessage.isDisplayed());
// }
//
// public void assertIsLoaded() {
// assertTrue(this.userName.isDisplayed());
// }
// }
// Path: src/test/java/com/nosoftskills/predcomposer/browser/scenarios/LoginScenarioTest.java
import com.nosoftskills.predcomposer.browser.pages.HomePage;
import com.nosoftskills.predcomposer.browser.pages.LoginPage;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.InitialPage;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
package com.nosoftskills.predcomposer.browser.scenarios;
/**
* @author Ivan St. Ivanov
*/
@RunWith(Arquillian.class)
@RunAsClient
public class LoginScenarioTest {
@Drone
private WebDriver browser;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return Deployments.createDeployment();
}
@Page
private HomePage homePage;
@Page | private LoginPage loginPage; |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/session/UserContext.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/User.java
// @Entity
// @XmlRootElement
// @Table(name = "Users")
// @NamedQueries({
// @NamedQuery(name = "findUserByNameAndPassword", query = "SELECT u FROM User u WHERE u.userName = :userName AND u.password = :password"),
// @NamedQuery(name = "getAllUsers", query = "SELECT u FROM User u")
// })
// public class User implements Serializable {
//
// private static final long serialVersionUID = -3718072367022295097L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String userName;
//
// @Column(nullable = false)
// private String password;
//
// @Column(nullable = false)
// private String email;
//
// private String firstName;
//
// private String lastName;
//
// @Column(nullable = false)
// private Boolean isAdmin = false;
//
// @Lob
// private byte[] avatar;
//
// @OneToMany(mappedBy = "byUser", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// public User() {
// }
//
// public User(String userName, String password, String email) {
// this(userName, password, email, null, null, false);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean isAdmin) {
// this(userName, password, email, firstName, lastName, isAdmin, null);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean admin, byte[] avatar) {
// this.userName = userName;
// this.password = password;
// this.email = email;
// this.firstName = firstName;
// this.lastName = lastName;
// this.isAdmin = admin;
// this.avatar = avatar;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @XmlTransient
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public Boolean getIsAdmin() {
// return isAdmin;
// }
//
// public void setIsAdmin(Boolean admin) {
// this.isAdmin = admin;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return this.predictions;
// }
//
// public void setPredictions(final Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public byte[] getAvatar() {
// return avatar;
// }
//
// public void setAvatar(byte[] avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// ", firstName='" + firstName + '\'' +
// ", lastName='" + lastName + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof User))
// return false;
// User user = (User) o;
// return Objects.equals(userName, user.userName)
// && Objects.equals(password, user.password)
// && Objects.equals(email, user.email)
// && Objects.equals(isAdmin, user.isAdmin);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(userName, password, email, isAdmin);
// }
// }
| import com.nosoftskills.predcomposer.model.User;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.io.Serializable; | package com.nosoftskills.predcomposer.session;
/**
* @author Ivan St. Ivanov
*/
@SessionScoped
@Named("userContext")
public class UserContext implements Serializable {
private static final long serialVersionUID = -1047249575365658031L;
| // Path: src/main/java/com/nosoftskills/predcomposer/model/User.java
// @Entity
// @XmlRootElement
// @Table(name = "Users")
// @NamedQueries({
// @NamedQuery(name = "findUserByNameAndPassword", query = "SELECT u FROM User u WHERE u.userName = :userName AND u.password = :password"),
// @NamedQuery(name = "getAllUsers", query = "SELECT u FROM User u")
// })
// public class User implements Serializable {
//
// private static final long serialVersionUID = -3718072367022295097L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String userName;
//
// @Column(nullable = false)
// private String password;
//
// @Column(nullable = false)
// private String email;
//
// private String firstName;
//
// private String lastName;
//
// @Column(nullable = false)
// private Boolean isAdmin = false;
//
// @Lob
// private byte[] avatar;
//
// @OneToMany(mappedBy = "byUser", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// public User() {
// }
//
// public User(String userName, String password, String email) {
// this(userName, password, email, null, null, false);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean isAdmin) {
// this(userName, password, email, firstName, lastName, isAdmin, null);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean admin, byte[] avatar) {
// this.userName = userName;
// this.password = password;
// this.email = email;
// this.firstName = firstName;
// this.lastName = lastName;
// this.isAdmin = admin;
// this.avatar = avatar;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @XmlTransient
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public Boolean getIsAdmin() {
// return isAdmin;
// }
//
// public void setIsAdmin(Boolean admin) {
// this.isAdmin = admin;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return this.predictions;
// }
//
// public void setPredictions(final Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public byte[] getAvatar() {
// return avatar;
// }
//
// public void setAvatar(byte[] avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// ", firstName='" + firstName + '\'' +
// ", lastName='" + lastName + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof User))
// return false;
// User user = (User) o;
// return Objects.equals(userName, user.userName)
// && Objects.equals(password, user.password)
// && Objects.equals(email, user.email)
// && Objects.equals(isAdmin, user.isAdmin);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(userName, password, email, isAdmin);
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/session/UserContext.java
import com.nosoftskills.predcomposer.model.User;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.io.Serializable;
package com.nosoftskills.predcomposer.session;
/**
* @author Ivan St. Ivanov
*/
@SessionScoped
@Named("userContext")
public class UserContext implements Serializable {
private static final long serialVersionUID = -1047249575365658031L;
| private User loggedUser; |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/user/UsersService.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/User.java
// @Entity
// @XmlRootElement
// @Table(name = "Users")
// @NamedQueries({
// @NamedQuery(name = "findUserByNameAndPassword", query = "SELECT u FROM User u WHERE u.userName = :userName AND u.password = :password"),
// @NamedQuery(name = "getAllUsers", query = "SELECT u FROM User u")
// })
// public class User implements Serializable {
//
// private static final long serialVersionUID = -3718072367022295097L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String userName;
//
// @Column(nullable = false)
// private String password;
//
// @Column(nullable = false)
// private String email;
//
// private String firstName;
//
// private String lastName;
//
// @Column(nullable = false)
// private Boolean isAdmin = false;
//
// @Lob
// private byte[] avatar;
//
// @OneToMany(mappedBy = "byUser", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// public User() {
// }
//
// public User(String userName, String password, String email) {
// this(userName, password, email, null, null, false);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean isAdmin) {
// this(userName, password, email, firstName, lastName, isAdmin, null);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean admin, byte[] avatar) {
// this.userName = userName;
// this.password = password;
// this.email = email;
// this.firstName = firstName;
// this.lastName = lastName;
// this.isAdmin = admin;
// this.avatar = avatar;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @XmlTransient
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public Boolean getIsAdmin() {
// return isAdmin;
// }
//
// public void setIsAdmin(Boolean admin) {
// this.isAdmin = admin;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return this.predictions;
// }
//
// public void setPredictions(final Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public byte[] getAvatar() {
// return avatar;
// }
//
// public void setAvatar(byte[] avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// ", firstName='" + firstName + '\'' +
// ", lastName='" + lastName + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof User))
// return false;
// User user = (User) o;
// return Objects.equals(userName, user.userName)
// && Objects.equals(password, user.password)
// && Objects.equals(email, user.email)
// && Objects.equals(isAdmin, user.isAdmin);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(userName, password, email, isAdmin);
// }
// }
| import com.nosoftskills.predcomposer.model.User;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List; | package com.nosoftskills.predcomposer.user;
/**
* @author Ivan St. Ivanov
*/
@Stateless
public class UsersService {
@PersistenceContext
private EntityManager entityManager;
| // Path: src/main/java/com/nosoftskills/predcomposer/model/User.java
// @Entity
// @XmlRootElement
// @Table(name = "Users")
// @NamedQueries({
// @NamedQuery(name = "findUserByNameAndPassword", query = "SELECT u FROM User u WHERE u.userName = :userName AND u.password = :password"),
// @NamedQuery(name = "getAllUsers", query = "SELECT u FROM User u")
// })
// public class User implements Serializable {
//
// private static final long serialVersionUID = -3718072367022295097L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String userName;
//
// @Column(nullable = false)
// private String password;
//
// @Column(nullable = false)
// private String email;
//
// private String firstName;
//
// private String lastName;
//
// @Column(nullable = false)
// private Boolean isAdmin = false;
//
// @Lob
// private byte[] avatar;
//
// @OneToMany(mappedBy = "byUser", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// public User() {
// }
//
// public User(String userName, String password, String email) {
// this(userName, password, email, null, null, false);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean isAdmin) {
// this(userName, password, email, firstName, lastName, isAdmin, null);
// }
//
// public User(String userName, String password, String email,
// String firstName, String lastName, boolean admin, byte[] avatar) {
// this.userName = userName;
// this.password = password;
// this.email = email;
// this.firstName = firstName;
// this.lastName = lastName;
// this.isAdmin = admin;
// this.avatar = avatar;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// @XmlTransient
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public Boolean getIsAdmin() {
// return isAdmin;
// }
//
// public void setIsAdmin(Boolean admin) {
// this.isAdmin = admin;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return this.predictions;
// }
//
// public void setPredictions(final Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public byte[] getAvatar() {
// return avatar;
// }
//
// public void setAvatar(byte[] avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", userName='" + userName + '\'' +
// ", password='" + password + '\'' +
// ", email='" + email + '\'' +
// ", firstName='" + firstName + '\'' +
// ", lastName='" + lastName + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof User))
// return false;
// User user = (User) o;
// return Objects.equals(userName, user.userName)
// && Objects.equals(password, user.password)
// && Objects.equals(email, user.email)
// && Objects.equals(isAdmin, user.isAdmin);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(userName, password, email, isAdmin);
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/user/UsersService.java
import com.nosoftskills.predcomposer.model.User;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
package com.nosoftskills.predcomposer.user;
/**
* @author Ivan St. Ivanov
*/
@Stateless
public class UsersService {
@PersistenceContext
private EntityManager entityManager;
| public List<User> getAllUsers() { |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/game/AutomaticGameLocker.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/Game.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "getRecentGames", query = "SELECT g from Game g WHERE g.gameTime <= :kickoffTime AND g.locked = FALSE")
// })
// public class Game implements Serializable, Comparable<Game> {
//
// private static final long serialVersionUID = -7167764360968863333L;
//
// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
// "dd MMM, HH:mm");
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String homeTeam;
//
// @Column(nullable = false)
// private String awayTeam;
//
// @Column
// private String result;
//
// @Column(nullable = false)
// private LocalDateTime gameTime;
//
// @OneToMany(mappedBy = "forGame", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// private boolean locked = false;
//
// public Game() {
// }
//
// public Game(String homeTeam, String awayTeam, LocalDateTime gameTime) {
// this(homeTeam, awayTeam, null, gameTime, false);
// }
//
// public Game(String homeTeam, String awayTeam, String result, LocalDateTime gameTime, boolean locked) {
// this.homeTeam = homeTeam;
// this.awayTeam = awayTeam;
// this.result = result;
// this.gameTime = gameTime;
// this.locked = locked;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getHomeTeam() {
// return homeTeam;
// }
//
// public void setHomeTeam(String homeTeam) {
// this.homeTeam = homeTeam;
// }
//
// public String getAwayTeam() {
// return awayTeam;
// }
//
// public void setAwayTeam(String awayTeam) {
// this.awayTeam = awayTeam;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public LocalDateTime getGameTime() {
// return gameTime;
// }
//
// public String getGameTimeFormatted() {
// return gameTime.format(DATE_TIME_FORMATTER);
// }
//
// public void setGameTime(LocalDateTime gameTime) {
// this.gameTime = gameTime;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return predictions;
// }
//
// public void setPredictions(
// Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// @Override
// public String toString() {
// return "Game{" +
// "id=" + id +
// ", homeTeam='" + homeTeam + '\'' +
// ", awayTeam='" + awayTeam + '\'' +
// ", result='" + result + '\'' +
// ", gameTime=" + gameTime +
// ", locked=" + locked +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Game))
// return false;
// Game game = (Game) o;
// return Objects.equals(homeTeam, game.homeTeam) &&
// Objects.equals(awayTeam, game.awayTeam) &&
// Objects.equals(gameTime, game.gameTime);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(homeTeam, awayTeam, gameTime);
// }
//
// @Override
// public int compareTo(Game game) {
// return this.getGameTime().compareTo(game.getGameTime());
// }
// }
| import com.nosoftskills.predcomposer.model.Game;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.time.LocalDateTime; | package com.nosoftskills.predcomposer.game;
/**
* @author Ivan St. Ivanov
*/
@Singleton
public class AutomaticGameLocker {
@PersistenceContext
private EntityManager entityManager;
@Inject | // Path: src/main/java/com/nosoftskills/predcomposer/model/Game.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "getRecentGames", query = "SELECT g from Game g WHERE g.gameTime <= :kickoffTime AND g.locked = FALSE")
// })
// public class Game implements Serializable, Comparable<Game> {
//
// private static final long serialVersionUID = -7167764360968863333L;
//
// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
// "dd MMM, HH:mm");
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String homeTeam;
//
// @Column(nullable = false)
// private String awayTeam;
//
// @Column
// private String result;
//
// @Column(nullable = false)
// private LocalDateTime gameTime;
//
// @OneToMany(mappedBy = "forGame", cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Prediction> predictions = new HashSet<>();
//
// private boolean locked = false;
//
// public Game() {
// }
//
// public Game(String homeTeam, String awayTeam, LocalDateTime gameTime) {
// this(homeTeam, awayTeam, null, gameTime, false);
// }
//
// public Game(String homeTeam, String awayTeam, String result, LocalDateTime gameTime, boolean locked) {
// this.homeTeam = homeTeam;
// this.awayTeam = awayTeam;
// this.result = result;
// this.gameTime = gameTime;
// this.locked = locked;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getHomeTeam() {
// return homeTeam;
// }
//
// public void setHomeTeam(String homeTeam) {
// this.homeTeam = homeTeam;
// }
//
// public String getAwayTeam() {
// return awayTeam;
// }
//
// public void setAwayTeam(String awayTeam) {
// this.awayTeam = awayTeam;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public LocalDateTime getGameTime() {
// return gameTime;
// }
//
// public String getGameTimeFormatted() {
// return gameTime.format(DATE_TIME_FORMATTER);
// }
//
// public void setGameTime(LocalDateTime gameTime) {
// this.gameTime = gameTime;
// }
//
// @XmlTransient
// public Set<Prediction> getPredictions() {
// return predictions;
// }
//
// public void setPredictions(
// Set<Prediction> predictions) {
// this.predictions = predictions;
// }
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// @Override
// public String toString() {
// return "Game{" +
// "id=" + id +
// ", homeTeam='" + homeTeam + '\'' +
// ", awayTeam='" + awayTeam + '\'' +
// ", result='" + result + '\'' +
// ", gameTime=" + gameTime +
// ", locked=" + locked +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Game))
// return false;
// Game game = (Game) o;
// return Objects.equals(homeTeam, game.homeTeam) &&
// Objects.equals(awayTeam, game.awayTeam) &&
// Objects.equals(gameTime, game.gameTime);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(homeTeam, awayTeam, gameTime);
// }
//
// @Override
// public int compareTo(Game game) {
// return this.getGameTime().compareTo(game.getGameTime());
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/game/AutomaticGameLocker.java
import com.nosoftskills.predcomposer.model.Game;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.time.LocalDateTime;
package com.nosoftskills.predcomposer.game;
/**
* @author Ivan St. Ivanov
*/
@Singleton
public class AutomaticGameLocker {
@PersistenceContext
private EntityManager entityManager;
@Inject | private Event<Game> gameEvent; |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/rest/resources/CompetitionResource.java | // Path: src/main/java/com/nosoftskills/predcomposer/competition/CompetitionsService.java
// @Stateless
// public class CompetitionsService implements Serializable {
//
// public static final String DEFAULT_COMPETITION_NAME = "Champions League 2016-2017";
//
// private static final long serialVersionUID = 7432416155835050214L;
//
// @PersistenceContext
// EntityManager entityManager;
//
// private static Competition activeCompetition;
//
// public Competition findCompetitionById(Long competitionId) {
// return entityManager.find(Competition.class, competitionId);
// }
//
//
// public Competition findActiveCompetition() {
// if (activeCompetition == null) {
// TypedQuery<Competition> competitionQuery = entityManager.createQuery("SELECT c FROM Competition c WHERE c.name = :defaultCompetition", Competition.class);
// competitionQuery.setParameter("defaultCompetition", DEFAULT_COMPETITION_NAME);
// activeCompetition = competitionQuery.getSingleResult();
// }
// return activeCompetition;
// }
//
// public Competition storeCompetition(Competition competition) {
// if (competition.getId() == null) {
// entityManager.persist(competition);
// return competition;
// } else {
// return entityManager.merge(competition);
// }
// }
//
// public Set<Game> getGamesForCompetition(Competition selectedCompetition) {
// Competition mergedCompetition = entityManager.merge(selectedCompetition);
// return mergedCompetition.getGames();
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
| import com.nosoftskills.predcomposer.competition.CompetitionsService;
import com.nosoftskills.predcomposer.model.Competition;
import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI; | package com.nosoftskills.predcomposer.rest.resources;
/**
* @author Ivan St. Ivanov
*/
@Path(CompetitionResource.COMPETITION_RESOURCE_ROOT)
public class CompetitionResource {
static final String COMPETITION_RESOURCE_ROOT = "/competition";
@Inject | // Path: src/main/java/com/nosoftskills/predcomposer/competition/CompetitionsService.java
// @Stateless
// public class CompetitionsService implements Serializable {
//
// public static final String DEFAULT_COMPETITION_NAME = "Champions League 2016-2017";
//
// private static final long serialVersionUID = 7432416155835050214L;
//
// @PersistenceContext
// EntityManager entityManager;
//
// private static Competition activeCompetition;
//
// public Competition findCompetitionById(Long competitionId) {
// return entityManager.find(Competition.class, competitionId);
// }
//
//
// public Competition findActiveCompetition() {
// if (activeCompetition == null) {
// TypedQuery<Competition> competitionQuery = entityManager.createQuery("SELECT c FROM Competition c WHERE c.name = :defaultCompetition", Competition.class);
// competitionQuery.setParameter("defaultCompetition", DEFAULT_COMPETITION_NAME);
// activeCompetition = competitionQuery.getSingleResult();
// }
// return activeCompetition;
// }
//
// public Competition storeCompetition(Competition competition) {
// if (competition.getId() == null) {
// entityManager.persist(competition);
// return competition;
// } else {
// return entityManager.merge(competition);
// }
// }
//
// public Set<Game> getGamesForCompetition(Competition selectedCompetition) {
// Competition mergedCompetition = entityManager.merge(selectedCompetition);
// return mergedCompetition.getGames();
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/rest/resources/CompetitionResource.java
import com.nosoftskills.predcomposer.competition.CompetitionsService;
import com.nosoftskills.predcomposer.model.Competition;
import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
package com.nosoftskills.predcomposer.rest.resources;
/**
* @author Ivan St. Ivanov
*/
@Path(CompetitionResource.COMPETITION_RESOURCE_ROOT)
public class CompetitionResource {
static final String COMPETITION_RESOURCE_ROOT = "/competition";
@Inject | private CompetitionsService competitionsService; |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/rest/resources/CompetitionResource.java | // Path: src/main/java/com/nosoftskills/predcomposer/competition/CompetitionsService.java
// @Stateless
// public class CompetitionsService implements Serializable {
//
// public static final String DEFAULT_COMPETITION_NAME = "Champions League 2016-2017";
//
// private static final long serialVersionUID = 7432416155835050214L;
//
// @PersistenceContext
// EntityManager entityManager;
//
// private static Competition activeCompetition;
//
// public Competition findCompetitionById(Long competitionId) {
// return entityManager.find(Competition.class, competitionId);
// }
//
//
// public Competition findActiveCompetition() {
// if (activeCompetition == null) {
// TypedQuery<Competition> competitionQuery = entityManager.createQuery("SELECT c FROM Competition c WHERE c.name = :defaultCompetition", Competition.class);
// competitionQuery.setParameter("defaultCompetition", DEFAULT_COMPETITION_NAME);
// activeCompetition = competitionQuery.getSingleResult();
// }
// return activeCompetition;
// }
//
// public Competition storeCompetition(Competition competition) {
// if (competition.getId() == null) {
// entityManager.persist(competition);
// return competition;
// } else {
// return entityManager.merge(competition);
// }
// }
//
// public Set<Game> getGamesForCompetition(Competition selectedCompetition) {
// Competition mergedCompetition = entityManager.merge(selectedCompetition);
// return mergedCompetition.getGames();
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
| import com.nosoftskills.predcomposer.competition.CompetitionsService;
import com.nosoftskills.predcomposer.model.Competition;
import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI; | package com.nosoftskills.predcomposer.rest.resources;
/**
* @author Ivan St. Ivanov
*/
@Path(CompetitionResource.COMPETITION_RESOURCE_ROOT)
public class CompetitionResource {
static final String COMPETITION_RESOURCE_ROOT = "/competition";
@Inject
private CompetitionsService competitionsService;
@GET
@Path("{id}")
@Produces("application/json")
public Response findCompetitionById(@PathParam("id") String id) { | // Path: src/main/java/com/nosoftskills/predcomposer/competition/CompetitionsService.java
// @Stateless
// public class CompetitionsService implements Serializable {
//
// public static final String DEFAULT_COMPETITION_NAME = "Champions League 2016-2017";
//
// private static final long serialVersionUID = 7432416155835050214L;
//
// @PersistenceContext
// EntityManager entityManager;
//
// private static Competition activeCompetition;
//
// public Competition findCompetitionById(Long competitionId) {
// return entityManager.find(Competition.class, competitionId);
// }
//
//
// public Competition findActiveCompetition() {
// if (activeCompetition == null) {
// TypedQuery<Competition> competitionQuery = entityManager.createQuery("SELECT c FROM Competition c WHERE c.name = :defaultCompetition", Competition.class);
// competitionQuery.setParameter("defaultCompetition", DEFAULT_COMPETITION_NAME);
// activeCompetition = competitionQuery.getSingleResult();
// }
// return activeCompetition;
// }
//
// public Competition storeCompetition(Competition competition) {
// if (competition.getId() == null) {
// entityManager.persist(competition);
// return competition;
// } else {
// return entityManager.merge(competition);
// }
// }
//
// public Set<Game> getGamesForCompetition(Competition selectedCompetition) {
// Competition mergedCompetition = entityManager.merge(selectedCompetition);
// return mergedCompetition.getGames();
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Competition.java
// @Entity
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "findCompetitionByName", query = "SELECT c FROM Competition c WHERE c.name = :competitionName"),
// })
// public class Competition implements Serializable {
//
// private static final long serialVersionUID = 7251381689096178933L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @Column(nullable = false)
// private String name;
//
// private String description;
//
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
// private Set<Game> games = new HashSet<>();
//
// public Competition() {
// }
//
// public Competition(String name) {
// this(name, "");
// }
//
// public Competition(String name, String description) {
// this.name = name;
// this.description = description;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// @XmlTransient
// public Set<Game> getGames() {
// return games;
// }
//
// public void setGames(Set<Game> games) {
// this.games = games;
// }
//
// @Override
// public String toString() {
// return "Competition{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Competition))
// return false;
// Competition that = (Competition) o;
// return Objects.equals(name, that.name) &&
// Objects.equals(description, that.description);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(name, description);
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/rest/resources/CompetitionResource.java
import com.nosoftskills.predcomposer.competition.CompetitionsService;
import com.nosoftskills.predcomposer.model.Competition;
import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
package com.nosoftskills.predcomposer.rest.resources;
/**
* @author Ivan St. Ivanov
*/
@Path(CompetitionResource.COMPETITION_RESOURCE_ROOT)
public class CompetitionResource {
static final String COMPETITION_RESOURCE_ROOT = "/competition";
@Inject
private CompetitionsService competitionsService;
@GET
@Path("{id}")
@Produces("application/json")
public Response findCompetitionById(@PathParam("id") String id) { | Competition competition = competitionsService.findCompetitionById(Long.parseLong(id)); |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBean.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/session/UserContext.java
// @SessionScoped
// @Named("userContext")
// public class UserContext implements Serializable {
//
// private static final long serialVersionUID = -1047249575365658031L;
//
// private User loggedUser;
//
// public User getLoggedUser() {
// return loggedUser;
// }
//
// public void setLoggedUser(User loggedUser) {
// this.loggedUser = loggedUser;
// }
// }
| import com.nosoftskills.predcomposer.model.Prediction;
import com.nosoftskills.predcomposer.session.UserContext;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@Named("userPredictionsViewer")
@SessionScoped
public class ViewUserPredictionsBean implements Serializable {
private static final long serialVersionUID = -7671166619622273176L;
| // Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/session/UserContext.java
// @SessionScoped
// @Named("userContext")
// public class UserContext implements Serializable {
//
// private static final long serialVersionUID = -1047249575365658031L;
//
// private User loggedUser;
//
// public User getLoggedUser() {
// return loggedUser;
// }
//
// public void setLoggedUser(User loggedUser) {
// this.loggedUser = loggedUser;
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBean.java
import com.nosoftskills.predcomposer.model.Prediction;
import com.nosoftskills.predcomposer.session.UserContext;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@Named("userPredictionsViewer")
@SessionScoped
public class ViewUserPredictionsBean implements Serializable {
private static final long serialVersionUID = -7671166619622273176L;
| private Map<Long, Prediction> userPredictions = new HashMap<>(); |
ivannov/predcomposer | src/main/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBean.java | // Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/session/UserContext.java
// @SessionScoped
// @Named("userContext")
// public class UserContext implements Serializable {
//
// private static final long serialVersionUID = -1047249575365658031L;
//
// private User loggedUser;
//
// public User getLoggedUser() {
// return loggedUser;
// }
//
// public void setLoggedUser(User loggedUser) {
// this.loggedUser = loggedUser;
// }
// }
| import com.nosoftskills.predcomposer.model.Prediction;
import com.nosoftskills.predcomposer.session.UserContext;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@Named("userPredictionsViewer")
@SessionScoped
public class ViewUserPredictionsBean implements Serializable {
private static final long serialVersionUID = -7671166619622273176L;
private Map<Long, Prediction> userPredictions = new HashMap<>();
@Inject | // Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/session/UserContext.java
// @SessionScoped
// @Named("userContext")
// public class UserContext implements Serializable {
//
// private static final long serialVersionUID = -1047249575365658031L;
//
// private User loggedUser;
//
// public User getLoggedUser() {
// return loggedUser;
// }
//
// public void setLoggedUser(User loggedUser) {
// this.loggedUser = loggedUser;
// }
// }
// Path: src/main/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBean.java
import com.nosoftskills.predcomposer.model.Prediction;
import com.nosoftskills.predcomposer.session.UserContext;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@Named("userPredictionsViewer")
@SessionScoped
public class ViewUserPredictionsBean implements Serializable {
private static final long serialVersionUID = -7671166619622273176L;
private Map<Long, Prediction> userPredictions = new HashMap<>();
@Inject | private UserContext userContext; |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | PredictionsServiceAlternative.class, UserContextAlternative.class |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({ | PredictionsServiceAlternative.class, UserContextAlternative.class |
ivannov/predcomposer | src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
| import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; | package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({
PredictionsServiceAlternative.class, UserContextAlternative.class
})
public class ViewUserPredictionsBeanTest {
@Inject
private ViewUserPredictionsBean bean;
@Test
@InRequestScope
public void shouldLoadUserPredictionsUponStartup() throws Exception { | // Path: src/test/java/com/nosoftskills/predcomposer/alternatives/PredictionsServiceAlternative.java
// @Alternative
// public class PredictionsServiceAlternative extends PredictionsService {
//
// private static Set<Prediction> ivansPredictions = new HashSet<>();
// private static Set<Prediction> kokosPredictions = new HashSet<>();
//
// private static Set<Prediction> game3Predictions = new HashSet<>();
// private static Set<Prediction> game2Predictions = new HashSet<>();
//
// static {
// ivansPredictions.addAll(Arrays.asList(prediction1, prediction3));
// kokosPredictions.add(prediction2);
//
// game2Predictions.addAll(Arrays.asList(prediction1, prediction2));
// game3Predictions.add(prediction3);
// }
//
// @Override
// public Set<Prediction> getPredictionsForUser(User user) {
// switch (user.getUserName()) {
// case "ivan":
// return ivansPredictions;
// case "koko":
// return kokosPredictions;
// default:
// return null;
// }
// }
//
// @Override
// public Set<Prediction> getPredictionsForGame(Game game) {
// if (game.equals(game1)) {
// return game3Predictions;
// } else if (game.equals(game2)) {
// return game2Predictions;
// } else {
// return null;
// }
// }
// }
//
// Path: src/test/java/com/nosoftskills/predcomposer/alternatives/UserContextAlternative.java
// @Alternative
// @SessionScoped
// public class UserContextAlternative extends UserContext {
//
// @Override
// public User getLoggedUser() {
// return user1;
// }
//
// }
//
// Path: src/main/java/com/nosoftskills/predcomposer/model/Prediction.java
// @Entity
// @XmlRootElement
// public class Prediction implements Serializable {
//
// private static final long serialVersionUID = -5531972294380467582L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private Long id;
//
// @Version
// private int version;
//
// @ManyToOne
// private User byUser;
//
// @ManyToOne
// private Game forGame;
//
// private String predictedResult;
//
// public Prediction() {
// }
//
// public Prediction(User byUser, Game forGame, String predictedResult) {
// this.byUser = byUser;
// this.forGame = forGame;
// this.predictedResult = predictedResult;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @XmlTransient
// public int getVersion() {
// return version;
// }
//
// public void setVersion(int version) {
// this.version = version;
// }
//
// public User getByUser() {
// return byUser;
// }
//
// public void setByUser(User byUser) {
// this.byUser = byUser;
// }
//
// public Game getForGame() {
// return forGame;
// }
//
// public void setForGame(Game forGame) {
// this.forGame = forGame;
// }
//
// public String getPredictedResult() {
// return predictedResult;
// }
//
// public void setPredictedResult(String predictedResult) {
// this.predictedResult = predictedResult;
// }
//
// @Override
// public String toString() {
// return "Prediction{" +
// "id=" + id +
// ", byUser=" + byUser +
// ", forGame=" + forGame +
// ", predictedResult='" + predictedResult + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (!(o instanceof Prediction))
// return false;
// Prediction that = (Prediction) o;
// return Objects.equals(byUser, that.byUser) &&
// Objects.equals(forGame, that.forGame) &&
// Objects.equals(predictedResult, that.predictedResult);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(byUser, forGame, predictedResult);
// }
// }
// Path: src/test/java/com/nosoftskills/predcomposer/prediction/ViewUserPredictionsBeanTest.java
import com.nosoftskills.predcomposer.alternatives.PredictionsServiceAlternative;
import com.nosoftskills.predcomposer.alternatives.UserContextAlternative;
import com.nosoftskills.predcomposer.model.Prediction;
import org.jglue.cdiunit.ActivatedAlternatives;
import org.jglue.cdiunit.CdiRunner;
import org.jglue.cdiunit.InRequestScope;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
package com.nosoftskills.predcomposer.prediction;
/**
* @author Ivan St. Ivanov
*/
@RunWith(CdiRunner.class)
@ActivatedAlternatives({
PredictionsServiceAlternative.class, UserContextAlternative.class
})
public class ViewUserPredictionsBeanTest {
@Inject
private ViewUserPredictionsBean bean;
@Test
@InRequestScope
public void shouldLoadUserPredictionsUponStartup() throws Exception { | Map<Long, Prediction> userPredictions = bean.getUserPredictions(); |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/Events/ComponentDragEvent.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
//
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java
// public interface GUIContainer extends GUIComponent {
//
// /**
// * Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
// * or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
// * <br>
// * The parent component (this) should handle the drawing and management of the given component
// * see: {@link GUIElement#draw()}
// * @param component the component that should be added to this component
// */
// void add( GUIComponent component );
//
// /**
// * Removes the given component from the parent component.
// * This should also manage the removal of the native item from the Inventory
// * see: {@link GUIElement#dispose()}
// * @param component the component to remove
// */
// void remove( GUIComponent component );
//
// /**
// *
// * @return the list of all components, that are applied to this one
// */
// List<GUIComponent> getComponents();
//
// /**
// *
// * @param position where the wanted {@link GUIElement} can be found
// * @return GUIElement if there is at least one at the given position
// * Note: there can be multiple Elements / Components applied to one position!
// */
// GUIElement getElement(Vector2i position);
//
// /**
// * This can be used to separate gui and logic
// * @param name displayname of the wanted {@link GUIElement}
// * @return GUIElement if found, else null
// */
// GUIElement getElementByName(String name);
//
// /**
// *
// * @return the size of this container corresponding to the width and height of the minecraft inventory
// */
// Vector2i getSize();
//
// /**
// * Updates the size of this container.
// * This should also redraw this container and calculate all its components relatively towards the new dimension
// * @param dimension the container should have
// */
// void setSize( Vector2i dimension );
//
// /**
// *
// * @return the applied layout
// */
// GUILayout getLayout();
//
// /**
// * Updates the layout that designs this container
// * Rather than just setting the layout, this should also update the containers components
// * to be designed by the new layout
// * @param layout the new layout this container should be designed by
// */
// void setLayout( GUILayout layout );
//
// /**
// *
// * @return the native minecraft inventory
// */
// Inventory getInventory();
//
// /**
// * Switches out the native minecraft inventory
// * @param inventory the new inventory that should be displayed on {@link GUIContainer#draw(Player)}
// */
// void setInventory( Inventory inventory );
//
// /**
// * Displays the native minecraft inventory to the given player
// * @param player to whom the container should be opened
// */
// void draw( Player player );
//
// /**
// * Closes the native minecraft inventory and unregisters all previously registered events used by this container
// * @param player thats inevtory should be closed
// */
// void dispose( Player player );
//
// Player getPlayer();
// boolean isNativeListenerRegistered();
// void setNativeListenerRegistered(boolean registered);
// JavaPlugin getPlugin();
// }
| import com.minecraftlegend.inventoryapi.GUIComponent;
import com.minecraftlegend.inventoryapi.GUIContainer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.DragType;
import org.bukkit.inventory.ItemStack;
import java.util.Map; | package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public class ComponentDragEvent {
private GUIContainer gui; | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
//
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java
// public interface GUIContainer extends GUIComponent {
//
// /**
// * Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
// * or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
// * <br>
// * The parent component (this) should handle the drawing and management of the given component
// * see: {@link GUIElement#draw()}
// * @param component the component that should be added to this component
// */
// void add( GUIComponent component );
//
// /**
// * Removes the given component from the parent component.
// * This should also manage the removal of the native item from the Inventory
// * see: {@link GUIElement#dispose()}
// * @param component the component to remove
// */
// void remove( GUIComponent component );
//
// /**
// *
// * @return the list of all components, that are applied to this one
// */
// List<GUIComponent> getComponents();
//
// /**
// *
// * @param position where the wanted {@link GUIElement} can be found
// * @return GUIElement if there is at least one at the given position
// * Note: there can be multiple Elements / Components applied to one position!
// */
// GUIElement getElement(Vector2i position);
//
// /**
// * This can be used to separate gui and logic
// * @param name displayname of the wanted {@link GUIElement}
// * @return GUIElement if found, else null
// */
// GUIElement getElementByName(String name);
//
// /**
// *
// * @return the size of this container corresponding to the width and height of the minecraft inventory
// */
// Vector2i getSize();
//
// /**
// * Updates the size of this container.
// * This should also redraw this container and calculate all its components relatively towards the new dimension
// * @param dimension the container should have
// */
// void setSize( Vector2i dimension );
//
// /**
// *
// * @return the applied layout
// */
// GUILayout getLayout();
//
// /**
// * Updates the layout that designs this container
// * Rather than just setting the layout, this should also update the containers components
// * to be designed by the new layout
// * @param layout the new layout this container should be designed by
// */
// void setLayout( GUILayout layout );
//
// /**
// *
// * @return the native minecraft inventory
// */
// Inventory getInventory();
//
// /**
// * Switches out the native minecraft inventory
// * @param inventory the new inventory that should be displayed on {@link GUIContainer#draw(Player)}
// */
// void setInventory( Inventory inventory );
//
// /**
// * Displays the native minecraft inventory to the given player
// * @param player to whom the container should be opened
// */
// void draw( Player player );
//
// /**
// * Closes the native minecraft inventory and unregisters all previously registered events used by this container
// * @param player thats inevtory should be closed
// */
// void dispose( Player player );
//
// Player getPlayer();
// boolean isNativeListenerRegistered();
// void setNativeListenerRegistered(boolean registered);
// JavaPlugin getPlugin();
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/Events/ComponentDragEvent.java
import com.minecraftlegend.inventoryapi.GUIComponent;
import com.minecraftlegend.inventoryapi.GUIContainer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.DragType;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public class ComponentDragEvent {
private GUIContainer gui; | private GUIComponent component; |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/Events/ComponentClickEvent.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
//
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java
// public interface GUIContainer extends GUIComponent {
//
// /**
// * Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
// * or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
// * <br>
// * The parent component (this) should handle the drawing and management of the given component
// * see: {@link GUIElement#draw()}
// * @param component the component that should be added to this component
// */
// void add( GUIComponent component );
//
// /**
// * Removes the given component from the parent component.
// * This should also manage the removal of the native item from the Inventory
// * see: {@link GUIElement#dispose()}
// * @param component the component to remove
// */
// void remove( GUIComponent component );
//
// /**
// *
// * @return the list of all components, that are applied to this one
// */
// List<GUIComponent> getComponents();
//
// /**
// *
// * @param position where the wanted {@link GUIElement} can be found
// * @return GUIElement if there is at least one at the given position
// * Note: there can be multiple Elements / Components applied to one position!
// */
// GUIElement getElement(Vector2i position);
//
// /**
// * This can be used to separate gui and logic
// * @param name displayname of the wanted {@link GUIElement}
// * @return GUIElement if found, else null
// */
// GUIElement getElementByName(String name);
//
// /**
// *
// * @return the size of this container corresponding to the width and height of the minecraft inventory
// */
// Vector2i getSize();
//
// /**
// * Updates the size of this container.
// * This should also redraw this container and calculate all its components relatively towards the new dimension
// * @param dimension the container should have
// */
// void setSize( Vector2i dimension );
//
// /**
// *
// * @return the applied layout
// */
// GUILayout getLayout();
//
// /**
// * Updates the layout that designs this container
// * Rather than just setting the layout, this should also update the containers components
// * to be designed by the new layout
// * @param layout the new layout this container should be designed by
// */
// void setLayout( GUILayout layout );
//
// /**
// *
// * @return the native minecraft inventory
// */
// Inventory getInventory();
//
// /**
// * Switches out the native minecraft inventory
// * @param inventory the new inventory that should be displayed on {@link GUIContainer#draw(Player)}
// */
// void setInventory( Inventory inventory );
//
// /**
// * Displays the native minecraft inventory to the given player
// * @param player to whom the container should be opened
// */
// void draw( Player player );
//
// /**
// * Closes the native minecraft inventory and unregisters all previously registered events used by this container
// * @param player thats inevtory should be closed
// */
// void dispose( Player player );
//
// Player getPlayer();
// boolean isNativeListenerRegistered();
// void setNativeListenerRegistered(boolean registered);
// JavaPlugin getPlugin();
// }
| import com.minecraftlegend.inventoryapi.GUIComponent;
import com.minecraftlegend.inventoryapi.GUIContainer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; | package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public class ComponentClickEvent implements EventWrapper {
private GUIContainer gui; | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
//
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java
// public interface GUIContainer extends GUIComponent {
//
// /**
// * Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
// * or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
// * <br>
// * The parent component (this) should handle the drawing and management of the given component
// * see: {@link GUIElement#draw()}
// * @param component the component that should be added to this component
// */
// void add( GUIComponent component );
//
// /**
// * Removes the given component from the parent component.
// * This should also manage the removal of the native item from the Inventory
// * see: {@link GUIElement#dispose()}
// * @param component the component to remove
// */
// void remove( GUIComponent component );
//
// /**
// *
// * @return the list of all components, that are applied to this one
// */
// List<GUIComponent> getComponents();
//
// /**
// *
// * @param position where the wanted {@link GUIElement} can be found
// * @return GUIElement if there is at least one at the given position
// * Note: there can be multiple Elements / Components applied to one position!
// */
// GUIElement getElement(Vector2i position);
//
// /**
// * This can be used to separate gui and logic
// * @param name displayname of the wanted {@link GUIElement}
// * @return GUIElement if found, else null
// */
// GUIElement getElementByName(String name);
//
// /**
// *
// * @return the size of this container corresponding to the width and height of the minecraft inventory
// */
// Vector2i getSize();
//
// /**
// * Updates the size of this container.
// * This should also redraw this container and calculate all its components relatively towards the new dimension
// * @param dimension the container should have
// */
// void setSize( Vector2i dimension );
//
// /**
// *
// * @return the applied layout
// */
// GUILayout getLayout();
//
// /**
// * Updates the layout that designs this container
// * Rather than just setting the layout, this should also update the containers components
// * to be designed by the new layout
// * @param layout the new layout this container should be designed by
// */
// void setLayout( GUILayout layout );
//
// /**
// *
// * @return the native minecraft inventory
// */
// Inventory getInventory();
//
// /**
// * Switches out the native minecraft inventory
// * @param inventory the new inventory that should be displayed on {@link GUIContainer#draw(Player)}
// */
// void setInventory( Inventory inventory );
//
// /**
// * Displays the native minecraft inventory to the given player
// * @param player to whom the container should be opened
// */
// void draw( Player player );
//
// /**
// * Closes the native minecraft inventory and unregisters all previously registered events used by this container
// * @param player thats inevtory should be closed
// */
// void dispose( Player player );
//
// Player getPlayer();
// boolean isNativeListenerRegistered();
// void setNativeListenerRegistered(boolean registered);
// JavaPlugin getPlugin();
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/Events/ComponentClickEvent.java
import com.minecraftlegend.inventoryapi.GUIComponent;
import com.minecraftlegend.inventoryapi.GUIContainer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public class ComponentClickEvent implements EventWrapper {
private GUIContainer gui; | private GUIComponent component; |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
| import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List; | package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUIContainer extends GUIComponent {
/**
* Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
* or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
* <br>
* The parent component (this) should handle the drawing and management of the given component
* see: {@link GUIElement#draw()}
* @param component the component that should be added to this component
*/
void add( GUIComponent component );
/**
* Removes the given component from the parent component.
* This should also manage the removal of the native item from the Inventory
* see: {@link GUIElement#dispose()}
* @param component the component to remove
*/
void remove( GUIComponent component );
/**
*
* @return the list of all components, that are applied to this one
*/
List<GUIComponent> getComponents();
/**
*
* @param position where the wanted {@link GUIElement} can be found
* @return GUIElement if there is at least one at the given position
* Note: there can be multiple Elements / Components applied to one position!
*/ | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIContainer.java
import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUIContainer extends GUIComponent {
/**
* Add other gui components to this one such as sub inventories like: {@link com.legend.cloud.clientapi.api.gui.elements.GUISubContainer}
* or gui elements like: {@link com.legend.cloud.clientapi.api.gui.elements.GUILabel}
* <br>
* The parent component (this) should handle the drawing and management of the given component
* see: {@link GUIElement#draw()}
* @param component the component that should be added to this component
*/
void add( GUIComponent component );
/**
* Removes the given component from the parent component.
* This should also manage the removal of the native item from the Inventory
* see: {@link GUIElement#dispose()}
* @param component the component to remove
*/
void remove( GUIComponent component );
/**
*
* @return the list of all components, that are applied to this one
*/
List<GUIComponent> getComponents();
/**
*
* @param position where the wanted {@link GUIElement} can be found
* @return GUIElement if there is at least one at the given position
* Note: there can be multiple Elements / Components applied to one position!
*/ | GUIElement getElement(Vector2i position); |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/Events/InputChangeEvent.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
| import com.minecraftlegend.inventoryapi.GUIComponent;
import org.bukkit.entity.HumanEntity; | package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2017 by Jan Hof
* All rights reserved.
**/
public class InputChangeEvent implements EventWrapper {
private InputActionType action; | // Path: src/main/java/com/minecraftlegend/inventoryapi/GUIComponent.java
// public interface GUIComponent extends Listener, Cloneable, Serializable{
//
//
// default void registerNativeListeners( JavaPlugin plugin) {
// plugin.getServer().getPluginManager().registerEvents( this, plugin );
// }
//
//
// default void init() {
// }
//
// default void postInit() {
// }
//
// /**
// * Adds gui events to this component.
// * All Events will be specified for this component
// * @param event to register
// */
// void addEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered event
// * @param event to remove
// */
// void removeEvent( GUIEvent event );
//
// /**
// *
// * @param event is fired globalized (like a normal event listener) therefor gui components will be null
// */
// void addGlobalEvent( GUIEvent event );
//
// /**
// * Removes an earlier registered global event
// * @param event to remove
// */
// void removeGlobalEvent( GUIEvent event );
//
// /**
// *
// * @return all global events
// */
// List<GUIEvent> getGlobalEvents();
//
// /**
// *
// * @return all registered events for this component
// */
// List<GUIEvent> getEvents();
//
// void setEvents(List<GUIEvent> events);
// void setGlobalEvents(List<GUIEvent> events);
//
// /**
// * Locks this component
// * -> if this is an Inventory, the whole inventory will be locked and no items can be moved
// * -> if this is an gui element, this specific element will be locked
// * Note: in most cases components are already locked by default
// */
// void lock();
//
// /**
// * unlocks this component
// */
// void unlock();
//
// /**
// *
// * @return the current lock state of this component
// */
// boolean isLocked();
//
// Object clone();
//
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/Events/InputChangeEvent.java
import com.minecraftlegend.inventoryapi.GUIComponent;
import org.bukkit.entity.HumanEntity;
package com.minecraftlegend.inventoryapi.Events;
/**
* @Author Sauerbier | Jan
* @Copyright 2017 by Jan Hof
* All rights reserved.
**/
public class InputChangeEvent implements EventWrapper {
private InputActionType action; | private GUIComponent component; |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/GUIElement.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
| import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.inventory.ItemStack; | package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUIElement extends GUIComponent {
/**
*
* @return the parent this element belongs to
*/
GUIComponent getParent();
/**
*
* @param parent sets a new parent component
*/
void setParent( GUIComponent parent );
/**
*
* @return the size of this element, you can have mulit-slot elements such as {@link com.legend.cloud.clientapi.api.gui.elements.GUIProgressBar}
*/ | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUIElement.java
import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.inventory.ItemStack;
package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUIElement extends GUIComponent {
/**
*
* @return the parent this element belongs to
*/
GUIComponent getParent();
/**
*
* @param parent sets a new parent component
*/
void setParent( GUIComponent parent );
/**
*
* @return the size of this element, you can have mulit-slot elements such as {@link com.legend.cloud.clientapi.api.gui.elements.GUIProgressBar}
*/ | Vector2i getSize(); |
LegendOnline/InventoryAPI | src/main/java/com/minecraftlegend/inventoryapi/GUILayout.java | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
| import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.event.inventory.InventoryType; | package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUILayout {
/**
* Main method to apply the defined layout as {@link GUIElement}'s in the container
* @param container
*/
void apply( GUIContainer container );
/**
*
* @return the size, the container should have -> the layout has to specify the size
*/ | // Path: src/main/java/com/minecraftlegend/inventoryapi/utils/Vector2i.java
// public class Vector2i implements Cloneable {
//
// private int x, y;
//
// public Vector2i( int x, int y ) {
// this.x = x;
// this.y = y;
// }
//
// public Vector2i( Vector2i vec ) {
// this.x = vec.getX();
// this.y = vec.getY();
// }
//
// public void add( Vector2i vector2i ) {
// x += vector2i.getX();
// y += vector2i.getY();
// }
//
//
// public void sub( Vector2i vec ) {
// this.x -= vec.getX();
// this.y -= vec.getY();
// }
//
// public void multiply( Vector2i vec ) {
// x *= vec.getX();
// y *= vec.getY();
// }
//
// public void multiply( int m ) {
// x *= m;
// y *= m;
// }
//
// public void divide( Vector2i vec ) {
// x /= vec.getX();
// y /= vec.getY();
// }
//
// public void divide( int m ) {
// x /= m;
// y /= m;
// }
//
// public int scalar( Vector2i vec ) {
// return ( x + vec.getX() ) * ( y + vec.getY() );
// }
//
// public double distance( Vector2i vec ) {
// int dx = vec.getX() - x;
// int dy = vec.getY() - y;
// return new Vector2i( dx, dy ).length();
// }
//
// public double angle( Vector2i vec ) {
// double dx = vec.getX() - x;
// double dy = vec.getY() - y;
// return Math.atan2( dy, dx );
// }
//
//
// public Vector2i toPixelPrecision( int pixelMask ) {
// return new Vector2i( (int) x << pixelMask, (int) y << pixelMask );
// }
//
// public Vector2i toBlockPrecision( int pixelMask ) {
// return new Vector2i( (int) x >> pixelMask, (int) y >> pixelMask );
// }
//
// public int toInventoryPosition(){
// return x + y * 9;
// }
//
// public Vector2i max( Vector2i vec ) {
// if ( x + y > vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
// public Vector2i min( Vector2i vec ) {
//
// if ( x + y < vec.getX() + vec.getY() ) {
// return this;
// }
// else return vec;
// }
//
//
// public double length() {
// return Math.sqrt( x * x + y * y );
// }
//
// @Override
// public Vector2i clone() {
// try {
// return (Vector2i) super.clone();
// }
// catch ( CloneNotSupportedException e ) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean equals( Object obj ) {
// Validate.notNull( obj);
// Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );
//
// Vector2i other = (Vector2i) obj;
//
// if(other.getX() != x) return false;
// if(other.getY() != y) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "[x:" + x + ",y:" + y + "]";
// }
//
// public int getX() {
// return x;
// }
//
// public void setX( int x ) {
// this.x = x;
// }
//
//
// public int getY() {
// return y;
// }
//
// public void setY( int y ) {
// this.y = y;
// }
// }
// Path: src/main/java/com/minecraftlegend/inventoryapi/GUILayout.java
import com.minecraftlegend.inventoryapi.utils.Vector2i;
import org.bukkit.event.inventory.InventoryType;
package com.minecraftlegend.inventoryapi;
/**
* @Author Sauerbier | Jan
* @Copyright 2016 by Jan Hof
* All rights reserved.
**/
public interface GUILayout {
/**
* Main method to apply the defined layout as {@link GUIElement}'s in the container
* @param container
*/
void apply( GUIContainer container );
/**
*
* @return the size, the container should have -> the layout has to specify the size
*/ | Vector2i getSize(); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/ui/widget/DragViewLayout.java | // Path: app/src/main/java/reader/simple/com/simple_reader/common/DebugUtil.java
// public class DebugUtil {
// static String className;
// private DebugUtil(){}
//
// public static boolean isDebugEnable() {
// return Config.DEBUG;
// }
//
// private static String createLog( String log ) {
// return log;
// }
//
// private static void getMethodNames(StackTraceElement[] sElements){
// String methodName = sElements[1].getMethodName();
// int lineNumber = sElements[1].getLineNumber();
// className = "{ " + sElements[1].getFileName() + " : " + lineNumber + " - " + methodName + " }";
// }
//
// public static void e(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(className, createLog(message));
// } public static void e(String Tag ,String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(Tag, createLog(message));
// }
//
// public static void i(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.i(className, createLog(message));
// }
//
// public static void d(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.d(className, createLog(message));
// }
//
// public static void v(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.v(className, createLog(message));
// }
//
// public static void w(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.w(className, createLog(message));
// }
//
// public static void wtf(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.wtf(className, createLog(message));
// }
//
// }
| import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;
import reader.simple.com.simple_reader.common.DebugUtil; | }
if (mHorizonRight && !mHorizonLeft) {
if (left < 0) {
return child.getLeft();
}
}
return left;
} else {
return mFirstView.getLeft();
}
}
//处理纵向手势
@Override
public int clampViewPositionVertical(View child, int top, int dy) {
if (mVerticalUp || mVerticalDown) {
if (null != mListener) {
mListener.onVerticalMoving();
}
return top;
} else {
return child.getTop();
}
}
//抬起手势处理
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) { | // Path: app/src/main/java/reader/simple/com/simple_reader/common/DebugUtil.java
// public class DebugUtil {
// static String className;
// private DebugUtil(){}
//
// public static boolean isDebugEnable() {
// return Config.DEBUG;
// }
//
// private static String createLog( String log ) {
// return log;
// }
//
// private static void getMethodNames(StackTraceElement[] sElements){
// String methodName = sElements[1].getMethodName();
// int lineNumber = sElements[1].getLineNumber();
// className = "{ " + sElements[1].getFileName() + " : " + lineNumber + " - " + methodName + " }";
// }
//
// public static void e(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(className, createLog(message));
// } public static void e(String Tag ,String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(Tag, createLog(message));
// }
//
// public static void i(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.i(className, createLog(message));
// }
//
// public static void d(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.d(className, createLog(message));
// }
//
// public static void v(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.v(className, createLog(message));
// }
//
// public static void w(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.w(className, createLog(message));
// }
//
// public static void wtf(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.wtf(className, createLog(message));
// }
//
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/ui/widget/DragViewLayout.java
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;
import reader.simple.com.simple_reader.common.DebugUtil;
}
if (mHorizonRight && !mHorizonLeft) {
if (left < 0) {
return child.getLeft();
}
}
return left;
} else {
return mFirstView.getLeft();
}
}
//处理纵向手势
@Override
public int clampViewPositionVertical(View child, int top, int dy) {
if (mVerticalUp || mVerticalDown) {
if (null != mListener) {
mListener.onVerticalMoving();
}
return top;
} else {
return child.getTop();
}
}
//抬起手势处理
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) { | DebugUtil.e("onViewReleased"); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java | // Path: app/src/main/java/reader/simple/com/simple_reader/common/Constants.java
// public class Constants {
//
// public static final String KEY_ARCITLE = "id";
// public static final String KEY_IMAG_PATH = "imagePath";
//
// public static final String LOADING = "加载中....";
// public static final String NONELOAD = "全部加载完成";
// public static final String NET_ERROR = "加载异常";
// public static final String DEFAULT_PREFER = "default_config";
// }
| import android.content.Context;
import android.content.SharedPreferences;
import reader.simple.com.simple_reader.common.Constants; | package reader.simple.com.simple_reader.utils;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/7/20 下午4:55
* 备注:
* Version:
* ==================================================
*/
public class PreferenceManager {
private SharedPreferences mPreferences;
private static PreferenceManager instance = null;
private int currentVersionCode = -1;
private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
public static void initPreferences(Context context) {
instance = new PreferenceManager(context);
}
private PreferenceManager(Context context) { | // Path: app/src/main/java/reader/simple/com/simple_reader/common/Constants.java
// public class Constants {
//
// public static final String KEY_ARCITLE = "id";
// public static final String KEY_IMAG_PATH = "imagePath";
//
// public static final String LOADING = "加载中....";
// public static final String NONELOAD = "全部加载完成";
// public static final String NET_ERROR = "加载异常";
// public static final String DEFAULT_PREFER = "default_config";
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java
import android.content.Context;
import android.content.SharedPreferences;
import reader.simple.com.simple_reader.common.Constants;
package reader.simple.com.simple_reader.utils;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/7/20 下午4:55
* 备注:
* Version:
* ==================================================
*/
public class PreferenceManager {
private SharedPreferences mPreferences;
private static PreferenceManager instance = null;
private int currentVersionCode = -1;
private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
public static void initPreferences(Context context) {
instance = new PreferenceManager(context);
}
private PreferenceManager(Context context) { | mPreferences = context.getSharedPreferences(Constants.DEFAULT_PREFER, Context.MODE_PRIVATE); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/animator/MyBaseItemAnimtor.java | // Path: app/src/main/java/reader/simple/com/simple_reader/common/DebugUtil.java
// public class DebugUtil {
// static String className;
// private DebugUtil(){}
//
// public static boolean isDebugEnable() {
// return Config.DEBUG;
// }
//
// private static String createLog( String log ) {
// return log;
// }
//
// private static void getMethodNames(StackTraceElement[] sElements){
// String methodName = sElements[1].getMethodName();
// int lineNumber = sElements[1].getLineNumber();
// className = "{ " + sElements[1].getFileName() + " : " + lineNumber + " - " + methodName + " }";
// }
//
// public static void e(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(className, createLog(message));
// } public static void e(String Tag ,String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(Tag, createLog(message));
// }
//
// public static void i(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.i(className, createLog(message));
// }
//
// public static void d(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.d(className, createLog(message));
// }
//
// public static void v(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.v(className, createLog(message));
// }
//
// public static void w(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.w(className, createLog(message));
// }
//
// public static void wtf(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.wtf(className, createLog(message));
// }
//
// }
| import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import reader.simple.com.simple_reader.common.DebugUtil; |
private ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder) {
this.oldHolder = oldHolder;
this.newHolder = newHolder;
}
private ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
int fromX, int fromY, int toX, int toY) {
this(oldHolder, newHolder);
this.fromX = fromX;
this.fromY = fromY;
this.toX = toX;
this.toY = toY;
}
@Override
public String toString() {
return "ChangeInfo{" +
"oldHolder=" + oldHolder +
", newHolder=" + newHolder +
", fromX=" + fromX +
", fromY=" + fromY +
", toX=" + toX +
", toY=" + toY +
'}';
}
}
@Override
public void runPendingAnimations() { | // Path: app/src/main/java/reader/simple/com/simple_reader/common/DebugUtil.java
// public class DebugUtil {
// static String className;
// private DebugUtil(){}
//
// public static boolean isDebugEnable() {
// return Config.DEBUG;
// }
//
// private static String createLog( String log ) {
// return log;
// }
//
// private static void getMethodNames(StackTraceElement[] sElements){
// String methodName = sElements[1].getMethodName();
// int lineNumber = sElements[1].getLineNumber();
// className = "{ " + sElements[1].getFileName() + " : " + lineNumber + " - " + methodName + " }";
// }
//
// public static void e(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(className, createLog(message));
// } public static void e(String Tag ,String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.e(Tag, createLog(message));
// }
//
// public static void i(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.i(className, createLog(message));
// }
//
// public static void d(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.d(className, createLog(message));
// }
//
// public static void v(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.v(className, createLog(message));
// }
//
// public static void w(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.w(className, createLog(message));
// }
//
// public static void wtf(String message){
// if (!isDebugEnable())
// return;
//
// getMethodNames(new Throwable().getStackTrace());
// Log.wtf(className, createLog(message));
// }
//
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/animator/MyBaseItemAnimtor.java
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import reader.simple.com.simple_reader.common.DebugUtil;
private ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder) {
this.oldHolder = oldHolder;
this.newHolder = newHolder;
}
private ChangeInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
int fromX, int fromY, int toX, int toY) {
this(oldHolder, newHolder);
this.fromX = fromX;
this.fromY = fromY;
this.toX = toX;
this.toY = toY;
}
@Override
public String toString() {
return "ChangeInfo{" +
"oldHolder=" + oldHolder +
", newHolder=" + newHolder +
", fromX=" + fromX +
", fromY=" + fromY +
", toX=" + toX +
", toY=" + toY +
'}';
}
}
@Override
public void runPendingAnimations() { | DebugUtil.e("runPendingAnimations"); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/BaseApplication.java | // Path: app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java
// public class PreferenceManager {
// private SharedPreferences mPreferences;
// private static PreferenceManager instance = null;
// private int currentVersionCode = -1;
//
// private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
// private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
// private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
//
// public static void initPreferences(Context context) {
// instance = new PreferenceManager(context);
// }
//
// private PreferenceManager(Context context) {
// mPreferences = context.getSharedPreferences(Constants.DEFAULT_PREFER, Context.MODE_PRIVATE);
// }
//
// public static PreferenceManager getInstance() {
// return instance;
// }
//
// public int getReceiveRideResult() {
// return mPreferences.getInt(KEY_RIDE_RESULT, 0);
// }
//
// public void setReceiveRideResult(int value) {
// mPreferences.edit().putInt(KEY_RIDE_RESULT, value).apply();
// }
//
// public void setVersionCode(int code) {
// if (currentVersionCode != code) {
// currentVersionCode = code;
// setReceiveRideResult(0);
// }
// }
//
// public String getSplashImgPath() {
// return mPreferences.getString(KEY_SPLASH_IMG, "");
// }
//
//
// public void putSplashImgPath(String mPath) {
// mPreferences.edit().putString(KEY_SPLASH_IMG, mPath).apply();
// }
//
//
// public int getSplashImgCode() {
// return mPreferences.getInt(KEY_SPLASH_CODE, 0);
// }
//
// public void putSplashImgCode(int code) {
// mPreferences.edit().putInt(KEY_SPLASH_CODE, code).apply();
// }
// }
| import android.app.Application;
import android.content.Context;
import com.github.moduth.blockcanary.BlockCanary;
import com.squareup.leakcanary.LeakCanary;
import reader.simple.com.simple_reader.utils.PreferenceManager; | package reader.simple.com.simple_reader;
public class BaseApplication extends Application {
public static String cacheDir = "";
public static Context mAppContext = null;
@Override
public void onCreate() {
super.onCreate();
mAppContext = getApplicationContext();
// 初始化 retrofit
// CrashHandler.init(new CrashHandler(getApplicationContext()));
/**
* 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
*/
if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
cacheDir = getApplicationContext().getExternalCacheDir().getAbsolutePath();
} else {
cacheDir = getApplicationContext().getCacheDir().toString();
} | // Path: app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java
// public class PreferenceManager {
// private SharedPreferences mPreferences;
// private static PreferenceManager instance = null;
// private int currentVersionCode = -1;
//
// private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
// private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
// private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
//
// public static void initPreferences(Context context) {
// instance = new PreferenceManager(context);
// }
//
// private PreferenceManager(Context context) {
// mPreferences = context.getSharedPreferences(Constants.DEFAULT_PREFER, Context.MODE_PRIVATE);
// }
//
// public static PreferenceManager getInstance() {
// return instance;
// }
//
// public int getReceiveRideResult() {
// return mPreferences.getInt(KEY_RIDE_RESULT, 0);
// }
//
// public void setReceiveRideResult(int value) {
// mPreferences.edit().putInt(KEY_RIDE_RESULT, value).apply();
// }
//
// public void setVersionCode(int code) {
// if (currentVersionCode != code) {
// currentVersionCode = code;
// setReceiveRideResult(0);
// }
// }
//
// public String getSplashImgPath() {
// return mPreferences.getString(KEY_SPLASH_IMG, "");
// }
//
//
// public void putSplashImgPath(String mPath) {
// mPreferences.edit().putString(KEY_SPLASH_IMG, mPath).apply();
// }
//
//
// public int getSplashImgCode() {
// return mPreferences.getInt(KEY_SPLASH_CODE, 0);
// }
//
// public void putSplashImgCode(int code) {
// mPreferences.edit().putInt(KEY_SPLASH_CODE, code).apply();
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/BaseApplication.java
import android.app.Application;
import android.content.Context;
import com.github.moduth.blockcanary.BlockCanary;
import com.squareup.leakcanary.LeakCanary;
import reader.simple.com.simple_reader.utils.PreferenceManager;
package reader.simple.com.simple_reader;
public class BaseApplication extends Application {
public static String cacheDir = "";
public static Context mAppContext = null;
@Override
public void onCreate() {
super.onCreate();
mAppContext = getApplicationContext();
// 初始化 retrofit
// CrashHandler.init(new CrashHandler(getApplicationContext()));
/**
* 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
*/
if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
cacheDir = getApplicationContext().getExternalCacheDir().getAbsolutePath();
} else {
cacheDir = getApplicationContext().getCacheDir().toString();
} | PreferenceManager.initPreferences(this); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/ui/activity/LockscreenActivity.java | // Path: app/src/main/java/reader/simple/com/simple_reader/ui/activity/base/BaseSwipeActivity.java
// public abstract class BaseSwipeActivity extends BaseActivity implements SwipeBackActivityBase {
// private SwipeBackActivityHelper mHelper;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// // super.setStatusBar();
//
// }
//
// @Override
// protected void doBeforeSetContentView() {
// mHelper = new SwipeBackActivityHelper(this);
// mHelper.onActivityCreate();
// }
//
// @Override
// protected void doAfterSetContentView() {
// SwipeBackLayout swipeBackLayout = getSwipeBackLayout();
// swipeBackLayout.setEnableGesture(getSwipeBackLayoutEnabled());
// if (!getSwipeBackLayoutEnabled()) {
// swipeBackLayout.setEdgeTrackingEnabled(getSwipeBackLayoutTracking());
// }
// }
//
// protected abstract int getSwipeBackLayoutTracking();
//
// protected abstract boolean getSwipeBackLayoutEnabled();
//
// @Override
// protected void onPostCreate(Bundle savedInstanceState) {
// super.onPostCreate(savedInstanceState);
// mHelper.onPostCreate();
// }
//
// @Override
// public View findViewById(int id) {
// View v = super.findViewById(id);
// if (v == null && mHelper != null)
// return mHelper.findViewById(id);
// return v;
// }
//
// @Override
// public SwipeBackLayout getSwipeBackLayout() {
// return mHelper.getSwipeBackLayout();
// }
//
// @Override
// public void setSwipeBackEnable(boolean enable) {
// getSwipeBackLayout().setEnableGesture(enable);
// }
//
// @Override
// public void scrollToFinishActivity() {
// Utils.convertActivityToTranslucent(this);
// getSwipeBackLayout().scrollToFinishActivity();
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java
// public class PreferenceManager {
// private SharedPreferences mPreferences;
// private static PreferenceManager instance = null;
// private int currentVersionCode = -1;
//
// private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
// private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
// private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
//
// public static void initPreferences(Context context) {
// instance = new PreferenceManager(context);
// }
//
// private PreferenceManager(Context context) {
// mPreferences = context.getSharedPreferences(Constants.DEFAULT_PREFER, Context.MODE_PRIVATE);
// }
//
// public static PreferenceManager getInstance() {
// return instance;
// }
//
// public int getReceiveRideResult() {
// return mPreferences.getInt(KEY_RIDE_RESULT, 0);
// }
//
// public void setReceiveRideResult(int value) {
// mPreferences.edit().putInt(KEY_RIDE_RESULT, value).apply();
// }
//
// public void setVersionCode(int code) {
// if (currentVersionCode != code) {
// currentVersionCode = code;
// setReceiveRideResult(0);
// }
// }
//
// public String getSplashImgPath() {
// return mPreferences.getString(KEY_SPLASH_IMG, "");
// }
//
//
// public void putSplashImgPath(String mPath) {
// mPreferences.edit().putString(KEY_SPLASH_IMG, mPath).apply();
// }
//
//
// public int getSplashImgCode() {
// return mPreferences.getInt(KEY_SPLASH_CODE, 0);
// }
//
// public void putSplashImgCode(int code) {
// mPreferences.edit().putInt(KEY_SPLASH_CODE, code).apply();
// }
// }
| import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import butterknife.InjectView;
import me.imid.swipebacklayout.lib.SwipeBackLayout;
import reader.simple.com.simple_reader.R;
import reader.simple.com.simple_reader.ui.activity.base.BaseSwipeActivity;
import reader.simple.com.simple_reader.utils.PreferenceManager; | protected boolean pendingTransition() {
return false;
}
@Override
protected TransitionMode getTransitionMode() {
return null;
}
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_lockscreen;
}
@Override
protected void initViewsAndEvents() {
initView();
}
@Override
protected int getSwipeBackLayoutTracking() {
return SwipeBackLayout.EDGE_LEFT ;
}
@Override
protected boolean getSwipeBackLayoutEnabled() {
return true;
}
private void initView() { | // Path: app/src/main/java/reader/simple/com/simple_reader/ui/activity/base/BaseSwipeActivity.java
// public abstract class BaseSwipeActivity extends BaseActivity implements SwipeBackActivityBase {
// private SwipeBackActivityHelper mHelper;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// // super.setStatusBar();
//
// }
//
// @Override
// protected void doBeforeSetContentView() {
// mHelper = new SwipeBackActivityHelper(this);
// mHelper.onActivityCreate();
// }
//
// @Override
// protected void doAfterSetContentView() {
// SwipeBackLayout swipeBackLayout = getSwipeBackLayout();
// swipeBackLayout.setEnableGesture(getSwipeBackLayoutEnabled());
// if (!getSwipeBackLayoutEnabled()) {
// swipeBackLayout.setEdgeTrackingEnabled(getSwipeBackLayoutTracking());
// }
// }
//
// protected abstract int getSwipeBackLayoutTracking();
//
// protected abstract boolean getSwipeBackLayoutEnabled();
//
// @Override
// protected void onPostCreate(Bundle savedInstanceState) {
// super.onPostCreate(savedInstanceState);
// mHelper.onPostCreate();
// }
//
// @Override
// public View findViewById(int id) {
// View v = super.findViewById(id);
// if (v == null && mHelper != null)
// return mHelper.findViewById(id);
// return v;
// }
//
// @Override
// public SwipeBackLayout getSwipeBackLayout() {
// return mHelper.getSwipeBackLayout();
// }
//
// @Override
// public void setSwipeBackEnable(boolean enable) {
// getSwipeBackLayout().setEnableGesture(enable);
// }
//
// @Override
// public void scrollToFinishActivity() {
// Utils.convertActivityToTranslucent(this);
// getSwipeBackLayout().scrollToFinishActivity();
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/utils/PreferenceManager.java
// public class PreferenceManager {
// private SharedPreferences mPreferences;
// private static PreferenceManager instance = null;
// private int currentVersionCode = -1;
//
// private static final String KEY_RIDE_RESULT = "RIDE_RESULT";
// private static final String KEY_SPLASH_IMG = "IMG_SPLASH";
// private static final String KEY_SPLASH_CODE = "CODE_SPLASH";
//
// public static void initPreferences(Context context) {
// instance = new PreferenceManager(context);
// }
//
// private PreferenceManager(Context context) {
// mPreferences = context.getSharedPreferences(Constants.DEFAULT_PREFER, Context.MODE_PRIVATE);
// }
//
// public static PreferenceManager getInstance() {
// return instance;
// }
//
// public int getReceiveRideResult() {
// return mPreferences.getInt(KEY_RIDE_RESULT, 0);
// }
//
// public void setReceiveRideResult(int value) {
// mPreferences.edit().putInt(KEY_RIDE_RESULT, value).apply();
// }
//
// public void setVersionCode(int code) {
// if (currentVersionCode != code) {
// currentVersionCode = code;
// setReceiveRideResult(0);
// }
// }
//
// public String getSplashImgPath() {
// return mPreferences.getString(KEY_SPLASH_IMG, "");
// }
//
//
// public void putSplashImgPath(String mPath) {
// mPreferences.edit().putString(KEY_SPLASH_IMG, mPath).apply();
// }
//
//
// public int getSplashImgCode() {
// return mPreferences.getInt(KEY_SPLASH_CODE, 0);
// }
//
// public void putSplashImgCode(int code) {
// mPreferences.edit().putInt(KEY_SPLASH_CODE, code).apply();
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/ui/activity/LockscreenActivity.java
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import butterknife.InjectView;
import me.imid.swipebacklayout.lib.SwipeBackLayout;
import reader.simple.com.simple_reader.R;
import reader.simple.com.simple_reader.ui.activity.base.BaseSwipeActivity;
import reader.simple.com.simple_reader.utils.PreferenceManager;
protected boolean pendingTransition() {
return false;
}
@Override
protected TransitionMode getTransitionMode() {
return null;
}
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_lockscreen;
}
@Override
protected void initViewsAndEvents() {
initView();
}
@Override
protected int getSwipeBackLayoutTracking() {
return SwipeBackLayout.EDGE_LEFT ;
}
@Override
protected boolean getSwipeBackLayoutEnabled() {
return true;
}
private void initView() { | String path = PreferenceManager.getInstance().getSplashImgPath(); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/viewInterface/MainView.java | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
| import reader.simple.com.simple_reader.domain.PageInfo; | package reader.simple.com.simple_reader.viewInterface;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/2 下午4:47
* 修改时间:16/4/2 下午4:47
* 修改备注:
* Version:
* ==================================================
*/
public interface MainView {
void doOnThrow(Throwable throwable);
void hideRefresh();
void clearListData();
| // Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/viewInterface/MainView.java
import reader.simple.com.simple_reader.domain.PageInfo;
package reader.simple.com.simple_reader.viewInterface;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/2 下午4:47
* 修改时间:16/4/2 下午4:47
* 修改备注:
* Version:
* ==================================================
*/
public interface MainView {
void doOnThrow(Throwable throwable);
void hideRefresh();
void clearListData();
| void setLoadMore(PageInfo pageInfo); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/ui/service/LockScreenService.java | // Path: app/src/main/java/reader/simple/com/simple_reader/ui/activity/LockscreenActivity.java
// public class LockScreenActivity extends BaseSwipeActivity {
//
// @InjectView(R.id.fullscreen_content)
// ImageView fullscreenContent;
//
// @Override
// protected void doBeforeSetContentView() {
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// super.doBeforeSetContentView();
// }
//
//
// @Override
// protected boolean pendingTransition() {
// return false;
// }
//
// @Override
// protected TransitionMode getTransitionMode() {
// return null;
// }
//
// @Override
// protected int getContentViewLayoutID() {
// return R.layout.activity_lockscreen;
// }
//
// @Override
// protected void initViewsAndEvents() {
// initView();
// }
//
// @Override
// protected int getSwipeBackLayoutTracking() {
// return SwipeBackLayout.EDGE_LEFT ;
// }
//
// @Override
// protected boolean getSwipeBackLayoutEnabled() {
// return true;
// }
//
// private void initView() {
// String path = PreferenceManager.getInstance().getSplashImgPath();
// if (!TextUtils.isEmpty(path)) {
// Glide.with(this).load(PreferenceManager.getInstance().getSplashImgPath()).into(fullscreenContent);
// } else {
// Glide.with(this).load("file:///android_asset/splash/splash_background.jpg").into(fullscreenContent);
// }
// show();
// }
//
// private void show() {
// fullscreenContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
// fullscreenContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// int action = event.getKeyCode();
// switch (action) {
// case KeyEvent.KEYCODE_BACK:
// return true;
// case KeyEvent.KEYCODE_MENU:
// return true;
// default:
// return super.onKeyDown(keyCode, event);
// }
// }
// }
| import android.app.Notification;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.Nullable;
import reader.simple.com.simple_reader.ui.activity.LockScreenActivity; | package reader.simple.com.simple_reader.ui.service;
public class LockScreenService extends Service {
private static int SERVICE_ID = 0xFd;
public LockScreenService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
super.onCreate();
keepLive();
IntentFilter mFilter = new IntentFilter();
mFilter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(mReceiver, mFilter);
}
private void keepLive() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
startForeground(SERVICE_ID, new Notification());
} else {
Intent mIntent = new Intent(this, GrayService.class);
startService(mIntent);
startForeground(SERVICE_ID, new Notification());
}
}
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { | // Path: app/src/main/java/reader/simple/com/simple_reader/ui/activity/LockscreenActivity.java
// public class LockScreenActivity extends BaseSwipeActivity {
//
// @InjectView(R.id.fullscreen_content)
// ImageView fullscreenContent;
//
// @Override
// protected void doBeforeSetContentView() {
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// super.doBeforeSetContentView();
// }
//
//
// @Override
// protected boolean pendingTransition() {
// return false;
// }
//
// @Override
// protected TransitionMode getTransitionMode() {
// return null;
// }
//
// @Override
// protected int getContentViewLayoutID() {
// return R.layout.activity_lockscreen;
// }
//
// @Override
// protected void initViewsAndEvents() {
// initView();
// }
//
// @Override
// protected int getSwipeBackLayoutTracking() {
// return SwipeBackLayout.EDGE_LEFT ;
// }
//
// @Override
// protected boolean getSwipeBackLayoutEnabled() {
// return true;
// }
//
// private void initView() {
// String path = PreferenceManager.getInstance().getSplashImgPath();
// if (!TextUtils.isEmpty(path)) {
// Glide.with(this).load(PreferenceManager.getInstance().getSplashImgPath()).into(fullscreenContent);
// } else {
// Glide.with(this).load("file:///android_asset/splash/splash_background.jpg").into(fullscreenContent);
// }
// show();
// }
//
// private void show() {
// fullscreenContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
// | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
// fullscreenContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// int action = event.getKeyCode();
// switch (action) {
// case KeyEvent.KEYCODE_BACK:
// return true;
// case KeyEvent.KEYCODE_MENU:
// return true;
// default:
// return super.onKeyDown(keyCode, event);
// }
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/ui/service/LockScreenService.java
import android.app.Notification;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.Nullable;
import reader.simple.com.simple_reader.ui.activity.LockScreenActivity;
package reader.simple.com.simple_reader.ui.service;
public class LockScreenService extends Service {
private static int SERVICE_ID = 0xFd;
public LockScreenService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
super.onCreate();
keepLive();
IntentFilter mFilter = new IntentFilter();
mFilter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(mReceiver, mFilter);
}
private void keepLive() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
startForeground(SERVICE_ID, new Notification());
} else {
Intent mIntent = new Intent(this, GrayService.class);
startService(mIntent);
startForeground(SERVICE_ID, new Notification());
}
}
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { | Intent mIntent = new Intent(context, LockScreenActivity.class); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/common/ACache.java | // Path: app/src/main/java/reader/simple/com/simple_reader/BaseApplication.java
// public class BaseApplication extends Application {
//
// public static String cacheDir = "";
// public static Context mAppContext = null;
//
//
// @Override
// public void onCreate() {
// super.onCreate();
// mAppContext = getApplicationContext();
// // 初始化 retrofit
// // CrashHandler.init(new CrashHandler(getApplicationContext()));
//
// /**
// * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
// */
//
// if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
// cacheDir = getApplicationContext().getExternalCacheDir().getAbsolutePath();
//
// } else {
// cacheDir = getApplicationContext().getCacheDir().toString();
// }
// PreferenceManager.initPreferences(this);
// LeakCanary.install(this);
// BlockCanary.install(this, new AppBlockCanaryContext()).start();
// }
//
//
// private boolean ExistSDCard() {
// if (android.os.Environment.getExternalStorageState().equals(android.os.Environment
// .MEDIA_MOUNTED)) {
// return true;
// } else {
// return false;
// }
// }
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import reader.simple.com.simple_reader.BaseApplication; | /**
* Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reader.simple.com.simple_reader.common;
/**
* @author Michael Yang(www.yangfuhai.com) update at 2013.08.07
*/
public class ACache {
public static final int TIME_HOUR = 60 * 60;
public static final int TIME_DAY = TIME_HOUR * 24;
private static final int MAX_SIZE = 1024 * 1024 * 50; // 50 mb
private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量
private static Map<String, ACache> mInstanceMap = new HashMap<String, ACache>();
private ACacheManager mCache;
public static ACache get(Context ctx) {
return get(ctx, "Data");
}
public static ACache get(Context ctx, String cacheName) { | // Path: app/src/main/java/reader/simple/com/simple_reader/BaseApplication.java
// public class BaseApplication extends Application {
//
// public static String cacheDir = "";
// public static Context mAppContext = null;
//
//
// @Override
// public void onCreate() {
// super.onCreate();
// mAppContext = getApplicationContext();
// // 初始化 retrofit
// // CrashHandler.init(new CrashHandler(getApplicationContext()));
//
// /**
// * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
// */
//
// if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
// cacheDir = getApplicationContext().getExternalCacheDir().getAbsolutePath();
//
// } else {
// cacheDir = getApplicationContext().getCacheDir().toString();
// }
// PreferenceManager.initPreferences(this);
// LeakCanary.install(this);
// BlockCanary.install(this, new AppBlockCanaryContext()).start();
// }
//
//
// private boolean ExistSDCard() {
// if (android.os.Environment.getExternalStorageState().equals(android.os.Environment
// .MEDIA_MOUNTED)) {
// return true;
// } else {
// return false;
// }
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/common/ACache.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import reader.simple.com.simple_reader.BaseApplication;
/**
* Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reader.simple.com.simple_reader.common;
/**
* @author Michael Yang(www.yangfuhai.com) update at 2013.08.07
*/
public class ACache {
public static final int TIME_HOUR = 60 * 60;
public static final int TIME_DAY = TIME_HOUR * 24;
private static final int MAX_SIZE = 1024 * 1024 * 50; // 50 mb
private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量
private static Map<String, ACache> mInstanceMap = new HashMap<String, ACache>();
private ACacheManager mCache;
public static ACache get(Context ctx) {
return get(ctx, "Data");
}
public static ACache get(Context ctx, String cacheName) { | File f = new File(BaseApplication.cacheDir, cacheName); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
| import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable; | package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list") | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java
import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list") | Observable<PageInfo> getPageInfos(@Query("pageSize") int pageSize, @Query("page") int pageNum); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
| import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable; | package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list")
Observable<PageInfo> getPageInfos(@Query("pageSize") int pageSize, @Query("page") int pageNum);
@GET("art/info") | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java
import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list")
Observable<PageInfo> getPageInfos(@Query("pageSize") int pageSize, @Query("page") int pageNum);
@GET("art/info") | Observable<ArticleDescInfo> getArticleDescInfo(@Query("id") String id); |
hljwang3874149/ElephantReader | app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
| import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable; | package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list")
Observable<PageInfo> getPageInfos(@Query("pageSize") int pageSize, @Query("page") int pageNum);
@GET("art/info")
Observable<ArticleDescInfo> getArticleDescInfo(@Query("id") String id);
@GET("art/list")
Observable<PageInfo> loadMoreArticle(@Query("pageSize") int pageSize, @Query("create_time") String createTime, @Query("update_time") String
updateTime);
@GET("https://raw.githubusercontent.com/hljwang3874149/UpdateVersion/master/reader.json") | // Path: app/src/main/java/reader/simple/com/simple_reader/domain/ArticleDescInfo.java
// public class ArticleDescInfo {
// @SerializedName("body")
// public ArticleBody articleBody;
//
// public class ArticleBody {
// @SerializedName("article")
// public ArticleInfo articleInfo;
// }
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/PageInfo.java
// public class PageInfo implements Serializable {
//
// @SerializedName("body")
// public PageBody body;
//
// public class PageBody implements Serializable {
// // @SerializedName("ad")
// // public AdInfo adInfo;
// @SerializedName("article")
// public List<ArticleInfo> articleInfoList;
//
// }
//
//
// }
//
// Path: app/src/main/java/reader/simple/com/simple_reader/domain/SplashInfo.java
// public class SplashInfo {
// @SerializedName("versionCode")
// public int versionCode;
// @SerializedName("splashPath")
// public String splashPath;
//
// @Override
// public String toString() {
// return "SplashInfo{" +
// "splashPath='" + splashPath + '\'' +
// ", versionCode=" + versionCode +
// '}';
// }
// }
// Path: app/src/main/java/reader/simple/com/simple_reader/common/netWork/ApiService.java
import reader.simple.com.simple_reader.domain.ArticleDescInfo;
import reader.simple.com.simple_reader.domain.PageInfo;
import reader.simple.com.simple_reader.domain.SplashInfo;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
package reader.simple.com.simple_reader.common.netWork;
/**
* ==================================================
* 项目名称:Simple_Reader
* 创建人:wangxiaolong
* 创建时间:16/4/5 下午4:17
* 修改时间:16/4/5 下午4:17
* 修改备注:
* Version:
* ==================================================
*/
public interface ApiService {
@GET("art/list")
Observable<PageInfo> getPageInfos(@Query("pageSize") int pageSize, @Query("page") int pageNum);
@GET("art/info")
Observable<ArticleDescInfo> getArticleDescInfo(@Query("id") String id);
@GET("art/list")
Observable<PageInfo> loadMoreArticle(@Query("pageSize") int pageSize, @Query("create_time") String createTime, @Query("update_time") String
updateTime);
@GET("https://raw.githubusercontent.com/hljwang3874149/UpdateVersion/master/reader.json") | Observable<SplashInfo> loadSplashImg(); |
apptik/MultiSlider | mslider-uiautomator/src/main/java/io/apptik/widget/UiMultiSlider.java | // Path: lib/src/main/java/io/apptik/widget/MultiSlider.java
// static final int ACT_SET_PROGRESS = 16908349;
| import android.os.Bundle;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.test.uiautomator.Configurator;
import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiObjectNotFoundException;
import androidx.test.uiautomator.UiScrollable;
import androidx.test.uiautomator.UiSelector;
import static io.apptik.widget.MultiSlider.VirtualTreeProvider.ACT_SET_PROGRESS; | public UiMultiSlider(UiObject uiObject) {
this(uiObject.getSelector());
}
public boolean moveThumbForward() throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return ani.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
public boolean moveThumbBackward() throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return ani.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
public boolean setThumbValue(int value) throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
Bundle args = new Bundle();
args.putInt("value", value); | // Path: lib/src/main/java/io/apptik/widget/MultiSlider.java
// static final int ACT_SET_PROGRESS = 16908349;
// Path: mslider-uiautomator/src/main/java/io/apptik/widget/UiMultiSlider.java
import android.os.Bundle;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.test.uiautomator.Configurator;
import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiObjectNotFoundException;
import androidx.test.uiautomator.UiScrollable;
import androidx.test.uiautomator.UiSelector;
import static io.apptik.widget.MultiSlider.VirtualTreeProvider.ACT_SET_PROGRESS;
public UiMultiSlider(UiObject uiObject) {
this(uiObject.getSelector());
}
public boolean moveThumbForward() throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return ani.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
public boolean moveThumbBackward() throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return ani.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
public boolean setThumbValue(int value) throws UiObjectNotFoundException {
AccessibilityNodeInfo ani =
findAccessibilityNodeInfo(Configurator.getInstance().getWaitForSelectorTimeout());
if (ani == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
Bundle args = new Bundle();
args.putInt("value", value); | return ani.performAction(ACT_SET_PROGRESS, args); |
apptik/MultiSlider | lib/src/main/java/io/apptik/widget/MultiSlider.java | // Path: lib/src/main/java/io/apptik/widget/Util.java
// public static <T> T requireNonNull(T o) {
// if (o == null) {
// throw new NullPointerException();
// }
// return o;
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import io.apptik.widget.mslider.R;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD;
import static io.apptik.widget.Util.requireNonNull; | // This way, calling setThumbDrawables again with the same bitmap will result in
// it recalculating thumbOffset (if for example it the bounds of the
// drawable changed)
int curr = 0;
int padding = 0;
int rCol;
for (Thumb mThumb : mThumbs) {
curr++;
if (mThumb.getThumb() != null && thumb != mThumb.getThumb()) {
mThumb.getThumb().setCallback(null);
}
if (curr == 1 && range1 != null) {
rangeDrawable = range1;
rCol = a.getColor(io.apptik.widget.mslider.R.styleable.MultiSlider_range1Color, 0);
} else if (curr == 2 && range2 != null) {
rangeDrawable = range2;
rCol = a.getColor(io.apptik.widget.mslider.R.styleable.MultiSlider_range2Color, 0);
} else {
rangeDrawable = range;
rCol = defRangeColor;
}
setRangeDrawable(mThumb, rangeDrawable, rCol);
setThumbDrawable(mThumb, thumb, defThumbColor);
padding = Math.max(padding, mThumb.getThumbOffset());
}
setPadding(padding, getPaddingTop(), padding, getPaddingBottom());
}
private void setThumbDrawable(Thumb thumb, Drawable thumbDrawable, int thumbColor) { | // Path: lib/src/main/java/io/apptik/widget/Util.java
// public static <T> T requireNonNull(T o) {
// if (o == null) {
// throw new NullPointerException();
// }
// return o;
// }
// Path: lib/src/main/java/io/apptik/widget/MultiSlider.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import io.apptik.widget.mslider.R;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD;
import static io.apptik.widget.Util.requireNonNull;
// This way, calling setThumbDrawables again with the same bitmap will result in
// it recalculating thumbOffset (if for example it the bounds of the
// drawable changed)
int curr = 0;
int padding = 0;
int rCol;
for (Thumb mThumb : mThumbs) {
curr++;
if (mThumb.getThumb() != null && thumb != mThumb.getThumb()) {
mThumb.getThumb().setCallback(null);
}
if (curr == 1 && range1 != null) {
rangeDrawable = range1;
rCol = a.getColor(io.apptik.widget.mslider.R.styleable.MultiSlider_range1Color, 0);
} else if (curr == 2 && range2 != null) {
rangeDrawable = range2;
rCol = a.getColor(io.apptik.widget.mslider.R.styleable.MultiSlider_range2Color, 0);
} else {
rangeDrawable = range;
rCol = defRangeColor;
}
setRangeDrawable(mThumb, rangeDrawable, rCol);
setThumbDrawable(mThumb, thumb, defThumbColor);
padding = Math.max(padding, mThumb.getThumbOffset());
}
setPadding(padding, getPaddingTop(), padding, getPaddingBottom());
}
private void setThumbDrawable(Thumb thumb, Drawable thumbDrawable, int thumbColor) { | requireNonNull(thumbDrawable); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
| import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection; | package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection;
package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override | public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) { |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
| import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection; | package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override
public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
return request;
}
@Override | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection;
package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override
public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
return request;
}
@Override | public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) { |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
| import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection; | package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override
public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
return request;
}
@Override
public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
ReflectionUtils.makeAccessible(f);
Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
Object value = ((Collection) field.get("testHint")).iterator().next();
if (!"testHintValue".equals(value)) { | // Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestException.java
// public class TestException extends RuntimeException {
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
import com.google.common.collect.Multimap;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import cz.encircled.joiner.core.TestException;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Collection;
package cz.encircled.joiner.config.hint;
/**
* @author Kisel on 04.02.2016.
*/
public class HintQueryFeature implements QueryFeature {
@Override
public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
return request;
}
@Override
public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
ReflectionUtils.makeAccessible(f);
Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
Object value = ((Collection) field.get("testHint")).iterator().next();
if (!"testHintValue".equals(value)) { | throw new TestException(); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/TupleProjectionTest.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import com.querydsl.core.Tuple;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*; | package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TupleProjectionTest extends AbstractTest {
@Test
public void testSingleTuple() { | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/TupleProjectionTest.java
import com.querydsl.core.Tuple;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TupleProjectionTest extends AbstractTest {
@Test
public void testSingleTuple() { | List<Long> ids = joiner.find(Q.select(QUser.user1.id).from(QUser.user1)); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java | // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
| import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection; | package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement | // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java
import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection;
package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement | @TestExecutionListeners(listeners = {TestDataListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class}) |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java | // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
| import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection; | package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement
@TestExecutionListeners(listeners = {TestDataListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
public abstract class AbstractTest {
@Autowired
protected Joiner joiner;
@Autowired | // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java
import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection;
package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement
@TestExecutionListeners(listeners = {TestDataListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
public abstract class AbstractTest {
@Autowired
protected Joiner joiner;
@Autowired | protected JoinGraphRegistry joinGraphRegistry; |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java | // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
| import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection; | package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement
@TestExecutionListeners(listeners = {TestDataListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
public abstract class AbstractTest {
@Autowired
protected Joiner joiner;
@Autowired
protected JoinGraphRegistry joinGraphRegistry;
@PersistenceContext
protected EntityManager entityManager;
@Autowired
private Environment environment;
| // Path: joiner-test-support/src/main/java/cz/encircled/joiner/TestDataListener.java
// public class TestDataListener implements TestExecutionListener {
//
// public void beforeTestClass(TestContext testContext) throws Exception {
//
// }
//
// public void prepareTestInstance(TestContext testContext) throws Exception {
// TestData bean = testContext.getApplicationContext().getBean(TestData.class);
// bean.prepareData();
// }
//
// public void beforeTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestMethod(TestContext testContext) throws Exception {
//
// }
//
// public void afterTestClass(TestContext testContext) throws Exception {
//
// }
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-test-support/src/main/java/cz/encircled/joiner/model/AbstractEntity.java
// @MappedSuperclass
// public class AbstractEntity {
//
// @Column
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// protected Long id;
//
// @Column
// protected String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(final Long id) {
// this.id = id;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinGraphRegistry.java
// public interface JoinGraphRegistry {
//
// /**
// * Adds new join graph to the registry.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Replace an existing join graph with a new one
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void replaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// * Adds new join graph to the registry or replace an existing one.
// *
// * @param graphName graph unique name. Generally, any object may be used as a name, it should have correct hashCode method. String or enum is recommended.
// * @param joins associated joins
// * @param rootClasses target class for a new join graph
// */
// void registerOrReplaceJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses);
//
// /**
// *
// * @param clazz target class
// * @param name join graph name
// * @return collection of registered join graphs
// */
// List<JoinDescription> getJoinGraph(Class<?> clazz, Object name);
//
// /**
// * @param clazz target class
// * @return map of all registered join graphs
// */
// Map<Object, List<JoinDescription>> getAllJoinGraphs(Class<?> clazz);
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/AbstractTest.java
import cz.encircled.joiner.TestDataListener;
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.model.AbstractEntity;
import cz.encircled.joiner.query.join.JoinGraphRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import java.util.Collection;
package cz.encircled.joiner.core;
/**
* @author Kisel on 11.01.2016.
*/
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig(classes = {TestConfig.class})
@ContextConfiguration(classes = {TestConfig.class})
@Transactional
@EnableTransactionManagement
@TestExecutionListeners(listeners = {TestDataListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
public abstract class AbstractTest {
@Autowired
protected Joiner joiner;
@Autowired
protected JoinGraphRegistry joinGraphRegistry;
@PersistenceContext
protected EntityManager entityManager;
@Autowired
private Environment environment;
| protected void assertHasName(Collection<? extends AbstractEntity> entities, String name) { |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/util/ReflectionUtils.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
| import cz.encircled.joiner.exception.JoinerException;
import javax.persistence.EntityManager;
import javax.persistence.metamodel.Type;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors; | package cz.encircled.joiner.util;
/**
* @author Vlad on 14-Aug-16.
*/
public class ReflectionUtils {
@SuppressWarnings("unchecked")
public static <T> T instantiate(Class<?> generatedClass, Object... arguments) {
Assert.notNull(generatedClass);
try {
// TODO nulls?
Class[] classesOfArgs = new Class[arguments.length];
for (int i = 0; i < arguments.length; i++) {
classesOfArgs[i] = arguments[i].getClass();
}
Constructor<?> constructor = findConstructor(generatedClass, classesOfArgs);
if (!constructor.isAccessible()) {
constructor.setAccessible(true);
}
return (T) constructor.newInstance(arguments);
} catch (Exception e) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/ReflectionUtils.java
import cz.encircled.joiner.exception.JoinerException;
import javax.persistence.EntityManager;
import javax.persistence.metamodel.Type;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
package cz.encircled.joiner.util;
/**
* @author Vlad on 14-Aug-16.
*/
public class ReflectionUtils {
@SuppressWarnings("unchecked")
public static <T> T instantiate(Class<?> generatedClass, Object... arguments) {
Assert.notNull(generatedClass);
try {
// TODO nulls?
Class[] classesOfArgs = new Class[arguments.length];
for (int i = 0; i < arguments.length; i++) {
classesOfArgs[i] = arguments[i].getClass();
}
Constructor<?> constructor = findConstructor(generatedClass, classesOfArgs);
if (!constructor.isAccessible()) {
constructor.setAccessible(true);
}
return (T) constructor.newInstance(arguments);
} catch (Exception e) { | throw new JoinerException("Failed to create new instance of " + generatedClass, e); |
encircled/Joiner | joiner-spring/src/main/java/cz/encircled/joiner/spring/PageableFeature.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
| import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.PathBuilder;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.PropertyPath;
import java.util.Optional; | package cz.encircled.joiner.spring;
/**
* This feature allows applying spring {@link Pageable} criteria (limit, offset, sort) to the query
*
* @author Kisel on 29.10.2016.
*/
public class PageableFeature implements QueryFeature {
@Autowired
private final Pageable pageable;
public PageableFeature(Pageable pageable) {
this.pageable = pageable;
}
@Override | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/ExtendedJPAQuery.java
// public class ExtendedJPAQuery<T> extends JPAQuery<T> {
//
// public ExtendedJPAQuery(EntityManager entityManager, JPAQuery<T> another) {
// super(entityManager, another.getMetadata().clone());
// clone(another);
// }
//
// public JPQLSerializer getSerializer(boolean forCount) {
// return serialize(forCount);
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinerQuery.java
// public interface JoinerQuery<T, R> extends JoinRoot {
//
// EntityPath<T> getFrom();
//
// Expression<R> getReturnProjection();
//
// JoinerQuery<T, R> where(Predicate where);
//
// Predicate getWhere();
//
// JoinerQuery<T, R> distinct(boolean isDistinct);
//
// boolean isDistinct();
//
// JoinerQuery<T, R> groupBy(Path<?> groupBy);
//
// Path<?> getGroupBy();
//
// JoinerQuery<T, R> having(Predicate having);
//
// Predicate getHaving();
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQuery<T, R> joinGraphs(String... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Enum... names);
//
// /**
// * Add join graphs to the query.
// *
// * @param names names of join graphs
// * @return this
// * @see cz.encircled.joiner.query.join.JoinGraphRegistry
// */
// JoinerQueryBase<T, R> joinGraphs(Collection<?> names);
//
// Set<Object> getJoinGraphs();
//
// /**
// * Add <b>left</b> joins for specified paths
// *
// * @param paths join paths
// * @return this
// */
// JoinerQueryBase<T, R> joins(EntityPath<?>... paths);
//
// JoinerQueryBase<T, R> joins(CollectionPathBase<?, ?, ?>... path);
//
// JoinerQueryBase<T, R> joins(JoinDescription... joins);
//
// JoinerQueryBase<T, R> joins(Collection<JoinDescription> joins);
//
// Collection<JoinDescription> getJoins();
//
// JoinerQueryBase<T, R> addHint(String hint, Object value);
//
// LinkedHashMap<String, List<Object>> getHints();
//
// JoinerQueryBase<T, R> addFeatures(QueryFeature... features);
//
// JoinerQueryBase<T, R> addFeatures(Collection<QueryFeature> features);
//
// List<QueryFeature> getFeatures();
//
// /**
// * Set offset for the query results
// *
// * @param offset value
// * @return this
// */
// JoinerQuery<T, R> offset(Long offset);
//
// Long getOffset();
//
// /**
// * Set max results for the query results
// *
// * @param limit value
// * @return this
// */
// JoinerQuery<T, R> limit(Long limit);
//
// Long getLimit();
//
// JoinerQuery<T, R> asc(Expression<?> orderBy);
//
// JoinerQuery<T, R> desc(Expression<?> orderBy);
//
// List<QueryOrder> getOrder();
//
// JoinerQuery<T, R> copy();
//
// boolean isCount();
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/QueryFeature.java
// public interface QueryFeature {
//
// /**
// * This method is called before JPA query creation and allows request modification
// *
// * @param request initial joiner request
// * @param <T> query from
// * @param <R> query return type
// * @return modified request
// */
// <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> request);
//
// /**
// * This method is called just before JPA query execution and allows to modify result query directly
// *
// * @param request initial joiner request
// * @param query JPA query
// * @return modified JPA query to be executed
// */
// default <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// return query;
// }
//
// }
// Path: joiner-spring/src/main/java/cz/encircled/joiner/spring/PageableFeature.java
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.PathBuilder;
import cz.encircled.joiner.query.ExtendedJPAQuery;
import cz.encircled.joiner.query.JoinerQuery;
import cz.encircled.joiner.query.QueryFeature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.PropertyPath;
import java.util.Optional;
package cz.encircled.joiner.spring;
/**
* This feature allows applying spring {@link Pageable} criteria (limit, offset, sort) to the query
*
* @author Kisel on 29.10.2016.
*/
public class PageableFeature implements QueryFeature {
@Autowired
private final Pageable pageable;
public PageableFeature(Pageable pageable) {
this.pageable = pageable;
}
@Override | public <T, R> JoinerQuery<T, R> before(JoinerQuery<T, R> joinerQuery) { |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinDescription.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinRoot.java
// public interface JoinRoot {
//
// default JoinDescription getJoin(Expression<?> expression) {
// Assert.notNull(expression);
//
// return getAllJoins().get(expression.toString());
// }
//
// Map<String, JoinDescription> getAllJoins();
//
// default void addJoin(JoinDescription join) {
// String key = join.getOriginalAlias().toString();
// JoinDescription present = getAllJoins().get(key);
// if (present == null) {
// getAllJoins().put(key, join);
// } else {
// for (JoinDescription joinDescription : join.getChildren()) {
// present.nested(joinDescription);
// }
// }
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
| import com.querydsl.core.JoinType;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.CollectionPathBase;
import cz.encircled.joiner.query.JoinRoot;
import cz.encircled.joiner.util.Assert;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; | package cz.encircled.joiner.query.join;
/**
* Represents query join.
* For collection joins - {@link JoinDescription#collectionPath collectionPath} is used, for single entity joins - {@link JoinDescription#singlePath singlePath}.
* <p>
* By default, all joins are <b>left fetch</b> joins
* </p>
*
* @author Kisel on 21.01.2016.
*/
public class JoinDescription implements JoinRoot {
private final EntityPath<?> originalAlias;
private CollectionPathBase<?, ?, ?> collectionPath;
private EntityPath<?> singlePath;
private EntityPath<?> alias;
private JoinType joinType = JoinType.LEFTJOIN;
private boolean fetch = true;
private Predicate on;
private JoinDescription parent;
private Map<String, JoinDescription> children = new LinkedHashMap<>(4);
public JoinDescription(EntityPath<?> alias) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/JoinRoot.java
// public interface JoinRoot {
//
// default JoinDescription getJoin(Expression<?> expression) {
// Assert.notNull(expression);
//
// return getAllJoins().get(expression.toString());
// }
//
// Map<String, JoinDescription> getAllJoins();
//
// default void addJoin(JoinDescription join) {
// String key = join.getOriginalAlias().toString();
// JoinDescription present = getAllJoins().get(key);
// if (present == null) {
// getAllJoins().put(key, join);
// } else {
// for (JoinDescription joinDescription : join.getChildren()) {
// present.nested(joinDescription);
// }
// }
// }
//
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/JoinDescription.java
import com.querydsl.core.JoinType;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.CollectionPathBase;
import cz.encircled.joiner.query.JoinRoot;
import cz.encircled.joiner.util.Assert;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
package cz.encircled.joiner.query.join;
/**
* Represents query join.
* For collection joins - {@link JoinDescription#collectionPath collectionPath} is used, for single entity joins - {@link JoinDescription#singlePath singlePath}.
* <p>
* By default, all joins are <b>left fetch</b> joins
* </p>
*
* @author Kisel on 21.01.2016.
*/
public class JoinDescription implements JoinRoot {
private final EntityPath<?> originalAlias;
private CollectionPathBase<?, ?, ?> collectionPath;
private EntityPath<?> singlePath;
private EntityPath<?> alias;
private JoinType joinType = JoinType.LEFTJOIN;
private boolean fetch = true;
private Predicate on;
private JoinDescription parent;
private Map<String, JoinDescription> children = new LinkedHashMap<>(4);
public JoinDescription(EntityPath<?> alias) { | Assert.notNull(alias); |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/query/Q.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
| import com.querydsl.core.Tuple;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import cz.encircled.joiner.util.Assert; | package cz.encircled.joiner.query;
/**
* This class contains helper methods for joiner query building
*/
public class Q {
/**
* Build tuple query projections (i.e. select clause)
*
* @param returnProjections path to query projection
* @return joiner query with custom tuple query projection
*/
public static FromBuilder<Tuple> select(Expression<?>... returnProjections) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
import com.querydsl.core.Tuple;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import cz.encircled.joiner.util.Assert;
package cz.encircled.joiner.query;
/**
* This class contains helper methods for joiner query building
*/
public class Q {
/**
* Build tuple query projections (i.e. select clause)
*
* @param returnProjections path to query projection
* @return joiner query with custom tuple query projection
*/
public static FromBuilder<Tuple> select(Expression<?>... returnProjections) { | Assert.notNull(returnProjections); |
encircled/Joiner | example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/controller/JavaEmploymentController.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
//
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/Employment.java
// @Entity
// @Table
// public class Employment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// public Long id;
//
// @Column
// public String name;
//
// }
| import cz.encircled.joiner.query.Q;
import cz.encircled.joiner.reactive.ReactorJoiner;
import cz.encircled.joiner.springwebfluxexample.Employment;
import cz.encircled.joiner.springwebfluxexample.QEmployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; | package cz.encircled.joiner.springwebfluxexample.controller;
@RestController
@RequestMapping("/java/employment")
public class JavaEmploymentController {
@Autowired
ReactorJoiner joiner;
@GetMapping("{id}") | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
//
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/Employment.java
// @Entity
// @Table
// public class Employment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// public Long id;
//
// @Column
// public String name;
//
// }
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/controller/JavaEmploymentController.java
import cz.encircled.joiner.query.Q;
import cz.encircled.joiner.reactive.ReactorJoiner;
import cz.encircled.joiner.springwebfluxexample.Employment;
import cz.encircled.joiner.springwebfluxexample.QEmployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
package cz.encircled.joiner.springwebfluxexample.controller;
@RestController
@RequestMapping("/java/employment")
public class JavaEmploymentController {
@Autowired
ReactorJoiner joiner;
@GetMapping("{id}") | Mono<Employment> getOne(@PathVariable Long id) { |
encircled/Joiner | example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/controller/JavaEmploymentController.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
//
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/Employment.java
// @Entity
// @Table
// public class Employment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// public Long id;
//
// @Column
// public String name;
//
// }
| import cz.encircled.joiner.query.Q;
import cz.encircled.joiner.reactive.ReactorJoiner;
import cz.encircled.joiner.springwebfluxexample.Employment;
import cz.encircled.joiner.springwebfluxexample.QEmployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; | package cz.encircled.joiner.springwebfluxexample.controller;
@RestController
@RequestMapping("/java/employment")
public class JavaEmploymentController {
@Autowired
ReactorJoiner joiner;
@GetMapping("{id}")
Mono<Employment> getOne(@PathVariable Long id) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
//
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/Employment.java
// @Entity
// @Table
// public class Employment {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator")
// @SequenceGenerator(name = "id_generator", sequenceName = "id_seq", initialValue = 1, allocationSize = 1)
// public Long id;
//
// @Column
// public String name;
//
// }
// Path: example/spring-webflux-example/src/main/kotlin/cz/encircled/joiner/springwebfluxexample/controller/JavaEmploymentController.java
import cz.encircled.joiner.query.Q;
import cz.encircled.joiner.reactive.ReactorJoiner;
import cz.encircled.joiner.springwebfluxexample.Employment;
import cz.encircled.joiner.springwebfluxexample.QEmployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
package cz.encircled.joiner.springwebfluxexample.controller;
@RestController
@RequestMapping("/java/employment")
public class JavaEmploymentController {
@Autowired
ReactorJoiner joiner;
@GetMapping("{id}")
Mono<Employment> getOne(@PathVariable Long id) { | return joiner.findOne(Q.from(QEmployment.employment).where(QEmployment.employment.id.eq(id))); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/TestFindOne.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows; | package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TestFindOne extends AbstractTest {
@Test
public void testFindOneMultipleResults() { | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestFindOne.java
import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TestFindOne extends AbstractTest {
@Test
public void testFindOneMultipleResults() { | assertThrows(JoinerException.class, () -> joiner.findOne(Q.from(QUser.user1))); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/TestFindOne.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows; | package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TestFindOne extends AbstractTest {
@Test
public void testFindOneMultipleResults() { | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestFindOne.java
import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
package cz.encircled.joiner.core;
/**
* @author Vlad on 11-Feb-17.
*/
public class TestFindOne extends AbstractTest {
@Test
public void testFindOneMultipleResults() { | assertThrows(JoinerException.class, () -> joiner.findOne(Q.from(QUser.user1))); |
encircled/Joiner | joiner-eclipse/src/main/java/cz/encircled/joiner/eclipse/InheritanceJoiningCustomizer.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
| import cz.encircled.joiner.exception.JoinerException;
import org.eclipse.persistence.config.DescriptorCustomizer;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.descriptors.InheritancePolicy;
import org.eclipse.persistence.internal.descriptors.ObjectBuilder;
import org.eclipse.persistence.mappings.DatabaseMapping;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap; | @Override
public DatabaseMapping getMappingForAttributeName(String name) {
DatabaseMapping mapping = super.getMappingForAttributeName(name);
// name contains spaces for "treat as ..." entries, just skip it
if (mapping == null && !name.contains(SPACE)) {
InheritancePolicy policy = this.descriptor.getInheritancePolicyOrNull();
if (policy != null) {
mapping = findMappingOnChildren(policy, name);
}
}
return mapping;
}
private DatabaseMapping findMappingOnChildren(InheritancePolicy policy, String name) {
ArrayList<DatabaseMapping> found = new ArrayList<>();
for (ClassDescriptor child : policy.getChildDescriptors()) {
DatabaseMapping childMapping = child.getObjectBuilder().getMappingForAttributeName(name);
if (childMapping != null) {
found.add(childMapping);
}
}
switch (found.size()) {
case 0:
return null;
case 1:
return found.get(0);
default: | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
// Path: joiner-eclipse/src/main/java/cz/encircled/joiner/eclipse/InheritanceJoiningCustomizer.java
import cz.encircled.joiner.exception.JoinerException;
import org.eclipse.persistence.config.DescriptorCustomizer;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.descriptors.InheritancePolicy;
import org.eclipse.persistence.internal.descriptors.ObjectBuilder;
import org.eclipse.persistence.mappings.DatabaseMapping;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
@Override
public DatabaseMapping getMappingForAttributeName(String name) {
DatabaseMapping mapping = super.getMappingForAttributeName(name);
// name contains spaces for "treat as ..." entries, just skip it
if (mapping == null && !name.contains(SPACE)) {
InheritancePolicy policy = this.descriptor.getInheritancePolicyOrNull();
if (policy != null) {
mapping = findMappingOnChildren(policy, name);
}
}
return mapping;
}
private DatabaseMapping findMappingOnChildren(InheritancePolicy policy, String name) {
ArrayList<DatabaseMapping> found = new ArrayList<>();
for (ClassDescriptor child : policy.getChildDescriptors()) {
DatabaseMapping childMapping = child.getObjectBuilder().getMappingForAttributeName(name);
if (childMapping != null) {
found.add(childMapping);
}
}
switch (found.size()) {
case 0:
return null;
case 1:
return found.get(0);
default: | throw new JoinerException("Multiple mappings found for name " + name); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/HintsTest.java | // Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
// public class HintQueryFeature implements QueryFeature {
//
// @Override
// public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
// return request;
// }
//
// @Override
// public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
// ReflectionUtils.makeAccessible(f);
// Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
//
// Object value = ((Collection) field.get("testHint")).iterator().next();
// if (!"testHintValue".equals(value)) {
// throw new TestException();
// }
//
// return query;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.config.hint.HintQueryFeature;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.ContextConfiguration;
import static org.junit.jupiter.api.Assertions.assertThrows; | package cz.encircled.joiner.core;
/**
* @author Kisel on 04.02.2016.
*/
@ContextConfiguration(classes = {TestConfig.class})
public class HintsTest extends AbstractTest {
@Test
public void testHint() { | // Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
// public class HintQueryFeature implements QueryFeature {
//
// @Override
// public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
// return request;
// }
//
// @Override
// public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
// ReflectionUtils.makeAccessible(f);
// Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
//
// Object value = ((Collection) field.get("testHint")).iterator().next();
// if (!"testHintValue".equals(value)) {
// throw new TestException();
// }
//
// return query;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/HintsTest.java
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.config.hint.HintQueryFeature;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.ContextConfiguration;
import static org.junit.jupiter.api.Assertions.assertThrows;
package cz.encircled.joiner.core;
/**
* @author Kisel on 04.02.2016.
*/
@ContextConfiguration(classes = {TestConfig.class})
public class HintsTest extends AbstractTest {
@Test
public void testHint() { | joiner.find(Q.from(QUser.user1).addHint("testHint", "testHintValue").addFeatures(new HintQueryFeature())); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/HintsTest.java | // Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
// public class HintQueryFeature implements QueryFeature {
//
// @Override
// public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
// return request;
// }
//
// @Override
// public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
// ReflectionUtils.makeAccessible(f);
// Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
//
// Object value = ((Collection) field.get("testHint")).iterator().next();
// if (!"testHintValue".equals(value)) {
// throw new TestException();
// }
//
// return query;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.config.hint.HintQueryFeature;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.ContextConfiguration;
import static org.junit.jupiter.api.Assertions.assertThrows; | package cz.encircled.joiner.core;
/**
* @author Kisel on 04.02.2016.
*/
@ContextConfiguration(classes = {TestConfig.class})
public class HintsTest extends AbstractTest {
@Test
public void testHint() { | // Path: joiner-core/src/test/java/cz/encircled/joiner/config/TestConfig.java
// @Configuration
// @Import(EntityManagerConfig.class)
// @ComponentScan(basePackages = {"cz.encircled.joiner"})
// public class TestConfig {
//
// @PersistenceContext
// private EntityManager entityManager;
//
// @Bean
// public JoinGraphRegistry joinGraphRegistry() {
// return new DefaultJoinGraphRegistry();
// }
//
// @Bean
// public Joiner joiner(JoinGraphRegistry joinGraphRegistry) {
// Joiner joiner = new Joiner(entityManager);
// joiner.setJoinGraphRegistry(joinGraphRegistry);
// return joiner;
// }
//
// }
//
// Path: joiner-core/src/test/java/cz/encircled/joiner/config/hint/HintQueryFeature.java
// public class HintQueryFeature implements QueryFeature {
//
// @Override
// public <T, R> JoinerQuery<T, R> before(final JoinerQuery<T, R> request) {
// return request;
// }
//
// @Override
// public <T, R> ExtendedJPAQuery<R> after(JoinerQuery<T, R> request, ExtendedJPAQuery<R> query) {
// Field f = ReflectionUtils.findField(AbstractJPAQuery.class, "hints");
// ReflectionUtils.makeAccessible(f);
// Multimap<String, Object> field = (Multimap<String, Object>) ReflectionUtils.getField(f, query);
//
// Object value = ((Collection) field.get("testHint")).iterator().next();
// if (!"testHintValue".equals(value)) {
// throw new TestException();
// }
//
// return query;
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/HintsTest.java
import cz.encircled.joiner.config.TestConfig;
import cz.encircled.joiner.config.hint.HintQueryFeature;
import cz.encircled.joiner.model.QUser;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.ContextConfiguration;
import static org.junit.jupiter.api.Assertions.assertThrows;
package cz.encircled.joiner.core;
/**
* @author Kisel on 04.02.2016.
*/
@ContextConfiguration(classes = {TestConfig.class})
public class HintsTest extends AbstractTest {
@Test
public void testHint() { | joiner.find(Q.from(QUser.user1).addHint("testHint", "testHintValue").addFeatures(new HintQueryFeature())); |
encircled/Joiner | joiner-core/src/test/java/cz/encircled/joiner/core/TestGroupBy.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
| import cz.encircled.joiner.model.QAddress;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue; | package cz.encircled.joiner.core;
/**
* @author Kisel on 28.01.2016.
*/
public class TestGroupBy extends AbstractTest {
@Test
public void testGroupBy() {
List<Double> avg = joiner.find( | // Path: joiner-core/src/main/java/cz/encircled/joiner/query/Q.java
// public class Q {
//
// /**
// * Build tuple query projections (i.e. select clause)
// *
// * @param returnProjections path to query projection
// * @return joiner query with custom tuple query projection
// */
// public static FromBuilder<Tuple> select(Expression<?>... returnProjections) {
// Assert.notNull(returnProjections);
// return new TupleQueryFromBuilder(returnProjections);
// }
//
// /**
// * Build query projection (i.e. select clause)
// *
// * @param returnProjection path to query projection
// * @param <R> type of source entity
// * @return joiner query with custom query projection
// */
// public static <R> FromBuilder<R> select(Expression<R> returnProjection) {
// return new ExpressionQueryFromBuilder<>(returnProjection);
// }
//
// /**
// * Build "from" clause of query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return joiner query
// */
// public static <T> JoinerQuery<T, T> from(EntityPath<T> from) {
// return new JoinerQueryBase<>(from, from);
// }
//
// /**
// * Build count query
// *
// * @param from alias of source entity
// * @param <T> type of source entity
// * @return count joiner query
// */
// public static <T> JoinerQuery<T, Long> count(EntityPath<T> from) {
// JoinerQueryBase<T, Long> request = new JoinerQueryBase<>(from, true);
// request.distinct(false);
// return request;
// }
//
// }
// Path: joiner-core/src/test/java/cz/encircled/joiner/core/TestGroupBy.java
import cz.encircled.joiner.model.QAddress;
import cz.encircled.joiner.query.Q;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue;
package cz.encircled.joiner.core;
/**
* @author Kisel on 28.01.2016.
*/
public class TestGroupBy extends AbstractTest {
@Test
public void testGroupBy() {
List<Double> avg = joiner.find( | Q.select(QAddress.address.id.avg()) |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/query/TupleJoinerQuery.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// @SuppressWarnings("unchecked")
// public static <T> T instantiate(Class<?> generatedClass, Object... arguments) {
// Assert.notNull(generatedClass);
//
// try {
// // TODO nulls?
// Class[] classesOfArgs = new Class[arguments.length];
// for (int i = 0; i < arguments.length; i++) {
// classesOfArgs[i] = arguments[i].getClass();
// }
//
// Constructor<?> constructor = findConstructor(generatedClass, classesOfArgs);
// if (!constructor.isAccessible()) {
// constructor.setAccessible(true);
// }
// return (T) constructor.newInstance(arguments);
// } catch (Exception e) {
// throw new JoinerException("Failed to create new instance of " + generatedClass, e);
// }
// }
//
// public static Constructor<?> findConstructor(Class<?> clazz, Class[] argumentClasses) {
// outer:
// for (Constructor<?> constructor : clazz.getDeclaredConstructors()) {
// final Class<?>[] params = constructor.getParameterTypes();
// if (params.length == argumentClasses.length) {
// for (int i = 0; i < argumentClasses.length; i++) {
// if (!params[i].isAssignableFrom(argumentClasses[i])) {
// continue outer;
// }
// }
// return constructor;
// }
// }
//
// throw new RuntimeException("Constructor with params [" + Arrays.toString(argumentClasses) + "] is not found in [" + clazz + "]");
// }
//
// public static Field findField(Class<?> clazz, String name) {
// Assert.notNull(clazz);
// Assert.notNull(name);
//
// try {
// return clazz.getDeclaredField(name);
// } catch (NoSuchFieldException e) {
// return null;
// }
// }
//
// public static void setField(Field field, Object targetObject, Object value) {
// Assert.notNull(field);
//
// makeAccessible(field);
// try {
// field.set(targetObject, value);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static Object getField(String field, Object object) {
// return getField(findField(object.getClass(), field), object);
// }
//
// public static Object getField(Field field, Object object) {
// Assert.notNull(field);
// makeAccessible(field);
//
// try {
// return field.get(object);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static Set<Class> getSubclasses(Class<?> parent, EntityManager entityManager) {
// return entityManager.getMetamodel().getEntities().stream()
// .filter(entityType -> parent != entityType.getJavaType() && parent.isAssignableFrom(entityType.getJavaType()))
// .map(Type::getJavaType)
// .collect(Collectors.toCollection(HashSet::new));
// }
//
// private static void makeAccessible(Field field) {
// if (field != null && !field.isAccessible()) {
// field.setAccessible(true);
// }
// }
//
// }
| import com.querydsl.core.Tuple;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.QTuple;
import cz.encircled.joiner.util.ReflectionUtils; | package cz.encircled.joiner.query;
/**
* Implementation of joiner query with {@link Tuple} result
*
* @author Kisel on 13.9.2016.
*/
public class TupleJoinerQuery<T> extends JoinerQueryBase<T, Tuple> {
private final Expression<?>[] returnProjections;
public TupleJoinerQuery(EntityPath<T> from, Expression<?>... returnProjections) {
super(from);
this.returnProjections = returnProjections;
}
@Override
@SuppressWarnings("unchecked")
public Expression<Tuple> getReturnProjection() { | // Path: joiner-core/src/main/java/cz/encircled/joiner/util/ReflectionUtils.java
// public class ReflectionUtils {
//
// @SuppressWarnings("unchecked")
// public static <T> T instantiate(Class<?> generatedClass, Object... arguments) {
// Assert.notNull(generatedClass);
//
// try {
// // TODO nulls?
// Class[] classesOfArgs = new Class[arguments.length];
// for (int i = 0; i < arguments.length; i++) {
// classesOfArgs[i] = arguments[i].getClass();
// }
//
// Constructor<?> constructor = findConstructor(generatedClass, classesOfArgs);
// if (!constructor.isAccessible()) {
// constructor.setAccessible(true);
// }
// return (T) constructor.newInstance(arguments);
// } catch (Exception e) {
// throw new JoinerException("Failed to create new instance of " + generatedClass, e);
// }
// }
//
// public static Constructor<?> findConstructor(Class<?> clazz, Class[] argumentClasses) {
// outer:
// for (Constructor<?> constructor : clazz.getDeclaredConstructors()) {
// final Class<?>[] params = constructor.getParameterTypes();
// if (params.length == argumentClasses.length) {
// for (int i = 0; i < argumentClasses.length; i++) {
// if (!params[i].isAssignableFrom(argumentClasses[i])) {
// continue outer;
// }
// }
// return constructor;
// }
// }
//
// throw new RuntimeException("Constructor with params [" + Arrays.toString(argumentClasses) + "] is not found in [" + clazz + "]");
// }
//
// public static Field findField(Class<?> clazz, String name) {
// Assert.notNull(clazz);
// Assert.notNull(name);
//
// try {
// return clazz.getDeclaredField(name);
// } catch (NoSuchFieldException e) {
// return null;
// }
// }
//
// public static void setField(Field field, Object targetObject, Object value) {
// Assert.notNull(field);
//
// makeAccessible(field);
// try {
// field.set(targetObject, value);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static Object getField(String field, Object object) {
// return getField(findField(object.getClass(), field), object);
// }
//
// public static Object getField(Field field, Object object) {
// Assert.notNull(field);
// makeAccessible(field);
//
// try {
// return field.get(object);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static Set<Class> getSubclasses(Class<?> parent, EntityManager entityManager) {
// return entityManager.getMetamodel().getEntities().stream()
// .filter(entityType -> parent != entityType.getJavaType() && parent.isAssignableFrom(entityType.getJavaType()))
// .map(Type::getJavaType)
// .collect(Collectors.toCollection(HashSet::new));
// }
//
// private static void makeAccessible(Field field) {
// if (field != null && !field.isAccessible()) {
// field.setAccessible(true);
// }
// }
//
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/TupleJoinerQuery.java
import com.querydsl.core.Tuple;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.QTuple;
import cz.encircled.joiner.util.ReflectionUtils;
package cz.encircled.joiner.query;
/**
* Implementation of joiner query with {@link Tuple} result
*
* @author Kisel on 13.9.2016.
*/
public class TupleJoinerQuery<T> extends JoinerQueryBase<T, Tuple> {
private final Expression<?>[] returnProjections;
public TupleJoinerQuery(EntityPath<T> from, Expression<?>... returnProjections) {
super(from);
this.returnProjections = returnProjections;
}
@Override
@SuppressWarnings("unchecked")
public Expression<Tuple> getReturnProjection() { | return ReflectionUtils.instantiate(QTuple.class, (Object) returnProjections); |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/query/join/DefaultJoinGraphRegistry.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
| import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.util.Assert;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; | package cz.encircled.joiner.query.join;
/**
* ConcurrentHashMap-based implementation of {@link JoinGraphRegistry}
*
* @author Vlad on 15-Aug-16.
*/
public class DefaultJoinGraphRegistry implements JoinGraphRegistry {
private final Map<Class, Map<Object, List<JoinDescription>>> registry = new ConcurrentHashMap<>();
@Override
public void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/DefaultJoinGraphRegistry.java
import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.util.Assert;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
package cz.encircled.joiner.query.join;
/**
* ConcurrentHashMap-based implementation of {@link JoinGraphRegistry}
*
* @author Vlad on 15-Aug-16.
*/
public class DefaultJoinGraphRegistry implements JoinGraphRegistry {
private final Map<Class, Map<Object, List<JoinDescription>>> registry = new ConcurrentHashMap<>();
@Override
public void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses) { | Assert.notNull(graphName); |
encircled/Joiner | joiner-core/src/main/java/cz/encircled/joiner/query/join/DefaultJoinGraphRegistry.java | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
| import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.util.Assert;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; | package cz.encircled.joiner.query.join;
/**
* ConcurrentHashMap-based implementation of {@link JoinGraphRegistry}
*
* @author Vlad on 15-Aug-16.
*/
public class DefaultJoinGraphRegistry implements JoinGraphRegistry {
private final Map<Class, Map<Object, List<JoinDescription>>> registry = new ConcurrentHashMap<>();
@Override
public void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses) {
Assert.notNull(graphName);
Assert.notNull(joins);
Assert.notNull(rootClasses);
Assert.assertThat(rootClasses.length > 0);
for (Class<?> clazz : rootClasses) {
registry.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>());
Map<Object, List<JoinDescription>> joinsOfClass = registry.get(clazz);
if (joinsOfClass.containsKey(graphName)) { | // Path: joiner-core/src/main/java/cz/encircled/joiner/exception/JoinerException.java
// public class JoinerException extends RuntimeException {
//
// public JoinerException(String message) {
// super(message);
// }
//
// public JoinerException(String message, Exception exception) {
// super(message, exception);
// }
// }
//
// Path: joiner-core/src/main/java/cz/encircled/joiner/util/Assert.java
// public class Assert {
//
// public static void notNull(Object object) {
// if (object == null) {
// throw new IllegalArgumentException("Argument must be not null!");
// }
// }
//
// public static void assertThat(boolean predicate) {
// if (!predicate) {
// throw new IllegalArgumentException("Predicate must be true!");
// }
// }
//
// }
// Path: joiner-core/src/main/java/cz/encircled/joiner/query/join/DefaultJoinGraphRegistry.java
import cz.encircled.joiner.exception.JoinerException;
import cz.encircled.joiner.util.Assert;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
package cz.encircled.joiner.query.join;
/**
* ConcurrentHashMap-based implementation of {@link JoinGraphRegistry}
*
* @author Vlad on 15-Aug-16.
*/
public class DefaultJoinGraphRegistry implements JoinGraphRegistry {
private final Map<Class, Map<Object, List<JoinDescription>>> registry = new ConcurrentHashMap<>();
@Override
public void registerJoinGraph(Object graphName, Collection<JoinDescription> joins, Class<?>... rootClasses) {
Assert.notNull(graphName);
Assert.notNull(joins);
Assert.notNull(rootClasses);
Assert.assertThat(rootClasses.length > 0);
for (Class<?> clazz : rootClasses) {
registry.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>());
Map<Object, List<JoinDescription>> joinsOfClass = registry.get(clazz);
if (joinsOfClass.containsKey(graphName)) { | throw new JoinerException(String.format("JoinGraph with name [%s] is already defined for the class [%s]", graphName, clazz.getName())); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/render/ContainerSecretChest.java | // Path: src/main/java/com/wynprice/secretroomsmod/blocks/SecretChest.java
// public class SecretChest extends BaseFakeBlock
// {
//
// public SecretChest(String name) {
// super(name, Material.WOOD);
// }
//
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntitySecretChest();
// }
//
// @Override
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// for(int i = 0; i < ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getSlots(); i++)
// InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getStackInSlot(i));
// }
//
// public static final HashMap<Boolean, HashMap<BlockPos, Integer>> PLAYERS_USING_MAP = new HashMap<>();
//
// static
// {
// PLAYERS_USING_MAP.put(true, new HashMap<>());
// PLAYERS_USING_MAP.put(false, new HashMap<>());
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
// EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
// {
// HashMap<BlockPos, Integer> playerMap = PLAYERS_USING_MAP.get(worldIn.isRemote);
// if(!playerMap.containsKey(pos))
// playerMap.put(pos, 0);
// playerMap.put(pos, playerMap.get(pos) + 1);
// if(!worldIn.isRemote)
// playerIn.openGui(SecretRooms5.instance, GuiHandler.SECRET_CHEST, worldIn, pos.getX(), pos.getY(), pos.getZ());
// worldIn.notifyNeighborsOfStateChange(pos, this, false);
// return true;
// }
//
// }
| import com.wynprice.secretroomsmod.blocks.SecretChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler; | @Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack previous = ItemStack.EMPTY;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if (fromSlot < handler.getSlots()) {
if (!this.mergeItemStack(current, handler.getSlots(), 63, true))
return ItemStack.EMPTY;
} else {
if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
return ItemStack.EMPTY;
}
if (current.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (current.getCount() == previous.getCount())
return null;
slot.onTake(playerIn, current);
}
return previous;
}
@Override
public void onContainerClosed(EntityPlayer playerIn)
{ | // Path: src/main/java/com/wynprice/secretroomsmod/blocks/SecretChest.java
// public class SecretChest extends BaseFakeBlock
// {
//
// public SecretChest(String name) {
// super(name, Material.WOOD);
// }
//
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntitySecretChest();
// }
//
// @Override
// public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// for(int i = 0; i < ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getSlots(); i++)
// InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getStackInSlot(i));
// }
//
// public static final HashMap<Boolean, HashMap<BlockPos, Integer>> PLAYERS_USING_MAP = new HashMap<>();
//
// static
// {
// PLAYERS_USING_MAP.put(true, new HashMap<>());
// PLAYERS_USING_MAP.put(false, new HashMap<>());
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
// EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
// {
// HashMap<BlockPos, Integer> playerMap = PLAYERS_USING_MAP.get(worldIn.isRemote);
// if(!playerMap.containsKey(pos))
// playerMap.put(pos, 0);
// playerMap.put(pos, playerMap.get(pos) + 1);
// if(!worldIn.isRemote)
// playerIn.openGui(SecretRooms5.instance, GuiHandler.SECRET_CHEST, worldIn, pos.getX(), pos.getY(), pos.getZ());
// worldIn.notifyNeighborsOfStateChange(pos, this, false);
// return true;
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/render/ContainerSecretChest.java
import com.wynprice.secretroomsmod.blocks.SecretChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack previous = ItemStack.EMPTY;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if (fromSlot < handler.getSlots()) {
if (!this.mergeItemStack(current, handler.getSlots(), 63, true))
return ItemStack.EMPTY;
} else {
if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
return ItemStack.EMPTY;
}
if (current.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (current.getCount() == previous.getCount())
return null;
slot.onTake(playerIn, current);
}
return previous;
}
@Override
public void onContainerClosed(EntityPlayer playerIn)
{ | SecretChest.PLAYERS_USING_MAP.get(playerIn.world.isRemote).put(pos, SecretChest.PLAYERS_USING_MAP.get(playerIn.world.isRemote).get(pos) - 1); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/handler/RecipeConfigHandler.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretConfig.java
// @Config(modid = SecretRooms5.MODID, category = "")
// @EventBusSubscriber(modid=SecretRooms5.MODID)
// public final class SecretConfig {
//
// public static final General GENERAL = new General();
// public static final EnergizedPaste ENERGIZED_PASTE = new EnergizedPaste();
// public static final SRMBlockFunctionality BLOCK_FUNCTIONALITY = new SRMBlockFunctionality();
//
// public static final class General {
// @Config.Name("update_checker")
// @Config.Comment("Check for mod updates on startup")
// public boolean updateChecker = true;
//
// @Config.Name("survival_mode_helmet")
// @Config.Comment("Allow the helmet to be used in survival mode")
// public boolean survivalModeHelmet = true;
// }
//
// public static final class EnergizedPaste {
// @Config.Name("enable_recipe")
// @Config.Comment("Whether to enable the recipe for energized paste")
// public boolean enableRecipe = true;
//
// @Config.Name("mirror_blacklist")
// @Config.Comment("Blacklist of blocks that should not be mirrored by energized paste")
// public String[] blacklistMirror = {};
//
// @Config.Name("replacement_blacklist")
// @Config.Comment("Blacklist of blocks that should not be replaced by energized paste")
// public String[] replacementBlacklist = {};
//
// @Config.Name("tile_entity_whitelist")
// @Config.Comment("Whitelist of blocks with tile entities that can be copied by energized paste\nTo apply to a whole mod, do 'modid:*'")
// public String[] tileEntityWhitelist = {};
//
// @Config.Comment("The Sound, Volume and Pitch to play when a block is set to the Energized Paste")
// @Config.Name("sound_set_name")
// public String soundSetName = "minecraft:block.sand.place";
//
// @Config.Name("sound_set_volume")
// public double soundSetVolume = 0.5D;
//
// @Config.Name("sound_set_pitch")
// public double soundSetPitch = 3.0D;
//
// @Config.Comment("The Sound, Volume and Pitch to play when Energized Paste is used on another block, changing the appereance of that block.")
// @Config.Name("sound_use_name")
// public String soundUseName = "minecraft:block.slime.break";
//
// @Config.Name("sound_use_volume")
// public double soundUseVolume = 0.2D;
//
// @Config.Name("sound_use_pitch")
// public double soundUsePitch = 3.0D;
// }
//
// public static final class SRMBlockFunctionality {
//
// @Config.Comment("Should SRM attempt to copy the light value of the block its mirroring")
// @Config.Name("copy_light")
// public boolean copyLight = true;
//
// @Config.Comment("Should SRM be limited to only full blocks (Like the Classic SecretRoomsMod)")
// @Config.Name("only_full_blocks")
// public boolean onlyFullBlocks = false;
//
//
// }
//
// @SubscribeEvent
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
// if(event.getConfigID() != null && event.getConfigID().equals(SecretRooms5.MODID)) {
// ConfigManager.sync(SecretRooms5.MODID, Config.Type.INSTANCE);
// }
// }
//
// }
| import java.util.function.BooleanSupplier;
import com.google.gson.JsonObject;
import com.wynprice.secretroomsmod.SecretConfig;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext; | package com.wynprice.secretroomsmod.handler;
public class RecipeConfigHandler implements IConditionFactory
{
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) { | // Path: src/main/java/com/wynprice/secretroomsmod/SecretConfig.java
// @Config(modid = SecretRooms5.MODID, category = "")
// @EventBusSubscriber(modid=SecretRooms5.MODID)
// public final class SecretConfig {
//
// public static final General GENERAL = new General();
// public static final EnergizedPaste ENERGIZED_PASTE = new EnergizedPaste();
// public static final SRMBlockFunctionality BLOCK_FUNCTIONALITY = new SRMBlockFunctionality();
//
// public static final class General {
// @Config.Name("update_checker")
// @Config.Comment("Check for mod updates on startup")
// public boolean updateChecker = true;
//
// @Config.Name("survival_mode_helmet")
// @Config.Comment("Allow the helmet to be used in survival mode")
// public boolean survivalModeHelmet = true;
// }
//
// public static final class EnergizedPaste {
// @Config.Name("enable_recipe")
// @Config.Comment("Whether to enable the recipe for energized paste")
// public boolean enableRecipe = true;
//
// @Config.Name("mirror_blacklist")
// @Config.Comment("Blacklist of blocks that should not be mirrored by energized paste")
// public String[] blacklistMirror = {};
//
// @Config.Name("replacement_blacklist")
// @Config.Comment("Blacklist of blocks that should not be replaced by energized paste")
// public String[] replacementBlacklist = {};
//
// @Config.Name("tile_entity_whitelist")
// @Config.Comment("Whitelist of blocks with tile entities that can be copied by energized paste\nTo apply to a whole mod, do 'modid:*'")
// public String[] tileEntityWhitelist = {};
//
// @Config.Comment("The Sound, Volume and Pitch to play when a block is set to the Energized Paste")
// @Config.Name("sound_set_name")
// public String soundSetName = "minecraft:block.sand.place";
//
// @Config.Name("sound_set_volume")
// public double soundSetVolume = 0.5D;
//
// @Config.Name("sound_set_pitch")
// public double soundSetPitch = 3.0D;
//
// @Config.Comment("The Sound, Volume and Pitch to play when Energized Paste is used on another block, changing the appereance of that block.")
// @Config.Name("sound_use_name")
// public String soundUseName = "minecraft:block.slime.break";
//
// @Config.Name("sound_use_volume")
// public double soundUseVolume = 0.2D;
//
// @Config.Name("sound_use_pitch")
// public double soundUsePitch = 3.0D;
// }
//
// public static final class SRMBlockFunctionality {
//
// @Config.Comment("Should SRM attempt to copy the light value of the block its mirroring")
// @Config.Name("copy_light")
// public boolean copyLight = true;
//
// @Config.Comment("Should SRM be limited to only full blocks (Like the Classic SecretRoomsMod)")
// @Config.Name("only_full_blocks")
// public boolean onlyFullBlocks = false;
//
//
// }
//
// @SubscribeEvent
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
// if(event.getConfigID() != null && event.getConfigID().equals(SecretRooms5.MODID)) {
// ConfigManager.sync(SecretRooms5.MODID, Config.Type.INSTANCE);
// }
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/handler/RecipeConfigHandler.java
import java.util.function.BooleanSupplier;
import com.google.gson.JsonObject;
import com.wynprice.secretroomsmod.SecretConfig;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext;
package com.wynprice.secretroomsmod.handler;
public class RecipeConfigHandler implements IConditionFactory
{
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) { | return () -> SecretConfig.GENERAL.survivalModeHelmet; |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/render/fakemodels/TrueSightModel.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/base/BaseTextureSwitchFakeModel.java
// public abstract class BaseTextureSwitchFakeModel extends BaseTextureFakeModel
// {
//
// public BaseTextureSwitchFakeModel(FakeBlockModel model) {
// super(model);
// }
//
// @Override
// public IBlockState getNormalStateWith(IBlockState s, IBlockState mirrorState) {
// // if(((ISecretBlock)currentRender.getBlock()).phaseModel(this) instanceof BaseTextureFakeModel &&
// // !(((ISecretBlock)currentRender.getBlock()).phaseModel(this) instanceof BaseTextureSwitchFakeModel))
// // return ((BaseTextureFakeModel)((ISecretBlock)currentRender.getBlock()).phaseModel(this)).getNormalStateWith(s, mirrorState);
//
// return mirrorState;
// }
//
// @Override
// protected Class<? extends ISecretBlock> getBaseBlockClass() {
// return null;
// }
//
// }
| import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.base.BaseTextureSwitchFakeModel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; | package com.wynprice.secretroomsmod.render.fakemodels;
/**
* The basic true sight model. All True Sight models extend this class.
* @author Wyn Price
*
*/
public class TrueSightModel extends BaseTextureSwitchFakeModel
{
public TrueSightModel(FakeBlockModel model) {
super(model);
}
@Override
protected RenderInfo getRenderInfo(EnumFacing face, IBlockState teMirrorState, IBlockState teMirrorStateExtended)
{ | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/base/BaseTextureSwitchFakeModel.java
// public abstract class BaseTextureSwitchFakeModel extends BaseTextureFakeModel
// {
//
// public BaseTextureSwitchFakeModel(FakeBlockModel model) {
// super(model);
// }
//
// @Override
// public IBlockState getNormalStateWith(IBlockState s, IBlockState mirrorState) {
// // if(((ISecretBlock)currentRender.getBlock()).phaseModel(this) instanceof BaseTextureFakeModel &&
// // !(((ISecretBlock)currentRender.getBlock()).phaseModel(this) instanceof BaseTextureSwitchFakeModel))
// // return ((BaseTextureFakeModel)((ISecretBlock)currentRender.getBlock()).phaseModel(this)).getNormalStateWith(s, mirrorState);
//
// return mirrorState;
// }
//
// @Override
// protected Class<? extends ISecretBlock> getBaseBlockClass() {
// return null;
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/render/fakemodels/TrueSightModel.java
import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.base.BaseTextureSwitchFakeModel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
package com.wynprice.secretroomsmod.render.fakemodels;
/**
* The basic true sight model. All True Sight models extend this class.
* @author Wyn Price
*
*/
public class TrueSightModel extends BaseTextureSwitchFakeModel
{
public TrueSightModel(FakeBlockModel model) {
super(model);
}
@Override
protected RenderInfo getRenderInfo(EnumFacing face, IBlockState teMirrorState, IBlockState teMirrorStateExtended)
{ | return new RenderInfo(currentRender, getModel(new ResourceLocation(SecretRooms5.MODID, "block/" + currentRender.getBlock().getRegistryName().getResourcePath()))); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/tileentity/TileEntitySecretPressurePlate.java | // Path: src/main/java/com/wynprice/secretroomsmod/base/BaseFakePressurePlate.java
// public abstract class BaseFakePressurePlate extends BaseFakeBlock
// {
// public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
//
// public BaseFakePressurePlate(String name, Material materialIn) {
// super(name, materialIn);
// this.setDefaultState(this.blockState.getBaseState().withProperty(POWER, Integer.valueOf(0)));
// }
//
// @Override
// public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
// {
// calculateState(worldIn, pos);
// }
//
// @Override
// public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, SpawnPlacementType type) {
// return false;
// }
//
// @Override
// public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
// return getState(world, pos).getBlock().canBeConnectedTo(world, pos, facing);
// }
//
// public void calculateState(World worldIn, BlockPos pos)
// {
// List<Entity> entityList = worldIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1f, pos.getY() + 1.1f, pos.getZ() + 1f));
// int level = MathHelper.clamp(getLevel(worldIn, pos, entityList), 0, 15);
// if((level == 0 || worldIn.getBlockState(pos).getValue(POWER) == 0) && level != worldIn.getBlockState(pos).getValue(POWER))
// worldIn.playSound((EntityPlayer)null, pos, level == 0 ? soundOff() : soundOn(), SoundCategory.BLOCKS, 0.3F, level == 0 ? 0.75F : 0.90000004F);
//
// if(worldIn.getBlockState(pos).getValue(POWER) != entityList.size())
// {
// worldIn.setBlockState(pos, setRedstoneStrength(worldIn.getBlockState(pos), level), 3);
// worldIn.notifyNeighborsOfStateChange(pos, this, false);
// worldIn.notifyNeighborsOfStateChange(pos.down(), this, false);
// }
// if(worldIn.getBlockState(pos).getValue(POWER) > 0)
// worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
// }
//
// public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
// {
// }
//
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntitySecretPressurePlate();
// }
//
// public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
// {
// if (!worldIn.isRemote && state.getValue(POWER) > 0)
// onEntityWalk(worldIn, pos, null);
// }
//
// protected abstract int getLevel(World world, BlockPos pos, List<Entity> entityList);
//
// protected abstract SoundEvent soundOn();
//
// protected abstract SoundEvent soundOff();
//
// @Override
// public boolean canProvidePower(IBlockState state) {
// return true;
// }
//
// @Override
// public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// return blockState.getValue(POWER);
// }
//
// @Override
// public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// return side == EnumFacing.DOWN ? blockState.getValue(POWER) : 0;
// }
//
// protected IBlockState setRedstoneStrength(IBlockState state, int strength)
// {
// return state.withProperty(POWER, Integer.valueOf(strength));
// }
//
// /**
// * How many world ticks before ticking
// */
// public int tickRate(World worldIn)
// {
// return 20;
// }
//
// /**
// * Convert the given metadata into a BlockState for this Block
// */
// public IBlockState getStateFromMeta(int meta)
// {
// return this.getDefaultState().withProperty(POWER, Integer.valueOf(meta));
// }
//
// /**
// * Convert the BlockState into the correct metadata value
// */
// public int getMetaFromState(IBlockState state)
// {
// return ((Integer)state.getValue(POWER)).intValue();
// }
//
// protected BlockStateContainer createBlockState()
// {
// return new ExtendedBlockState(this, new IProperty[] {POWER}, new IUnlistedProperty[] {RENDER_PROPERTY});
// }
//
// }
| import com.wynprice.secretroomsmod.base.BaseFakePressurePlate; | package com.wynprice.secretroomsmod.tileentity;
/**
* The SRM Secret Pressure Plate tile entity
* @author Wyn Price
*
*/
public class TileEntitySecretPressurePlate extends TileEntityInfomationHolder
{
@Override
public void update()
{ | // Path: src/main/java/com/wynprice/secretroomsmod/base/BaseFakePressurePlate.java
// public abstract class BaseFakePressurePlate extends BaseFakeBlock
// {
// public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
//
// public BaseFakePressurePlate(String name, Material materialIn) {
// super(name, materialIn);
// this.setDefaultState(this.blockState.getBaseState().withProperty(POWER, Integer.valueOf(0)));
// }
//
// @Override
// public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
// {
// calculateState(worldIn, pos);
// }
//
// @Override
// public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, SpawnPlacementType type) {
// return false;
// }
//
// @Override
// public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
// return getState(world, pos).getBlock().canBeConnectedTo(world, pos, facing);
// }
//
// public void calculateState(World worldIn, BlockPos pos)
// {
// List<Entity> entityList = worldIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1f, pos.getY() + 1.1f, pos.getZ() + 1f));
// int level = MathHelper.clamp(getLevel(worldIn, pos, entityList), 0, 15);
// if((level == 0 || worldIn.getBlockState(pos).getValue(POWER) == 0) && level != worldIn.getBlockState(pos).getValue(POWER))
// worldIn.playSound((EntityPlayer)null, pos, level == 0 ? soundOff() : soundOn(), SoundCategory.BLOCKS, 0.3F, level == 0 ? 0.75F : 0.90000004F);
//
// if(worldIn.getBlockState(pos).getValue(POWER) != entityList.size())
// {
// worldIn.setBlockState(pos, setRedstoneStrength(worldIn.getBlockState(pos), level), 3);
// worldIn.notifyNeighborsOfStateChange(pos, this, false);
// worldIn.notifyNeighborsOfStateChange(pos.down(), this, false);
// }
// if(worldIn.getBlockState(pos).getValue(POWER) > 0)
// worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
// }
//
// public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
// {
// }
//
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntitySecretPressurePlate();
// }
//
// public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
// {
// if (!worldIn.isRemote && state.getValue(POWER) > 0)
// onEntityWalk(worldIn, pos, null);
// }
//
// protected abstract int getLevel(World world, BlockPos pos, List<Entity> entityList);
//
// protected abstract SoundEvent soundOn();
//
// protected abstract SoundEvent soundOff();
//
// @Override
// public boolean canProvidePower(IBlockState state) {
// return true;
// }
//
// @Override
// public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// return blockState.getValue(POWER);
// }
//
// @Override
// public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// return side == EnumFacing.DOWN ? blockState.getValue(POWER) : 0;
// }
//
// protected IBlockState setRedstoneStrength(IBlockState state, int strength)
// {
// return state.withProperty(POWER, Integer.valueOf(strength));
// }
//
// /**
// * How many world ticks before ticking
// */
// public int tickRate(World worldIn)
// {
// return 20;
// }
//
// /**
// * Convert the given metadata into a BlockState for this Block
// */
// public IBlockState getStateFromMeta(int meta)
// {
// return this.getDefaultState().withProperty(POWER, Integer.valueOf(meta));
// }
//
// /**
// * Convert the BlockState into the correct metadata value
// */
// public int getMetaFromState(IBlockState state)
// {
// return ((Integer)state.getValue(POWER)).intValue();
// }
//
// protected BlockStateContainer createBlockState()
// {
// return new ExtendedBlockState(this, new IProperty[] {POWER}, new IUnlistedProperty[] {RENDER_PROPERTY});
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/tileentity/TileEntitySecretPressurePlate.java
import com.wynprice.secretroomsmod.base.BaseFakePressurePlate;
package com.wynprice.secretroomsmod.tileentity;
/**
* The SRM Secret Pressure Plate tile entity
* @author Wyn Price
*
*/
public class TileEntitySecretPressurePlate extends TileEntityInfomationHolder
{
@Override
public void update()
{ | ((BaseFakePressurePlate)world.getBlockState(pos).getBlock()).calculateState(world, pos); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/base/interfaces/ISecretTileEntity.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import com.wynprice.secretroomsmod.SecretRooms5;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler; | *
* Used to get the mirrored state when there is no instance
* @param world The current world
* @param pos The current position
* @return the Mirrored State, or {@link Blocks#STONE} if there is none.
*/
public static IBlockState getMirrorState(World world, BlockPos pos)
{
IBlockState blockstate = getMap(world).get(pos) == null && world.getTileEntity(pos) instanceof ISecretTileEntity ? ((ISecretTileEntity)world.getTileEntity(pos)).getMirrorStateSafely() : getMap(world).get(pos);
return blockstate == null ? Blocks.STONE.getDefaultState() : blockstate;
}
/**
* Used to get the mirrored state when there is no instance, and all you have is the IBlockAccess
* @param access The current world
* @param pos The current position
* @return the current world, or {@link Blocks#STONE} if there is none
*/
public static IBlockState getMirrorState(IBlockAccess access, BlockPos pos)
{
IBlockState returnState = Blocks.AIR.getDefaultState();
if(access.getTileEntity(pos) instanceof ISecretTileEntity && ((ISecretTileEntity)access.getTileEntity(pos)).getMirrorStateSafely() != null) {
return ((ISecretTileEntity)access.getTileEntity(pos)).getMirrorStateSafely();
} else if(access instanceof World) {
returnState = getMirrorState((World)access, pos);
} else if(access.getTileEntity(pos) != null && access.getTileEntity(pos).getWorld() != null) {
returnState = getMirrorState(access.getTileEntity(pos).getWorld(), pos);
} else { //Last resort
for(int dim : RENDER_MAP.keySet()) {
if(FMLCommonHandler.instance().getMinecraftServerInstance() == null) { | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
// Path: src/main/java/com/wynprice/secretroomsmod/base/interfaces/ISecretTileEntity.java
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import com.wynprice.secretroomsmod.SecretRooms5;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
*
* Used to get the mirrored state when there is no instance
* @param world The current world
* @param pos The current position
* @return the Mirrored State, or {@link Blocks#STONE} if there is none.
*/
public static IBlockState getMirrorState(World world, BlockPos pos)
{
IBlockState blockstate = getMap(world).get(pos) == null && world.getTileEntity(pos) instanceof ISecretTileEntity ? ((ISecretTileEntity)world.getTileEntity(pos)).getMirrorStateSafely() : getMap(world).get(pos);
return blockstate == null ? Blocks.STONE.getDefaultState() : blockstate;
}
/**
* Used to get the mirrored state when there is no instance, and all you have is the IBlockAccess
* @param access The current world
* @param pos The current position
* @return the current world, or {@link Blocks#STONE} if there is none
*/
public static IBlockState getMirrorState(IBlockAccess access, BlockPos pos)
{
IBlockState returnState = Blocks.AIR.getDefaultState();
if(access.getTileEntity(pos) instanceof ISecretTileEntity && ((ISecretTileEntity)access.getTileEntity(pos)).getMirrorStateSafely() != null) {
return ((ISecretTileEntity)access.getTileEntity(pos)).getMirrorStateSafely();
} else if(access instanceof World) {
returnState = getMirrorState((World)access, pos);
} else if(access.getTileEntity(pos) != null && access.getTileEntity(pos).getWorld() != null) {
returnState = getMirrorState(access.getTileEntity(pos).getWorld(), pos);
} else { //Last resort
for(int dim : RENDER_MAP.keySet()) {
if(FMLCommonHandler.instance().getMinecraftServerInstance() == null) { | returnState = getMirrorState(SecretRooms5.proxy.getPlayer().world, pos); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/base/BaseMessagePacket.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
| import com.wynprice.secretroomsmod.SecretRooms5;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side; | package com.wynprice.secretroomsmod.base;
/**
* The base packet for SRM
* @author Wyn Price
*
* @param <REQ> use the class this is. Used to get the right instance of the packet, so you don't have to do casting
*/
public abstract class BaseMessagePacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>
{
@Override
public REQ onMessage(REQ message, MessageContext ctx) { | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
// Path: src/main/java/com/wynprice/secretroomsmod/base/BaseMessagePacket.java
import com.wynprice.secretroomsmod.SecretRooms5;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
package com.wynprice.secretroomsmod.base;
/**
* The base packet for SRM
* @author Wyn Price
*
* @param <REQ> use the class this is. Used to get the right instance of the packet, so you don't have to do casting
*/
public abstract class BaseMessagePacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>
{
@Override
public REQ onMessage(REQ message, MessageContext ctx) { | onReceived(message, ctx.side == Side.SERVER ? ctx.getServerHandler().player : SecretRooms5.proxy.getPlayer()); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/integration/jei/energizedpaste/EnergizedPasteCategory.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/SecretRoomsJEI.java
// @JEIPlugin
// public class SecretRoomsJEI implements IModPlugin
// {
// public static final String ENERGIZED_PASTE_UUID = "secretroomsmod:energizedpaste";
//
// @Override
// public void register(IModRegistry registry) {
// registry.handleRecipes(EnergizedPasteRecipe.class, new EnergizedPasteJEIHandler(), ENERGIZED_PASTE_UUID);
// registry.addRecipeCatalyst(new ItemStack(Items.FLINT_AND_STEEL), ENERGIZED_PASTE_UUID);
// registry.addRecipes(Lists.newArrayList(new EnergizedPasteRecipe(new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE, 1, 1), Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(Blocks.FIRE.getDefaultState()))), ENERGIZED_PASTE_UUID);
//
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(
// new EnergizedPasteCategory(registry)
// );
// }
//
// }
| import java.awt.Point;
import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.integration.jei.SecretRoomsJEI;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; | package com.wynprice.secretroomsmod.integration.jei.energizedpaste;
public class EnergizedPasteCategory implements IRecipeCategory
{
protected final IDrawable background;
protected final IDrawable overlay;
public EnergizedPasteCategory(IRecipeCategoryRegistration reg)
{
background = reg.getJeiHelpers().getGuiHelper().createBlankDrawable(150, 110); | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/SecretRoomsJEI.java
// @JEIPlugin
// public class SecretRoomsJEI implements IModPlugin
// {
// public static final String ENERGIZED_PASTE_UUID = "secretroomsmod:energizedpaste";
//
// @Override
// public void register(IModRegistry registry) {
// registry.handleRecipes(EnergizedPasteRecipe.class, new EnergizedPasteJEIHandler(), ENERGIZED_PASTE_UUID);
// registry.addRecipeCatalyst(new ItemStack(Items.FLINT_AND_STEEL), ENERGIZED_PASTE_UUID);
// registry.addRecipes(Lists.newArrayList(new EnergizedPasteRecipe(new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE, 1, 1), Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(Blocks.FIRE.getDefaultState()))), ENERGIZED_PASTE_UUID);
//
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(
// new EnergizedPasteCategory(registry)
// );
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/energizedpaste/EnergizedPasteCategory.java
import java.awt.Point;
import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.integration.jei.SecretRoomsJEI;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
package com.wynprice.secretroomsmod.integration.jei.energizedpaste;
public class EnergizedPasteCategory implements IRecipeCategory
{
protected final IDrawable background;
protected final IDrawable overlay;
public EnergizedPasteCategory(IRecipeCategoryRegistration reg)
{
background = reg.getJeiHelpers().getGuiHelper().createBlankDrawable(150, 110); | overlay = reg.getJeiHelpers().getGuiHelper().createDrawable(new ResourceLocation(SecretRooms5.MODID, "textures/gui/jei/energized_paste_cover.png"), 0, 0, 150, 110, 150, 110); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/integration/jei/energizedpaste/EnergizedPasteCategory.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/SecretRoomsJEI.java
// @JEIPlugin
// public class SecretRoomsJEI implements IModPlugin
// {
// public static final String ENERGIZED_PASTE_UUID = "secretroomsmod:energizedpaste";
//
// @Override
// public void register(IModRegistry registry) {
// registry.handleRecipes(EnergizedPasteRecipe.class, new EnergizedPasteJEIHandler(), ENERGIZED_PASTE_UUID);
// registry.addRecipeCatalyst(new ItemStack(Items.FLINT_AND_STEEL), ENERGIZED_PASTE_UUID);
// registry.addRecipes(Lists.newArrayList(new EnergizedPasteRecipe(new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE, 1, 1), Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(Blocks.FIRE.getDefaultState()))), ENERGIZED_PASTE_UUID);
//
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(
// new EnergizedPasteCategory(registry)
// );
// }
//
// }
| import java.awt.Point;
import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.integration.jei.SecretRoomsJEI;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; | package com.wynprice.secretroomsmod.integration.jei.energizedpaste;
public class EnergizedPasteCategory implements IRecipeCategory
{
protected final IDrawable background;
protected final IDrawable overlay;
public EnergizedPasteCategory(IRecipeCategoryRegistration reg)
{
background = reg.getJeiHelpers().getGuiHelper().createBlankDrawable(150, 110);
overlay = reg.getJeiHelpers().getGuiHelper().createDrawable(new ResourceLocation(SecretRooms5.MODID, "textures/gui/jei/energized_paste_cover.png"), 0, 0, 150, 110, 150, 110);
}
@Override
public String getUid() { | // Path: src/main/java/com/wynprice/secretroomsmod/SecretRooms5.java
// @Mod(modid = SecretRooms5.MODID, name = SecretRooms5.MODNAME, version = SecretRooms5.VERSION, acceptedMinecraftVersions = SecretRooms5.MCVERSION, dependencies = SecretRooms5.DEPENDENCIES,updateJSON = SecretRooms5.UPDATE_URL)
// public class SecretRooms5
// {
// public static final String MODID = "secretroomsmod";
// public static final String MODNAME = "Secret Rooms 5";
// public static final String VERSION = "5.6.4";
// public static final String MCVERSION = "[1.12.2,1.13]";
// public static final String DEPENDENCIES = "required-after:srm-hooks;required-after:forge@[14.23.0.2502,);";
// public static final String UPDATE_URL = "http://www.wynprice.com/update_jsons/secretroomsmod.json";
//
// @SidedProxy(modId = MODID, clientSide = "com.wynprice.secretroomsmod.proxy.ClientProxy", serverSide = "com.wynprice.secretroomsmod.proxy.ServerProxy")
// public static CommonProxy proxy;
//
// @Instance(MODID)
// public static SecretRooms5 instance;
// public static final CreativeTabs TAB = new CreativeTabs(MODID) {
//
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(SecretItems.CAMOUFLAGE_PASTE);
// }
// };
//
// public static final Logger LOGGER = LogManager.getLogger(MODID);
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit(event);
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void onServerLoaded(FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandBase() {@Override public int getRequiredPermissionLevel(){return 2;}@Override public String getUsage(ICommandSender sender) {return "Resets the energized blocks";}@Override public String getName() {return "resetenergized";}@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {EnergizedPasteHandler.getEnergized_map().clear();SecretNetwork.sendToAll(new MessagePacketSyncEnergizedPaste(EnergizedPasteHandler.saveToNBT(), null));}});
// }
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/SecretRoomsJEI.java
// @JEIPlugin
// public class SecretRoomsJEI implements IModPlugin
// {
// public static final String ENERGIZED_PASTE_UUID = "secretroomsmod:energizedpaste";
//
// @Override
// public void register(IModRegistry registry) {
// registry.handleRecipes(EnergizedPasteRecipe.class, new EnergizedPasteJEIHandler(), ENERGIZED_PASTE_UUID);
// registry.addRecipeCatalyst(new ItemStack(Items.FLINT_AND_STEEL), ENERGIZED_PASTE_UUID);
// registry.addRecipes(Lists.newArrayList(new EnergizedPasteRecipe(new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE), new ItemStack(SecretItems.CAMOUFLAGE_PASTE, 1, 1), Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(Blocks.FIRE.getDefaultState()))), ENERGIZED_PASTE_UUID);
//
// }
//
// @Override
// public void registerCategories(IRecipeCategoryRegistration registry) {
// registry.addRecipeCategories(
// new EnergizedPasteCategory(registry)
// );
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/integration/jei/energizedpaste/EnergizedPasteCategory.java
import java.awt.Point;
import com.wynprice.secretroomsmod.SecretRooms5;
import com.wynprice.secretroomsmod.integration.jei.SecretRoomsJEI;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
package com.wynprice.secretroomsmod.integration.jei.energizedpaste;
public class EnergizedPasteCategory implements IRecipeCategory
{
protected final IDrawable background;
protected final IDrawable overlay;
public EnergizedPasteCategory(IRecipeCategoryRegistration reg)
{
background = reg.getJeiHelpers().getGuiHelper().createBlankDrawable(150, 110);
overlay = reg.getJeiHelpers().getGuiHelper().createDrawable(new ResourceLocation(SecretRooms5.MODID, "textures/gui/jei/energized_paste_cover.png"), 0, 0, 150, 110, 150, 110);
}
@Override
public String getUid() { | return SecretRoomsJEI.ENERGIZED_PASTE_UUID; |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/base/BaseFakePressurePlate.java | // Path: src/main/java/com/wynprice/secretroomsmod/tileentity/TileEntitySecretPressurePlate.java
// public class TileEntitySecretPressurePlate extends TileEntityInfomationHolder
// {
// @Override
// public void update()
// {
// ((BaseFakePressurePlate)world.getBlockState(pos).getBlock()).calculateState(world, pos);
// super.update();
// }
// }
| import java.util.List;
import java.util.Random;
import com.wynprice.secretroomsmod.tileentity.TileEntitySecretPressurePlate;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving.SpawnPlacementType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; | }
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
return getState(world, pos).getBlock().canBeConnectedTo(world, pos, facing);
}
public void calculateState(World worldIn, BlockPos pos)
{
List<Entity> entityList = worldIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1f, pos.getY() + 1.1f, pos.getZ() + 1f));
int level = MathHelper.clamp(getLevel(worldIn, pos, entityList), 0, 15);
if((level == 0 || worldIn.getBlockState(pos).getValue(POWER) == 0) && level != worldIn.getBlockState(pos).getValue(POWER))
worldIn.playSound((EntityPlayer)null, pos, level == 0 ? soundOff() : soundOn(), SoundCategory.BLOCKS, 0.3F, level == 0 ? 0.75F : 0.90000004F);
if(worldIn.getBlockState(pos).getValue(POWER) != entityList.size())
{
worldIn.setBlockState(pos, setRedstoneStrength(worldIn.getBlockState(pos), level), 3);
worldIn.notifyNeighborsOfStateChange(pos, this, false);
worldIn.notifyNeighborsOfStateChange(pos.down(), this, false);
}
if(worldIn.getBlockState(pos).getValue(POWER) > 0)
worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
}
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) { | // Path: src/main/java/com/wynprice/secretroomsmod/tileentity/TileEntitySecretPressurePlate.java
// public class TileEntitySecretPressurePlate extends TileEntityInfomationHolder
// {
// @Override
// public void update()
// {
// ((BaseFakePressurePlate)world.getBlockState(pos).getBlock()).calculateState(world, pos);
// super.update();
// }
// }
// Path: src/main/java/com/wynprice/secretroomsmod/base/BaseFakePressurePlate.java
import java.util.List;
import java.util.Random;
import com.wynprice.secretroomsmod.tileentity.TileEntitySecretPressurePlate;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving.SpawnPlacementType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
}
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
return getState(world, pos).getBlock().canBeConnectedTo(world, pos, facing);
}
public void calculateState(World worldIn, BlockPos pos)
{
List<Entity> entityList = worldIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1f, pos.getY() + 1.1f, pos.getZ() + 1f));
int level = MathHelper.clamp(getLevel(worldIn, pos, entityList), 0, 15);
if((level == 0 || worldIn.getBlockState(pos).getValue(POWER) == 0) && level != worldIn.getBlockState(pos).getValue(POWER))
worldIn.playSound((EntityPlayer)null, pos, level == 0 ? soundOff() : soundOn(), SoundCategory.BLOCKS, 0.3F, level == 0 ? 0.75F : 0.90000004F);
if(worldIn.getBlockState(pos).getValue(POWER) != entityList.size())
{
worldIn.setBlockState(pos, setRedstoneStrength(worldIn.getBlockState(pos), level), 3);
worldIn.notifyNeighborsOfStateChange(pos, this, false);
worldIn.notifyNeighborsOfStateChange(pos.down(), this, false);
}
if(worldIn.getBlockState(pos).getValue(POWER) > 0)
worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
}
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) { | return new TileEntitySecretPressurePlate(); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/network/packets/MessagePacketUpdateProbe.java | // Path: src/main/java/com/wynprice/secretroomsmod/base/BaseMessagePacket.java
// public abstract class BaseMessagePacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>
// {
// @Override
// public REQ onMessage(REQ message, MessageContext ctx) {
// onReceived(message, ctx.side == Side.SERVER ? ctx.getServerHandler().player : SecretRooms5.proxy.getPlayer());
// return null;
// }
//
// /**
// * Convert the packet data to a {@link ByteBuf}
// */
// @Override
// public void toBytes(ByteBuf buf) {};
//
// /**
// * Get the packet data from the {@link ByteBuf}
// */
// @Override
// public void fromBytes(ByteBuf buf) {};
//
// /**
// * Called when the message is received
// * @param message the message
// * @param player the player sending the message
// */
// public abstract void onReceived(REQ message, EntityPlayer player);
//
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/items/ProgrammableSwitchProbe.java
// public class ProgrammableSwitchProbe extends Item
// {
// public ProgrammableSwitchProbe() {
// setRegistryName("programmable_switch_probe");
// setUnlocalizedName("programmable_switch_probe");
// this.setMaxStackSize(1);
// }
//
// @Override
// public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
// {
// if(worldIn.isRemote)
// SecretRooms5.proxy.displayGui(0, playerIn.getHeldItem(handIn));
// return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
// }
//
// @Override
// public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
// EnumFacing facing, float hitX, float hitY, float hitZ)
// {
// IBlockState state = worldIn.getBlockState(pos);
// if(state.getBlock() == Blocks.AIR)
// return EnumActionResult.PASS;
// ItemStackHandler handler = new ItemStackHandler(1);
// handler.setStackInSlot(0, state.getBlock().getPickBlock(state, worldIn.rayTraceBlocks(player.getPositionVector(), new Vec3d(pos)), worldIn, pos, player));
// if(state.getBlock() instanceof ISecretBlock && player.getHeldItem(hand).hasTagCompound() && player.getHeldItem(hand).getTagCompound().hasKey("hit_block", 8))
// {
// Block block = Block.REGISTRY.getObject(new ResourceLocation(player.getHeldItem(hand).getTagCompound().getString("hit_block")));
// if(!(block instanceof ISecretBlock) && block != Blocks.AIR)
// {
// ((ISecretBlock)state.getBlock()).forceBlockState(worldIn, pos, block.getStateFromMeta(player.getHeldItem(hand).getTagCompound().getInteger("hit_meta")));
// worldIn.markBlockRangeForRenderUpdate(pos.add(-1, -1, -1), pos.add(1, 1, 1));
// return EnumActionResult.SUCCESS;
// }
// }
// return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
// }
// }
| import com.wynprice.secretroomsmod.base.BaseMessagePacket;
import com.wynprice.secretroomsmod.items.ProgrammableSwitchProbe;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.network.ByteBufUtils; | package com.wynprice.secretroomsmod.network.packets;
/**
* Packet used to update the programmable switch probe. Received ServerSide
* @author Wyn Price
*
*/
public class MessagePacketUpdateProbe extends BaseMessagePacket<MessagePacketUpdateProbe>
{
public MessagePacketUpdateProbe() {
}
private NBTTagCompound compound;
public MessagePacketUpdateProbe(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public void toBytes(ByteBuf buf)
{
ByteBufUtils.writeTag(buf, compound);
}
@Override
public void fromBytes(ByteBuf buf) {
compound = ByteBufUtils.readTag(buf);
}
@Override
public void onReceived(MessagePacketUpdateProbe message, EntityPlayer player)
{ | // Path: src/main/java/com/wynprice/secretroomsmod/base/BaseMessagePacket.java
// public abstract class BaseMessagePacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>
// {
// @Override
// public REQ onMessage(REQ message, MessageContext ctx) {
// onReceived(message, ctx.side == Side.SERVER ? ctx.getServerHandler().player : SecretRooms5.proxy.getPlayer());
// return null;
// }
//
// /**
// * Convert the packet data to a {@link ByteBuf}
// */
// @Override
// public void toBytes(ByteBuf buf) {};
//
// /**
// * Get the packet data from the {@link ByteBuf}
// */
// @Override
// public void fromBytes(ByteBuf buf) {};
//
// /**
// * Called when the message is received
// * @param message the message
// * @param player the player sending the message
// */
// public abstract void onReceived(REQ message, EntityPlayer player);
//
// }
//
// Path: src/main/java/com/wynprice/secretroomsmod/items/ProgrammableSwitchProbe.java
// public class ProgrammableSwitchProbe extends Item
// {
// public ProgrammableSwitchProbe() {
// setRegistryName("programmable_switch_probe");
// setUnlocalizedName("programmable_switch_probe");
// this.setMaxStackSize(1);
// }
//
// @Override
// public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
// {
// if(worldIn.isRemote)
// SecretRooms5.proxy.displayGui(0, playerIn.getHeldItem(handIn));
// return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
// }
//
// @Override
// public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
// EnumFacing facing, float hitX, float hitY, float hitZ)
// {
// IBlockState state = worldIn.getBlockState(pos);
// if(state.getBlock() == Blocks.AIR)
// return EnumActionResult.PASS;
// ItemStackHandler handler = new ItemStackHandler(1);
// handler.setStackInSlot(0, state.getBlock().getPickBlock(state, worldIn.rayTraceBlocks(player.getPositionVector(), new Vec3d(pos)), worldIn, pos, player));
// if(state.getBlock() instanceof ISecretBlock && player.getHeldItem(hand).hasTagCompound() && player.getHeldItem(hand).getTagCompound().hasKey("hit_block", 8))
// {
// Block block = Block.REGISTRY.getObject(new ResourceLocation(player.getHeldItem(hand).getTagCompound().getString("hit_block")));
// if(!(block instanceof ISecretBlock) && block != Blocks.AIR)
// {
// ((ISecretBlock)state.getBlock()).forceBlockState(worldIn, pos, block.getStateFromMeta(player.getHeldItem(hand).getTagCompound().getInteger("hit_meta")));
// worldIn.markBlockRangeForRenderUpdate(pos.add(-1, -1, -1), pos.add(1, 1, 1));
// return EnumActionResult.SUCCESS;
// }
// }
// return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
// }
// }
// Path: src/main/java/com/wynprice/secretroomsmod/network/packets/MessagePacketUpdateProbe.java
import com.wynprice.secretroomsmod.base.BaseMessagePacket;
import com.wynprice.secretroomsmod.items.ProgrammableSwitchProbe;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.network.ByteBufUtils;
package com.wynprice.secretroomsmod.network.packets;
/**
* Packet used to update the programmable switch probe. Received ServerSide
* @author Wyn Price
*
*/
public class MessagePacketUpdateProbe extends BaseMessagePacket<MessagePacketUpdateProbe>
{
public MessagePacketUpdateProbe() {
}
private NBTTagCompound compound;
public MessagePacketUpdateProbe(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public void toBytes(ByteBuf buf)
{
ByteBufUtils.writeTag(buf, compound);
}
@Override
public void fromBytes(ByteBuf buf) {
compound = ByteBufUtils.readTag(buf);
}
@Override
public void onReceived(MessagePacketUpdateProbe message, EntityPlayer player)
{ | ItemStack stack = player.getHeldItemMainhand().getItem() instanceof ProgrammableSwitchProbe ? player.getHeldItemMainhand() : (player.getHeldItemOffhand().getItem() instanceof ProgrammableSwitchProbe ? player.getHeldItemOffhand() : null); |
AbrarSyed/SecretRoomsMod-forge | src/main/java/com/wynprice/secretroomsmod/items/TrueSightHelmet.java | // Path: src/main/java/com/wynprice/secretroomsmod/SecretConfig.java
// @Config(modid = SecretRooms5.MODID, category = "")
// @EventBusSubscriber(modid=SecretRooms5.MODID)
// public final class SecretConfig {
//
// public static final General GENERAL = new General();
// public static final EnergizedPaste ENERGIZED_PASTE = new EnergizedPaste();
// public static final SRMBlockFunctionality BLOCK_FUNCTIONALITY = new SRMBlockFunctionality();
//
// public static final class General {
// @Config.Name("update_checker")
// @Config.Comment("Check for mod updates on startup")
// public boolean updateChecker = true;
//
// @Config.Name("survival_mode_helmet")
// @Config.Comment("Allow the helmet to be used in survival mode")
// public boolean survivalModeHelmet = true;
// }
//
// public static final class EnergizedPaste {
// @Config.Name("enable_recipe")
// @Config.Comment("Whether to enable the recipe for energized paste")
// public boolean enableRecipe = true;
//
// @Config.Name("mirror_blacklist")
// @Config.Comment("Blacklist of blocks that should not be mirrored by energized paste")
// public String[] blacklistMirror = {};
//
// @Config.Name("replacement_blacklist")
// @Config.Comment("Blacklist of blocks that should not be replaced by energized paste")
// public String[] replacementBlacklist = {};
//
// @Config.Name("tile_entity_whitelist")
// @Config.Comment("Whitelist of blocks with tile entities that can be copied by energized paste\nTo apply to a whole mod, do 'modid:*'")
// public String[] tileEntityWhitelist = {};
//
// @Config.Comment("The Sound, Volume and Pitch to play when a block is set to the Energized Paste")
// @Config.Name("sound_set_name")
// public String soundSetName = "minecraft:block.sand.place";
//
// @Config.Name("sound_set_volume")
// public double soundSetVolume = 0.5D;
//
// @Config.Name("sound_set_pitch")
// public double soundSetPitch = 3.0D;
//
// @Config.Comment("The Sound, Volume and Pitch to play when Energized Paste is used on another block, changing the appereance of that block.")
// @Config.Name("sound_use_name")
// public String soundUseName = "minecraft:block.slime.break";
//
// @Config.Name("sound_use_volume")
// public double soundUseVolume = 0.2D;
//
// @Config.Name("sound_use_pitch")
// public double soundUsePitch = 3.0D;
// }
//
// public static final class SRMBlockFunctionality {
//
// @Config.Comment("Should SRM attempt to copy the light value of the block its mirroring")
// @Config.Name("copy_light")
// public boolean copyLight = true;
//
// @Config.Comment("Should SRM be limited to only full blocks (Like the Classic SecretRoomsMod)")
// @Config.Name("only_full_blocks")
// public boolean onlyFullBlocks = false;
//
//
// }
//
// @SubscribeEvent
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
// if(event.getConfigID() != null && event.getConfigID().equals(SecretRooms5.MODID)) {
// ConfigManager.sync(SecretRooms5.MODID, Config.Type.INSTANCE);
// }
// }
//
// }
| import com.wynprice.secretroomsmod.SecretConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; | package com.wynprice.secretroomsmod.items;
public class TrueSightHelmet extends ItemArmor
{
public TrueSightHelmet(String name, ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {
super(materialIn, renderIndexIn, equipmentSlotIn);
setUnlocalizedName(name);
setRegistryName(name);
this.setMaxStackSize(1);
}
public static boolean isHelmet(EntityPlayer player) { | // Path: src/main/java/com/wynprice/secretroomsmod/SecretConfig.java
// @Config(modid = SecretRooms5.MODID, category = "")
// @EventBusSubscriber(modid=SecretRooms5.MODID)
// public final class SecretConfig {
//
// public static final General GENERAL = new General();
// public static final EnergizedPaste ENERGIZED_PASTE = new EnergizedPaste();
// public static final SRMBlockFunctionality BLOCK_FUNCTIONALITY = new SRMBlockFunctionality();
//
// public static final class General {
// @Config.Name("update_checker")
// @Config.Comment("Check for mod updates on startup")
// public boolean updateChecker = true;
//
// @Config.Name("survival_mode_helmet")
// @Config.Comment("Allow the helmet to be used in survival mode")
// public boolean survivalModeHelmet = true;
// }
//
// public static final class EnergizedPaste {
// @Config.Name("enable_recipe")
// @Config.Comment("Whether to enable the recipe for energized paste")
// public boolean enableRecipe = true;
//
// @Config.Name("mirror_blacklist")
// @Config.Comment("Blacklist of blocks that should not be mirrored by energized paste")
// public String[] blacklistMirror = {};
//
// @Config.Name("replacement_blacklist")
// @Config.Comment("Blacklist of blocks that should not be replaced by energized paste")
// public String[] replacementBlacklist = {};
//
// @Config.Name("tile_entity_whitelist")
// @Config.Comment("Whitelist of blocks with tile entities that can be copied by energized paste\nTo apply to a whole mod, do 'modid:*'")
// public String[] tileEntityWhitelist = {};
//
// @Config.Comment("The Sound, Volume and Pitch to play when a block is set to the Energized Paste")
// @Config.Name("sound_set_name")
// public String soundSetName = "minecraft:block.sand.place";
//
// @Config.Name("sound_set_volume")
// public double soundSetVolume = 0.5D;
//
// @Config.Name("sound_set_pitch")
// public double soundSetPitch = 3.0D;
//
// @Config.Comment("The Sound, Volume and Pitch to play when Energized Paste is used on another block, changing the appereance of that block.")
// @Config.Name("sound_use_name")
// public String soundUseName = "minecraft:block.slime.break";
//
// @Config.Name("sound_use_volume")
// public double soundUseVolume = 0.2D;
//
// @Config.Name("sound_use_pitch")
// public double soundUsePitch = 3.0D;
// }
//
// public static final class SRMBlockFunctionality {
//
// @Config.Comment("Should SRM attempt to copy the light value of the block its mirroring")
// @Config.Name("copy_light")
// public boolean copyLight = true;
//
// @Config.Comment("Should SRM be limited to only full blocks (Like the Classic SecretRoomsMod)")
// @Config.Name("only_full_blocks")
// public boolean onlyFullBlocks = false;
//
//
// }
//
// @SubscribeEvent
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
// if(event.getConfigID() != null && event.getConfigID().equals(SecretRooms5.MODID)) {
// ConfigManager.sync(SecretRooms5.MODID, Config.Type.INSTANCE);
// }
// }
//
// }
// Path: src/main/java/com/wynprice/secretroomsmod/items/TrueSightHelmet.java
import com.wynprice.secretroomsmod.SecretConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package com.wynprice.secretroomsmod.items;
public class TrueSightHelmet extends ItemArmor
{
public TrueSightHelmet(String name, ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {
super(materialIn, renderIndexIn, equipmentSlotIn);
setUnlocalizedName(name);
setRegistryName(name);
this.setMaxStackSize(1);
}
public static boolean isHelmet(EntityPlayer player) { | return player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem() instanceof TrueSightHelmet && (player.isCreative() || player.isSpectator() || SecretConfig.GENERAL.survivalModeHelmet); |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/tween/Tween.java | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Manages the animation of a particular property of a visible.
*/
public abstract class Tween
{
/** A tween that animates a single scalar value. */
public static class One extends Interped
{ | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: core/src/main/java/com/threerings/jiggl/tween/Tween.java
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Manages the animation of a particular property of a visible.
*/
public abstract class Tween
{
/** A tween that animates a single scalar value. */
public static class One extends Interped
{ | public One (Interpolator interp, Scalar value) { |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/tween/Tween.java | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Manages the animation of a particular property of a visible.
*/
public abstract class Tween
{
/** A tween that animates a single scalar value. */
public static class One extends Interped
{
public One (Interpolator interp, Scalar value) {
super(interp);
_value = value;
}
/** Configures the starting value. Default: the value of the scalar at the time that the
* tween begins. */
public One from (float value) {
_from = value;
return this;
}
/** Configures the ending value. Default: 0. */
public One to (float value) {
_to = value;
return this;
}
@Override
protected void init (float time) {
super.init(time);
if (_from == Float.MIN_VALUE) _from = _value.value;
}
@Override
protected boolean apply (float time) {
float dt = time-_start;
if (dt < _duration) {
_value.value = _interp.apply(_from, _to-_from, dt, _duration);
return false;
} else {
_value.value = _to;
return true;
}
}
protected final Scalar _value;
protected float _from = Float.MIN_VALUE;
protected float _to;
}
/** A tween that animates a pair of scalar values (usually a position). */
public static class Two extends Interped
{
public Two (Interpolator interp, Scalar x, Scalar y) {
super(interp);
_x = x;
_y = y;
}
/** Configures the starting values. Default: the values of the scalar at the time that the
* tween begins. */
public Two from (float fromx, float fromy)
{
_fromx = fromx;
_fromy = fromy;
return this;
}
/** Configures the ending values. Default: (0, 0). */
public Two to (float tox, float toy)
{
_tox = tox;
_toy = toy;
return this;
}
@Override
protected void init (float time) {
super.init(time);
if (_fromx == Float.MIN_VALUE) _fromx = _x.value;
if (_fromy == Float.MIN_VALUE) _fromy = _y.value;
}
@Override
protected boolean apply (float time) {
float dt = time-_start;
if (dt < _duration) {
_x.value = _interp.apply(_fromx, _tox-_fromx, dt, _duration);
_y.value = _interp.apply(_fromy, _toy-_fromy, dt, _duration);
return false;
} else {
_x.value = _tox;
_y.value = _toy;
return true;
}
}
protected final Scalar _x, _y;
protected float _fromx = Float.MIN_VALUE, _fromy = Float.MIN_VALUE;
protected float _tox, _toy;
}
/** A tween that simply delays a specified number of seconds. */
public static class Delay extends Tween
{
public Delay (float duration) {
_duration = duration;
}
@Override
protected boolean apply (float time) {
return (time-_start >= _duration);
}
@Override
protected float getOverrun (float time) {
return (time - _start) - _duration;
}
protected final float _duration;
}
/** A tween that executes an action and completes immediately. */
public static class Action extends Tween
{
public Action (Runnable action) {
_action = action;
}
@Override
protected boolean apply (float time) {
_action.run();
return true;
}
protected Runnable _action;
}
/** A tween that repeats its underlying tween over and over again (until removed). */
public static class Repeat extends Tween
{ | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: core/src/main/java/com/threerings/jiggl/tween/Tween.java
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Manages the animation of a particular property of a visible.
*/
public abstract class Tween
{
/** A tween that animates a single scalar value. */
public static class One extends Interped
{
public One (Interpolator interp, Scalar value) {
super(interp);
_value = value;
}
/** Configures the starting value. Default: the value of the scalar at the time that the
* tween begins. */
public One from (float value) {
_from = value;
return this;
}
/** Configures the ending value. Default: 0. */
public One to (float value) {
_to = value;
return this;
}
@Override
protected void init (float time) {
super.init(time);
if (_from == Float.MIN_VALUE) _from = _value.value;
}
@Override
protected boolean apply (float time) {
float dt = time-_start;
if (dt < _duration) {
_value.value = _interp.apply(_from, _to-_from, dt, _duration);
return false;
} else {
_value.value = _to;
return true;
}
}
protected final Scalar _value;
protected float _from = Float.MIN_VALUE;
protected float _to;
}
/** A tween that animates a pair of scalar values (usually a position). */
public static class Two extends Interped
{
public Two (Interpolator interp, Scalar x, Scalar y) {
super(interp);
_x = x;
_y = y;
}
/** Configures the starting values. Default: the values of the scalar at the time that the
* tween begins. */
public Two from (float fromx, float fromy)
{
_fromx = fromx;
_fromy = fromy;
return this;
}
/** Configures the ending values. Default: (0, 0). */
public Two to (float tox, float toy)
{
_tox = tox;
_toy = toy;
return this;
}
@Override
protected void init (float time) {
super.init(time);
if (_fromx == Float.MIN_VALUE) _fromx = _x.value;
if (_fromy == Float.MIN_VALUE) _fromy = _y.value;
}
@Override
protected boolean apply (float time) {
float dt = time-_start;
if (dt < _duration) {
_x.value = _interp.apply(_fromx, _tox-_fromx, dt, _duration);
_y.value = _interp.apply(_fromy, _toy-_fromy, dt, _duration);
return false;
} else {
_x.value = _tox;
_y.value = _toy;
return true;
}
}
protected final Scalar _x, _y;
protected float _fromx = Float.MIN_VALUE, _fromy = Float.MIN_VALUE;
protected float _tox, _toy;
}
/** A tween that simply delays a specified number of seconds. */
public static class Delay extends Tween
{
public Delay (float duration) {
_duration = duration;
}
@Override
protected boolean apply (float time) {
return (time-_start >= _duration);
}
@Override
protected float getOverrun (float time) {
return (time - _start) - _duration;
}
protected final float _duration;
}
/** A tween that executes an action and completes immediately. */
public static class Action extends Tween
{
public Action (Runnable action) {
_action = action;
}
@Override
protected boolean apply (float time) {
_action.run();
return true;
}
protected Runnable _action;
}
/** A tween that repeats its underlying tween over and over again (until removed). */
public static class Repeat extends Tween
{ | public Repeat (Viz viz) { |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{ | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{ | public void execute (final Context ctx) |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{
public void execute (final Context ctx)
{ | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{
public void execute (final Context ctx)
{ | final TileSet tiles = ctx.tiles.load("testtiles.png"); |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{
public void execute (final Context ctx)
{
final TileSet tiles = ctx.tiles.load("testtiles.png"); | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/rsrc/TileSet.java
// public abstract class TileSet
// {
// /** Returns the tile at the specified index. */
// public abstract Tile get (int index);
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/TileVizTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.rsrc.TileSet;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Displays some tiles and moves them around.
*/
public class TileVizTest
{
public void execute (final Context ctx)
{
final TileSet tiles = ctx.tiles.load("testtiles.png"); | final Viz tile0 = ctx.view.add(ctx.view.newTileViz(tiles.get(0))); |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{ | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{ | public void execute (final Context ctx) |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{ | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{ | final Geometry quad = ctx.renderer.createQuad(1, 1); |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{
final Geometry quad = ctx.renderer.createQuad(1, 1); | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{
final Geometry quad = ctx.renderer.createQuad(1, 1); | final Viz quad0 = ctx.view.add(ctx.view.newGeomViz(quad, new Color(1, 0, 0))); |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{
final Geometry quad = ctx.renderer.createQuad(1, 1); | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Geometry.java
// public abstract class Geometry
// {
// /** The number of vertex components per attribute. */
// public final int compPerAttr;
//
// /**
// * Binds this geometry's vertices in preparation for rendering. This will be followed almost
// * immediately by a call to draw, with only some shader fiddling in between.
// */
// public abstract void bind (Renderer r);
//
// /**
// * Draws this geometry.
// */
// public abstract void draw (Renderer r);
//
// /**
// * Returns the width of this geometry.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this geometry.
// */
// public abstract float getHeight ();
//
// protected Geometry (int compPerAttr)
// {
// this.compPerAttr = compPerAttr;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/GeomTest.java
import com.google.gwt.core.client.GWT;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.util.Color;
import com.threerings.jiggl.view.Geometry;
import com.threerings.jiggl.view.Viz;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* Tests the display of simple geometries.
*/
public class GeomTest
{
public void execute (final Context ctx)
{
final Geometry quad = ctx.renderer.createQuad(1, 1); | final Viz quad0 = ctx.view.add(ctx.view.newGeomViz(quad, new Color(1, 0, 0))); |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java | // Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
| import com.threerings.jiggl.view.WGLView;
import com.google.gwt.user.client.Timer; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.util;
/**
* Drives a Jiggl/WebGL application.
*/
public class WGLDriver extends Driver
{ | // Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.user.client.Timer;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.util;
/**
* Drives a Jiggl/WebGL application.
*/
public class WGLDriver extends Driver
{ | public WGLDriver (WGLView view, int freqMillis) |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/ColorViz.java | // Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
| import com.threerings.jiggl.util.Color; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Renders geometry with a color.
*/
public class ColorViz extends WGLViz
{ | // Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/ColorViz.java
import com.threerings.jiggl.util.Color;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Renders geometry with a color.
*/
public class ColorViz extends WGLViz
{ | public ColorViz (Geometry geom, Color color) |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/TileViz.java | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
| import com.threerings.jiggl.rsrc.Tile;
import com.googlecode.gwtgl.binding.WebGLRenderingContext; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Renders a tile (a textured quad).
*/
public class TileViz extends WGLViz
{ | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/TileViz.java
import com.threerings.jiggl.rsrc.Tile;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Renders a tile (a textured quad).
*/
public class TileViz extends WGLViz
{ | public TileViz (WGLRenderer renderer, Tile tile) |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/view/View.java | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
| import com.threerings.jiggl.rsrc.Tile;
import com.threerings.jiggl.util.Color;
import java.util.ArrayList;
import java.util.List; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Coordinates the display and animation of a collection of {@link Viz} instances.
*/
public abstract class View
{
/**
* Adds the supplied viz to this view. Returns the added viz for convenient chaining.
*/
public <T extends Viz> T add (T viz)
{
viz.onAdd(this);
_vizs.add(viz);
return viz;
}
/**
* Removes the specified viz from this view.
*/
public void remove (Viz viz)
{
_vizs.remove(viz);
viz.onRemove();
}
/**
* Removes all registered visibles from this view.
*/
public void clear ()
{
for (Viz v : _vizs) {
v.onRemove();
}
_vizs.clear();
}
/**
* Executes this view's rendering commands.
*/
public abstract void render ();
/**
* Creates a visible that renders the supplied geometry using the supplied color.
*/ | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
// Path: core/src/main/java/com/threerings/jiggl/view/View.java
import com.threerings.jiggl.rsrc.Tile;
import com.threerings.jiggl.util.Color;
import java.util.ArrayList;
import java.util.List;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Coordinates the display and animation of a collection of {@link Viz} instances.
*/
public abstract class View
{
/**
* Adds the supplied viz to this view. Returns the added viz for convenient chaining.
*/
public <T extends Viz> T add (T viz)
{
viz.onAdd(this);
_vizs.add(viz);
return viz;
}
/**
* Removes the specified viz from this view.
*/
public void remove (Viz viz)
{
_vizs.remove(viz);
viz.onRemove();
}
/**
* Removes all registered visibles from this view.
*/
public void clear ()
{
for (Viz v : _vizs) {
v.onRemove();
}
_vizs.clear();
}
/**
* Executes this view's rendering commands.
*/
public abstract void render ();
/**
* Creates a visible that renders the supplied geometry using the supplied color.
*/ | public abstract Viz newGeomViz (Geometry geom, Color color); |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/view/View.java | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
| import com.threerings.jiggl.rsrc.Tile;
import com.threerings.jiggl.util.Color;
import java.util.ArrayList;
import java.util.List; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Coordinates the display and animation of a collection of {@link Viz} instances.
*/
public abstract class View
{
/**
* Adds the supplied viz to this view. Returns the added viz for convenient chaining.
*/
public <T extends Viz> T add (T viz)
{
viz.onAdd(this);
_vizs.add(viz);
return viz;
}
/**
* Removes the specified viz from this view.
*/
public void remove (Viz viz)
{
_vizs.remove(viz);
viz.onRemove();
}
/**
* Removes all registered visibles from this view.
*/
public void clear ()
{
for (Viz v : _vizs) {
v.onRemove();
}
_vizs.clear();
}
/**
* Executes this view's rendering commands.
*/
public abstract void render ();
/**
* Creates a visible that renders the supplied geometry using the supplied color.
*/
public abstract Viz newGeomViz (Geometry geom, Color color);
/**
* Creates a visible to render the supplied tile.
*/ | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
// Path: core/src/main/java/com/threerings/jiggl/view/View.java
import com.threerings.jiggl.rsrc.Tile;
import com.threerings.jiggl.util.Color;
import java.util.ArrayList;
import java.util.List;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Coordinates the display and animation of a collection of {@link Viz} instances.
*/
public abstract class View
{
/**
* Adds the supplied viz to this view. Returns the added viz for convenient chaining.
*/
public <T extends Viz> T add (T viz)
{
viz.onAdd(this);
_vizs.add(viz);
return viz;
}
/**
* Removes the specified viz from this view.
*/
public void remove (Viz viz)
{
_vizs.remove(viz);
viz.onRemove();
}
/**
* Removes all registered visibles from this view.
*/
public void clear ()
{
for (Viz v : _vizs) {
v.onRemove();
}
_vizs.clear();
}
/**
* Executes this view's rendering commands.
*/
public abstract void render ();
/**
* Creates a visible that renders the supplied geometry using the supplied color.
*/
public abstract Viz newGeomViz (Geometry geom, Color color);
/**
* Creates a visible to render the supplied tile.
*/ | public abstract Viz newTileViz (Tile tile); |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/view/Viz.java | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
| import com.threerings.jiggl.util.Scalar; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* A visible entity, which has base dimensions and a transform matrix, and which knows how to
* render itself. The lifecycle of a viz is a call to {@link #onAdd}, zero or more calls to {@link
* #render}, followed by a call to {@link #onRemove}. This lifecycle may be repeated for a viz that
* is added to and removed from a view repeatedly.
*/
public abstract class Viz
{
/** The x-component of our (container relative) translation. */ | // Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
import com.threerings.jiggl.util.Scalar;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* A visible entity, which has base dimensions and a transform matrix, and which knows how to
* render itself. The lifecycle of a viz is a call to {@link #onAdd}, zero or more calls to {@link
* #render}, followed by a call to {@link #onRemove}. This lifecycle may be repeated for a viz that
* is added to and removed from a view repeatedly.
*/
public abstract class Viz
{
/** The x-component of our (container relative) translation. */ | public final Scalar x = new Scalar(0); |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/WGLRenderer.java | // Path: webgl/src/main/java/com/threerings/jiggl/util/GeomUtil.java
// public class GeomUtil
// {
// /**
// * Creates an orthographic projection matrix which will display pixels in the ranges:
// * [0, width), [0, height) and [-depth/2, depth/2).
// */
// public static float[] createOrthoMatrix (int width, int height, int depth)
// {
// // see http://www.khronos.org/opengles/documentation/opengles1_0/html/glOrtho.html
// float left = 0, right = width, top = height, bottom = 0, near = -depth/2, far = depth/2;
// float tx = -(right+left)/(right-left);
// float ty = -(top+bottom)/(top-bottom);
// float tz = -(far+near)/(far-near);
// return new float[] { 2/(right-left), 0, 0, 0,
// 0, 2/(top-bottom), 0, 0,
// 0, 0, -2/(far-near), 0,
// tx, ty, tz, 1 };
// }
//
// /**
// * Creates a perspective projection matrix. Not used, but here for reference.
// */
// public static float[] createPerspectiveMatrix (
// int fieldOfViewVertical, float aspectRatio, float minimumClearance, float maximumClearance)
// {
// float top = minimumClearance * (float)Math.tan(fieldOfViewVertical * Math.PI / 360.0);
// float bottom = -top;
// float left = bottom * aspectRatio;
// float right = top * aspectRatio;
//
// float X = 2*minimumClearance/(right-left);
// float Y = 2*minimumClearance/(top-bottom);
// float A = (right+left)/(right-left);
// float B = (top+bottom)/(top-bottom);
// float C = -(maximumClearance+minimumClearance)/(maximumClearance-minimumClearance);
// float D = -2*maximumClearance*minimumClearance/(maximumClearance-minimumClearance);
//
// return new float[] { X, 0f, A, 0f,
// 0f, Y, B, 0f,
// 0f, 0f, C, -1f,
// 0f, 0f, D, 0f};
// }
// }
| import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.threerings.jiggl.util.GeomUtil;
import com.googlecode.gwtgl.array.Float32Array;
import com.googlecode.gwtgl.binding.WebGLBuffer; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Manages renderer state that may be shared across visibles.
*/
public class WGLRenderer extends Renderer
{
/** Provides access to OpenGL bits. */
public final WebGLRenderingContext wctx;
/** Our orthographic projection matrix. */ | // Path: webgl/src/main/java/com/threerings/jiggl/util/GeomUtil.java
// public class GeomUtil
// {
// /**
// * Creates an orthographic projection matrix which will display pixels in the ranges:
// * [0, width), [0, height) and [-depth/2, depth/2).
// */
// public static float[] createOrthoMatrix (int width, int height, int depth)
// {
// // see http://www.khronos.org/opengles/documentation/opengles1_0/html/glOrtho.html
// float left = 0, right = width, top = height, bottom = 0, near = -depth/2, far = depth/2;
// float tx = -(right+left)/(right-left);
// float ty = -(top+bottom)/(top-bottom);
// float tz = -(far+near)/(far-near);
// return new float[] { 2/(right-left), 0, 0, 0,
// 0, 2/(top-bottom), 0, 0,
// 0, 0, -2/(far-near), 0,
// tx, ty, tz, 1 };
// }
//
// /**
// * Creates a perspective projection matrix. Not used, but here for reference.
// */
// public static float[] createPerspectiveMatrix (
// int fieldOfViewVertical, float aspectRatio, float minimumClearance, float maximumClearance)
// {
// float top = minimumClearance * (float)Math.tan(fieldOfViewVertical * Math.PI / 360.0);
// float bottom = -top;
// float left = bottom * aspectRatio;
// float right = top * aspectRatio;
//
// float X = 2*minimumClearance/(right-left);
// float Y = 2*minimumClearance/(top-bottom);
// float A = (right+left)/(right-left);
// float B = (top+bottom)/(top-bottom);
// float C = -(maximumClearance+minimumClearance)/(maximumClearance-minimumClearance);
// float D = -2*maximumClearance*minimumClearance/(maximumClearance-minimumClearance);
//
// return new float[] { X, 0f, A, 0f,
// 0f, Y, B, 0f,
// 0f, 0f, C, -1f,
// 0f, 0f, D, 0f};
// }
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLRenderer.java
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.threerings.jiggl.util.GeomUtil;
import com.googlecode.gwtgl.array.Float32Array;
import com.googlecode.gwtgl.binding.WebGLBuffer;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Manages renderer state that may be shared across visibles.
*/
public class WGLRenderer extends Renderer
{
/** Provides access to OpenGL bits. */
public final WebGLRenderingContext wctx;
/** Our orthographic projection matrix. */ | public final float[] projMatrix = GeomUtil.createOrthoMatrix(5, 5, 20); |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/WebGL.java | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
| import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{ | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{ | WGLView view = new WGLView(canvas, 500, 500); |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/WebGL.java | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
| import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{
WGLView view = new WGLView(canvas, 500, 500); | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{
WGLView view = new WGLView(canvas, 500, 500); | return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view, |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/WebGL.java | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
| import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{
WGLView view = new WGLView(canvas, 500, 500);
return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view, | // Path: webgl/src/main/java/com/threerings/jiggl/rsrc/WGLTileSetLoader.java
// public class WGLTileSetLoader extends TileSetLoader
// {
// public WGLTileSetLoader (String baseURL)
// {
// _baseURL = baseURL + (baseURL.endsWith("/") ? "" : "/");
// }
//
// @Override // from TileSetLoader
// public TileSet load (String tileSetId)
// {
// int width = 64, height = 64; // TODO
// return new WGLTileSet(_baseURL + tileSetId, width, height);
// }
//
// protected final String _baseURL;
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/util/WGLDriver.java
// public class WGLDriver extends Driver
// {
// public WGLDriver (WGLView view, int freqMillis)
// {
// super(view);
// new Timer() {
// public void run () {
// tick((System.currentTimeMillis()-_start)/1000f);
// }
// }.scheduleRepeating(freqMillis);
// }
//
// protected long _start = System.currentTimeMillis();
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
// public class WGLView extends View
// {
// /** Provides access to shared rendering bits. */
// public final WGLRenderer renderer;
//
// public WGLView (Canvas canvas, int width, int height)
// {
// _wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
//
// canvas.setCoordinateSpaceHeight(width);
// canvas.setCoordinateSpaceWidth(height);
// _wctx.viewport(0, 0, width, height);
//
// // create our renderer now that the basic viewport is configured
// renderer = new WGLRenderer(_wctx);
//
// // temp: initialize the view
// _wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
// _wctx.clearDepth(1.0f);
// _wctx.enable(WebGLRenderingContext.DEPTH_TEST);
// _wctx.depthFunc(WebGLRenderingContext.LEQUAL);
// }
//
// @Override // from View
// public void render ()
// {
// // clear the view
// _wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
//
// // render all registered visibles
// renderVisibles();
// }
//
// @Override // from View
// public Viz newGeomViz (Geometry geom, Color color)
// {
// return new ColorViz(geom, color);
// }
//
// @Override // from View
// public Viz newTileViz (Tile tile)
// {
// return new TileViz(renderer, tile);
// }
//
// protected final WebGLRenderingContext _wctx;
// }
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
import com.threerings.jiggl.rsrc.WGLTileSetLoader;
import com.threerings.jiggl.util.WGLDriver;
import com.threerings.jiggl.view.WGLView;
import com.google.gwt.canvas.client.Canvas;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl;
/**
* The main factory for WebGL views and visibles.
*/
public class WebGL
{
public static Context create (Canvas canvas, String rsrcRootURL)
{
WGLView view = new WGLView(canvas, 500, 500);
return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view, | new WGLTileSetLoader(rsrcRootURL)); |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/WGLViz.java | // Path: webgl/src/main/java/com/threerings/jiggl/util/MatrixUtil.java
// public class MatrixUtil
// {
// /**
// * Returns the 3x3 identity matrix.
// */
// public static float[] identity3 ()
// {
// return new float[] { 1, 0, 0,
// 0, 1, 0,
// 0, 0, 1 };
// }
//
// /**
// * Returns the 4x4 identity matrix.
// */
// public static float[] identity4 ()
// {
// return new float[] { 1, 0, 0, 0,
// 0, 1, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// /**
// * Computes a transformation matrix with the supplied translation, scale and rotation factors.
// */
// public static float[] transform4 (float dx, float dy, float dz,
// float sx, float sy, float sz, float theta)
// {
// float cos = (float)Math.cos(theta), sin = (float)Math.sin(theta);
// return new float[] { cos*sx, sin, 0, 0,
// -sin, cos*sy, 0, 0,
// 0, 0, sz, 0,
// dx, dy, dz, 1 };
// }
//
// /**
// * Returns a 4x4 translation matrix.
// */
// public static float[] translation (float dx, float dy, float dz)
// {
// return translate(identity4(), dx, dy, dz);
// }
//
// /**
// * Adds the supplied translations to the supplied 4x4 matrix. Returns the same matrix for
// * convenience.
// */
// public static float[] translate (float[] matrix, float dx, float dy, float dz)
// {
// matrix[M03] += dx;
// matrix[M13] += dy;
// matrix[M23] += dz;
// return matrix;
// }
//
// /**
// * Returns a 4x4 scaling matrix.
// */
// public static float[] scale (float sx, float sy)
// {
// return new float[] { sx, 0, 0, 0,
// 0, sy, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// /**
// * Returns a 4x4 rotation matrix (around the z axis).
// */
// public static float[] rotation (float theta)
// {
// float cos = (float)Math.cos(theta), sin = (float)Math.sin(theta);
// return new float[] { cos, sin, 0, 0,
// -sin, cos, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// // Position constants for 4x4 matrix of the form MRC where R = row and C = column
// protected static final int M00 = 4*0+0, M01 = 4*1+0, M02 = 4*2+0, M03 = 4*3+0;
// protected static final int M10 = 4*0+1, M11 = 4*1+1, M12 = 4*2+1, M13 = 4*3+1;
// protected static final int M20 = 4*0+2, M21 = 4*1+2, M22 = 4*2+2, M23 = 4*3+2;
// protected static final int M30 = 4*0+3, M31 = 4*1+3, M32 = 4*2+3, M33 = 4*3+3;
// }
| import com.googlecode.gwtgl.binding.WebGLUniformLocation;
import com.threerings.jiggl.util.MatrixUtil;
import com.google.gwt.core.client.GWT;
import com.googlecode.gwtgl.binding.WebGLRenderingContext; | }
@Override // from Viz
protected void onAdd (View view)
{
_view = (WGLView)view;
_shader.init(_view.renderer);
}
@Override // from Viz
protected void onRemove ()
{
_shader.delete(_view.renderer);
_view = null;
}
@Override // from Viz
protected void render ()
{
WGLRenderer wr = _view.renderer;
_shader.bind(wr);
bindUniforms(wr);
_geom.bind(wr);
bindAttributes(wr);
_geom.draw(wr);
}
protected void bindUniforms (WGLRenderer wr)
{ | // Path: webgl/src/main/java/com/threerings/jiggl/util/MatrixUtil.java
// public class MatrixUtil
// {
// /**
// * Returns the 3x3 identity matrix.
// */
// public static float[] identity3 ()
// {
// return new float[] { 1, 0, 0,
// 0, 1, 0,
// 0, 0, 1 };
// }
//
// /**
// * Returns the 4x4 identity matrix.
// */
// public static float[] identity4 ()
// {
// return new float[] { 1, 0, 0, 0,
// 0, 1, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// /**
// * Computes a transformation matrix with the supplied translation, scale and rotation factors.
// */
// public static float[] transform4 (float dx, float dy, float dz,
// float sx, float sy, float sz, float theta)
// {
// float cos = (float)Math.cos(theta), sin = (float)Math.sin(theta);
// return new float[] { cos*sx, sin, 0, 0,
// -sin, cos*sy, 0, 0,
// 0, 0, sz, 0,
// dx, dy, dz, 1 };
// }
//
// /**
// * Returns a 4x4 translation matrix.
// */
// public static float[] translation (float dx, float dy, float dz)
// {
// return translate(identity4(), dx, dy, dz);
// }
//
// /**
// * Adds the supplied translations to the supplied 4x4 matrix. Returns the same matrix for
// * convenience.
// */
// public static float[] translate (float[] matrix, float dx, float dy, float dz)
// {
// matrix[M03] += dx;
// matrix[M13] += dy;
// matrix[M23] += dz;
// return matrix;
// }
//
// /**
// * Returns a 4x4 scaling matrix.
// */
// public static float[] scale (float sx, float sy)
// {
// return new float[] { sx, 0, 0, 0,
// 0, sy, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// /**
// * Returns a 4x4 rotation matrix (around the z axis).
// */
// public static float[] rotation (float theta)
// {
// float cos = (float)Math.cos(theta), sin = (float)Math.sin(theta);
// return new float[] { cos, sin, 0, 0,
// -sin, cos, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1 };
// }
//
// // Position constants for 4x4 matrix of the form MRC where R = row and C = column
// protected static final int M00 = 4*0+0, M01 = 4*1+0, M02 = 4*2+0, M03 = 4*3+0;
// protected static final int M10 = 4*0+1, M11 = 4*1+1, M12 = 4*2+1, M13 = 4*3+1;
// protected static final int M20 = 4*0+2, M21 = 4*1+2, M22 = 4*2+2, M23 = 4*3+2;
// protected static final int M30 = 4*0+3, M31 = 4*1+3, M32 = 4*2+3, M33 = 4*3+3;
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLViz.java
import com.googlecode.gwtgl.binding.WebGLUniformLocation;
import com.threerings.jiggl.util.MatrixUtil;
import com.google.gwt.core.client.GWT;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
}
@Override // from Viz
protected void onAdd (View view)
{
_view = (WGLView)view;
_shader.init(_view.renderer);
}
@Override // from Viz
protected void onRemove ()
{
_shader.delete(_view.renderer);
_view = null;
}
@Override // from Viz
protected void render ()
{
WGLRenderer wr = _view.renderer;
_shader.bind(wr);
bindUniforms(wr);
_geom.bind(wr);
bindAttributes(wr);
_geom.draw(wr);
}
protected void bindUniforms (WGLRenderer wr)
{ | float[] transform = MatrixUtil.transform4( |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/util/Driver.java | // Path: core/src/main/java/com/threerings/jiggl/view/View.java
// public abstract class View
// {
// /**
// * Adds the supplied viz to this view. Returns the added viz for convenient chaining.
// */
// public <T extends Viz> T add (T viz)
// {
// viz.onAdd(this);
// _vizs.add(viz);
// return viz;
// }
//
// /**
// * Removes the specified viz from this view.
// */
// public void remove (Viz viz)
// {
// _vizs.remove(viz);
// viz.onRemove();
// }
//
// /**
// * Removes all registered visibles from this view.
// */
// public void clear ()
// {
// for (Viz v : _vizs) {
// v.onRemove();
// }
// _vizs.clear();
// }
//
// /**
// * Executes this view's rendering commands.
// */
// public abstract void render ();
//
// /**
// * Creates a visible that renders the supplied geometry using the supplied color.
// */
// public abstract Viz newGeomViz (Geometry geom, Color color);
//
// /**
// * Creates a visible to render the supplied tile.
// */
// public abstract Viz newTileViz (Tile tile);
//
// /**
// * Renders the visibles registered with this view.
// */
// protected void renderVisibles ()
// {
// for (int ii = 0, ll = _vizs.size(); ii < ll; ii++) {
// _vizs.get(ii).render();
// }
// }
//
// /** A list of our active visibles. */
// protected List<Viz> _vizs = new ArrayList<Viz>();
// }
| import com.threerings.jiggl.view.View;
import java.util.ArrayList;
import java.util.List; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.util;
/**
* Drives the time-based elements of a Jiggl application (animations and whatnot).
*/
public abstract class Driver
{
/** An interface implemented by things that wish to tick. */
public interface Tickable {
/** Called on every frame tick with the time elapsed since app start, in seconds.
* @return true if the tickable should remain registered, false otherwise. */
boolean tick (float time);
}
/**
* Registers a new tickable with the driver. The tickable may only be removed by returning
* false from its {@link Tickable#tick} method.
*/
public void addTickable (Tickable tickable)
{
_tickables.add(tickable);
}
/**
* Ticks all registered tickables, then re-renders the view.
*/
protected void tick (float time)
{
for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
if (!_tickables.get(ii).tick(time)) {
_tickables.remove(ii--);
ll -= 1;
}
}
_view.render();
}
| // Path: core/src/main/java/com/threerings/jiggl/view/View.java
// public abstract class View
// {
// /**
// * Adds the supplied viz to this view. Returns the added viz for convenient chaining.
// */
// public <T extends Viz> T add (T viz)
// {
// viz.onAdd(this);
// _vizs.add(viz);
// return viz;
// }
//
// /**
// * Removes the specified viz from this view.
// */
// public void remove (Viz viz)
// {
// _vizs.remove(viz);
// viz.onRemove();
// }
//
// /**
// * Removes all registered visibles from this view.
// */
// public void clear ()
// {
// for (Viz v : _vizs) {
// v.onRemove();
// }
// _vizs.clear();
// }
//
// /**
// * Executes this view's rendering commands.
// */
// public abstract void render ();
//
// /**
// * Creates a visible that renders the supplied geometry using the supplied color.
// */
// public abstract Viz newGeomViz (Geometry geom, Color color);
//
// /**
// * Creates a visible to render the supplied tile.
// */
// public abstract Viz newTileViz (Tile tile);
//
// /**
// * Renders the visibles registered with this view.
// */
// protected void renderVisibles ()
// {
// for (int ii = 0, ll = _vizs.size(); ii < ll; ii++) {
// _vizs.get(ii).render();
// }
// }
//
// /** A list of our active visibles. */
// protected List<Viz> _vizs = new ArrayList<Viz>();
// }
// Path: core/src/main/java/com/threerings/jiggl/util/Driver.java
import com.threerings.jiggl.view.View;
import java.util.ArrayList;
import java.util.List;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.util;
/**
* Drives the time-based elements of a Jiggl application (animations and whatnot).
*/
public abstract class Driver
{
/** An interface implemented by things that wish to tick. */
public interface Tickable {
/** Called on every frame tick with the time elapsed since app start, in seconds.
* @return true if the tickable should remain registered, false otherwise. */
boolean tick (float time);
}
/**
* Registers a new tickable with the driver. The tickable may only be removed by returning
* false from its {@link Tickable#tick} method.
*/
public void addTickable (Tickable tickable)
{
_tickables.add(tickable);
}
/**
* Ticks all registered tickables, then re-renders the view.
*/
protected void tick (float time)
{
for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
if (!_tickables.get(ii).tick(time)) {
_tickables.remove(ii--);
ll -= 1;
}
}
_view.render();
}
| protected Driver (View view) |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/WGLView.java | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
| import com.threerings.jiggl.util.Color;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.google.gwt.canvas.client.Canvas;
import com.threerings.jiggl.rsrc.Tile; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Provides a view implementation based on a GWT {@link Canvas} and the WebGL context.
*/
public class WGLView extends View
{
/** Provides access to shared rendering bits. */
public final WGLRenderer renderer;
public WGLView (Canvas canvas, int width, int height)
{
_wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
canvas.setCoordinateSpaceHeight(width);
canvas.setCoordinateSpaceWidth(height);
_wctx.viewport(0, 0, width, height);
// create our renderer now that the basic viewport is configured
renderer = new WGLRenderer(_wctx);
// temp: initialize the view
_wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
_wctx.clearDepth(1.0f);
_wctx.enable(WebGLRenderingContext.DEPTH_TEST);
_wctx.depthFunc(WebGLRenderingContext.LEQUAL);
}
@Override // from View
public void render ()
{
// clear the view
_wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
// render all registered visibles
renderVisibles();
}
@Override // from View | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
import com.threerings.jiggl.util.Color;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.google.gwt.canvas.client.Canvas;
import com.threerings.jiggl.rsrc.Tile;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Provides a view implementation based on a GWT {@link Canvas} and the WebGL context.
*/
public class WGLView extends View
{
/** Provides access to shared rendering bits. */
public final WGLRenderer renderer;
public WGLView (Canvas canvas, int width, int height)
{
_wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
canvas.setCoordinateSpaceHeight(width);
canvas.setCoordinateSpaceWidth(height);
_wctx.viewport(0, 0, width, height);
// create our renderer now that the basic viewport is configured
renderer = new WGLRenderer(_wctx);
// temp: initialize the view
_wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
_wctx.clearDepth(1.0f);
_wctx.enable(WebGLRenderingContext.DEPTH_TEST);
_wctx.depthFunc(WebGLRenderingContext.LEQUAL);
}
@Override // from View
public void render ()
{
// clear the view
_wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
// render all registered visibles
renderVisibles();
}
@Override // from View | public Viz newGeomViz (Geometry geom, Color color) |
threerings/jiggl | webgl/src/main/java/com/threerings/jiggl/view/WGLView.java | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
| import com.threerings.jiggl.util.Color;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.google.gwt.canvas.client.Canvas;
import com.threerings.jiggl.rsrc.Tile; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Provides a view implementation based on a GWT {@link Canvas} and the WebGL context.
*/
public class WGLView extends View
{
/** Provides access to shared rendering bits. */
public final WGLRenderer renderer;
public WGLView (Canvas canvas, int width, int height)
{
_wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
canvas.setCoordinateSpaceHeight(width);
canvas.setCoordinateSpaceWidth(height);
_wctx.viewport(0, 0, width, height);
// create our renderer now that the basic viewport is configured
renderer = new WGLRenderer(_wctx);
// temp: initialize the view
_wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
_wctx.clearDepth(1.0f);
_wctx.enable(WebGLRenderingContext.DEPTH_TEST);
_wctx.depthFunc(WebGLRenderingContext.LEQUAL);
}
@Override // from View
public void render ()
{
// clear the view
_wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
// render all registered visibles
renderVisibles();
}
@Override // from View
public Viz newGeomViz (Geometry geom, Color color)
{
return new ColorViz(geom, color);
}
@Override // from View | // Path: core/src/main/java/com/threerings/jiggl/rsrc/Tile.java
// public abstract class Tile
// {
// /** Returns the width of this tile, in pixels. */
// public abstract int getWidth ();
//
// /** Returns the height of this tile, in pixels. */
// public abstract int getHeight ();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Color.java
// public class Color
// {
// /** The red component of this color. Must be between 0 and 1f. */
// public final Scalar red;
//
// /** The green component of this color. Must be between 0 and 1f. */
// public final Scalar green;
//
// /** The blue component of this color. Must be between 0 and 1f. */
// public final Scalar blue;
//
// /** The alpha component of this color. Must be between 0 and 1f. */
// public final Scalar alpha;
//
// /**
// * Creates a color with the specified red, green, blue and alpha components.
// */
// public Color (float red, float green, float blue, float alpha)
// {
// this.red = new Scalar(red);
// this.green = new Scalar(green);
// this.blue = new Scalar(blue);
// this.alpha = new Scalar(alpha);
// }
//
// /**
// * Creates a color with the specified red, green, and blue components, with an alpha of 1.
// */
// public Color (float red, float green, float blue)
// {
// this(red, green, blue, 1f);
// }
//
// /**
// * Returns a float array suitable for binding to a vec4 shader variable.
// */
// public float[] toVec4fv ()
// {
// return new float[] { red.value, green.value, blue.value, alpha.value };
// }
// }
// Path: webgl/src/main/java/com/threerings/jiggl/view/WGLView.java
import com.threerings.jiggl.util.Color;
import com.googlecode.gwtgl.binding.WebGLRenderingContext;
import com.google.gwt.canvas.client.Canvas;
import com.threerings.jiggl.rsrc.Tile;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.view;
/**
* Provides a view implementation based on a GWT {@link Canvas} and the WebGL context.
*/
public class WGLView extends View
{
/** Provides access to shared rendering bits. */
public final WGLRenderer renderer;
public WGLView (Canvas canvas, int width, int height)
{
_wctx = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
canvas.setCoordinateSpaceHeight(width);
canvas.setCoordinateSpaceWidth(height);
_wctx.viewport(0, 0, width, height);
// create our renderer now that the basic viewport is configured
renderer = new WGLRenderer(_wctx);
// temp: initialize the view
_wctx.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
_wctx.clearDepth(1.0f);
_wctx.enable(WebGLRenderingContext.DEPTH_TEST);
_wctx.depthFunc(WebGLRenderingContext.LEQUAL);
}
@Override // from View
public void render ()
{
// clear the view
_wctx.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT);
// render all registered visibles
renderVisibles();
}
@Override // from View
public Viz newGeomViz (Geometry geom, Color color)
{
return new ColorViz(geom, color);
}
@Override // from View | public Viz newTileViz (Tile tile) |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/TestViewer.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
// public class WebGL
// {
// public static Context create (Canvas canvas, String rsrcRootURL)
// {
// WGLView view = new WGLView(canvas, 500, 500);
// return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view,
// new WGLTileSetLoader(rsrcRootURL));
// }
//
// protected static final int FRAME_DELAY = 15; // shoot for 66fps
// }
| import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.WebGL; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* The main entry point for our Jiggl/WebGL test viewer.
*/
public class TestViewer implements EntryPoint
{
// from interface EntryPoint
public void onModuleLoad ()
{
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth("500px");
canvas.setHeight("500px");
RootPanel.get("client").add(canvas); | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
// public class WebGL
// {
// public static Context create (Canvas canvas, String rsrcRootURL)
// {
// WGLView view = new WGLView(canvas, 500, 500);
// return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view,
// new WGLTileSetLoader(rsrcRootURL));
// }
//
// protected static final int FRAME_DELAY = 15; // shoot for 66fps
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/TestViewer.java
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.WebGL;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* The main entry point for our Jiggl/WebGL test viewer.
*/
public class TestViewer implements EntryPoint
{
// from interface EntryPoint
public void onModuleLoad ()
{
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth("500px");
canvas.setHeight("500px");
RootPanel.get("client").add(canvas); | Context ctx = WebGL.create(canvas, GWT.getModuleBaseURL()); |
threerings/jiggl | webgl/src/test/java/com/threerings/jiggl/test/TestViewer.java | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
// public class WebGL
// {
// public static Context create (Canvas canvas, String rsrcRootURL)
// {
// WGLView view = new WGLView(canvas, 500, 500);
// return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view,
// new WGLTileSetLoader(rsrcRootURL));
// }
//
// protected static final int FRAME_DELAY = 15; // shoot for 66fps
// }
| import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.WebGL; | //
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* The main entry point for our Jiggl/WebGL test viewer.
*/
public class TestViewer implements EntryPoint
{
// from interface EntryPoint
public void onModuleLoad ()
{
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth("500px");
canvas.setHeight("500px");
RootPanel.get("client").add(canvas); | // Path: core/src/main/java/com/threerings/jiggl/Context.java
// public class Context
// {
// /** Drives the boat. */
// public final Driver driver;
//
// /** Provides global renderer stuffs. */
// public final Renderer renderer;
//
// /** Displays the visibles. */
// public final View view;
//
// /** Loads the tilesets. */
// public final TileSetLoader tiles;
//
// /** Jiggles the properties. */
// public final Tweener tweener;
//
// protected Context (Driver driver, Renderer renderer, View view, TileSetLoader tiles)
// {
// this.driver = driver;
// this.renderer = renderer;
// this.view = view;
// this.tiles = tiles;
// this.tweener = new Tweener.Impl(driver);
// }
// }
//
// Path: webgl/src/main/java/com/threerings/jiggl/WebGL.java
// public class WebGL
// {
// public static Context create (Canvas canvas, String rsrcRootURL)
// {
// WGLView view = new WGLView(canvas, 500, 500);
// return new Context(new WGLDriver(view, FRAME_DELAY), view.renderer, view,
// new WGLTileSetLoader(rsrcRootURL));
// }
//
// protected static final int FRAME_DELAY = 15; // shoot for 66fps
// }
// Path: webgl/src/test/java/com/threerings/jiggl/test/TestViewer.java
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel;
import com.threerings.jiggl.Context;
import com.threerings.jiggl.WebGL;
//
// Jiggl WebGL - GWT + WebGL backend for 2D game framework
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.test;
/**
* The main entry point for our Jiggl/WebGL test viewer.
*/
public class TestViewer implements EntryPoint
{
// from interface EntryPoint
public void onModuleLoad ()
{
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth("500px");
canvas.setHeight("500px");
RootPanel.get("client").add(canvas); | Context ctx = WebGL.create(canvas, GWT.getModuleBaseURL()); |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/tween/Tweener.java | // Path: core/src/main/java/com/threerings/jiggl/util/Driver.java
// public abstract class Driver
// {
// /** An interface implemented by things that wish to tick. */
// public interface Tickable {
// /** Called on every frame tick with the time elapsed since app start, in seconds.
// * @return true if the tickable should remain registered, false otherwise. */
// boolean tick (float time);
// }
//
// /**
// * Registers a new tickable with the driver. The tickable may only be removed by returning
// * false from its {@link Tickable#tick} method.
// */
// public void addTickable (Tickable tickable)
// {
// _tickables.add(tickable);
// }
//
// /**
// * Ticks all registered tickables, then re-renders the view.
// */
// protected void tick (float time)
// {
// for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
// if (!_tickables.get(ii).tick(time)) {
// _tickables.remove(ii--);
// ll -= 1;
// }
// }
// _view.render();
// }
//
// protected Driver (View view)
// {
// _view = view;
// }
//
// protected final View _view;
// protected final List<Tickable> _tickables = new ArrayList<Tickable>();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import java.util.ArrayList;
import java.util.List;
import com.threerings.jiggl.util.Driver;
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz; | //
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Handles the animation of viz properties (position, rotation, etc.).
*/
public abstract class Tweener
{
/**
* Creates a tween on the specified value using the supplied interpolator.
*/ | // Path: core/src/main/java/com/threerings/jiggl/util/Driver.java
// public abstract class Driver
// {
// /** An interface implemented by things that wish to tick. */
// public interface Tickable {
// /** Called on every frame tick with the time elapsed since app start, in seconds.
// * @return true if the tickable should remain registered, false otherwise. */
// boolean tick (float time);
// }
//
// /**
// * Registers a new tickable with the driver. The tickable may only be removed by returning
// * false from its {@link Tickable#tick} method.
// */
// public void addTickable (Tickable tickable)
// {
// _tickables.add(tickable);
// }
//
// /**
// * Ticks all registered tickables, then re-renders the view.
// */
// protected void tick (float time)
// {
// for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
// if (!_tickables.get(ii).tick(time)) {
// _tickables.remove(ii--);
// ll -= 1;
// }
// }
// _view.render();
// }
//
// protected Driver (View view)
// {
// _view = view;
// }
//
// protected final View _view;
// protected final List<Tickable> _tickables = new ArrayList<Tickable>();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: core/src/main/java/com/threerings/jiggl/tween/Tweener.java
import java.util.ArrayList;
import java.util.List;
import com.threerings.jiggl.util.Driver;
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE
package com.threerings.jiggl.tween;
/**
* Handles the animation of viz properties (position, rotation, etc.).
*/
public abstract class Tweener
{
/**
* Creates a tween on the specified value using the supplied interpolator.
*/ | public Tween.One tween (Interpolator interp, Scalar value) |
threerings/jiggl | core/src/main/java/com/threerings/jiggl/tween/Tweener.java | // Path: core/src/main/java/com/threerings/jiggl/util/Driver.java
// public abstract class Driver
// {
// /** An interface implemented by things that wish to tick. */
// public interface Tickable {
// /** Called on every frame tick with the time elapsed since app start, in seconds.
// * @return true if the tickable should remain registered, false otherwise. */
// boolean tick (float time);
// }
//
// /**
// * Registers a new tickable with the driver. The tickable may only be removed by returning
// * false from its {@link Tickable#tick} method.
// */
// public void addTickable (Tickable tickable)
// {
// _tickables.add(tickable);
// }
//
// /**
// * Ticks all registered tickables, then re-renders the view.
// */
// protected void tick (float time)
// {
// for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
// if (!_tickables.get(ii).tick(time)) {
// _tickables.remove(ii--);
// ll -= 1;
// }
// }
// _view.render();
// }
//
// protected Driver (View view)
// {
// _view = view;
// }
//
// protected final View _view;
// protected final List<Tickable> _tickables = new ArrayList<Tickable>();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
| import java.util.ArrayList;
import java.util.List;
import com.threerings.jiggl.util.Driver;
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz; |
/**
* Creates an {@link Interpolator#EASE_OUT} tween on the specified values.
*/
public Tween.Two easeOut (Scalar x, Scalar y)
{
return tween(Interpolator.EASE_OUT, x, y);
}
/**
* Creates an {@link Interpolator#EASE_INOUT} tween on the specified values.
*/
public Tween.Two easeInOut (Scalar x, Scalar y)
{
return tween(Interpolator.EASE_INOUT, x, y);
}
/**
* Creates a tween that delays for the specified number of seconds.
*/
public Tween.Delay delay (float seconds)
{
return register(new Tween.Delay(seconds));
}
/**
* Returns a tweener which can be used to construct a tween that will be repeated until the
* supplied viz has been removed from its view. The viz must be added to the view in question
* before the next frame tick, or the cancellation will trigger immediately.
*/ | // Path: core/src/main/java/com/threerings/jiggl/util/Driver.java
// public abstract class Driver
// {
// /** An interface implemented by things that wish to tick. */
// public interface Tickable {
// /** Called on every frame tick with the time elapsed since app start, in seconds.
// * @return true if the tickable should remain registered, false otherwise. */
// boolean tick (float time);
// }
//
// /**
// * Registers a new tickable with the driver. The tickable may only be removed by returning
// * false from its {@link Tickable#tick} method.
// */
// public void addTickable (Tickable tickable)
// {
// _tickables.add(tickable);
// }
//
// /**
// * Ticks all registered tickables, then re-renders the view.
// */
// protected void tick (float time)
// {
// for (int ii = 0, ll = _tickables.size(); ii < ll; ii++) {
// if (!_tickables.get(ii).tick(time)) {
// _tickables.remove(ii--);
// ll -= 1;
// }
// }
// _view.render();
// }
//
// protected Driver (View view)
// {
// _view = view;
// }
//
// protected final View _view;
// protected final List<Tickable> _tickables = new ArrayList<Tickable>();
// }
//
// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
// /** The current value of this scalar. */
// public float value;
//
// /**
// * Creates a scalar with the specified initial value.
// */
// public Scalar (float init)
// {
// this.value = init;
// }
// }
//
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
// /** The x-component of our (container relative) translation. */
// public final Scalar x = new Scalar(0);
//
// /** The y-component of our (container relative) translation. */
// public final Scalar y = new Scalar(0);
//
// /** The x-component of our scale. */
// public final Scalar scaleX = new Scalar(1);
//
// /** The y-component of our scale. */
// public final Scalar scaleY = new Scalar(1);
//
// /** The rotation of this visible, in radians. */
// public final Scalar rotation = new Scalar(0);
//
// /**
// * Returns the width of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getWidth ();
//
// /**
// * Returns the height of this visible, including local scaling transformations (but not
// * rotation). Transformations applied by a parent of this visible are also not included.
// */
// public abstract float getHeight ();
//
// /**
// * Returns true if this viz is added to a view, false otherwise.
// */
// public abstract boolean isAdded ();
//
// /**
// * Called when this viz is added to a view. The viz should prepare any buffers or shader
// * programs it will need to render itself. Any exception thrown by this method will result in
// * the viz not being added to the view, so the viz should ensure that partially created
// * resources are cleaned up if it throws such an exception.
// */
// protected abstract void onAdd (View view);
//
// /**
// * Called when this viz is removed from a view. The viz should destroy any buffers or shader
// * programs it created in {@link #onAdd}.
// */
// protected abstract void onRemove ();
//
// /**
// * Instructs this viz to issue the rendering calls needed to visualize itself.
// */
// protected abstract void render ();
// }
// Path: core/src/main/java/com/threerings/jiggl/tween/Tweener.java
import java.util.ArrayList;
import java.util.List;
import com.threerings.jiggl.util.Driver;
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;
/**
* Creates an {@link Interpolator#EASE_OUT} tween on the specified values.
*/
public Tween.Two easeOut (Scalar x, Scalar y)
{
return tween(Interpolator.EASE_OUT, x, y);
}
/**
* Creates an {@link Interpolator#EASE_INOUT} tween on the specified values.
*/
public Tween.Two easeInOut (Scalar x, Scalar y)
{
return tween(Interpolator.EASE_INOUT, x, y);
}
/**
* Creates a tween that delays for the specified number of seconds.
*/
public Tween.Delay delay (float seconds)
{
return register(new Tween.Delay(seconds));
}
/**
* Returns a tweener which can be used to construct a tween that will be repeated until the
* supplied viz has been removed from its view. The viz must be added to the view in question
* before the next frame tick, or the cancellation will trigger immediately.
*/ | public Tweener repeat (Viz viz) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.