id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
600
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/io/Convert.java
Convert.exportSymbols
private static void exportSymbols(SymbolTable syms, String filename) { if (syms == null) { return; } try (PrintWriter out = new PrintWriter(new FileWriter(filename))) { for (ObjectIntCursor<String> sym : syms) { out.println(sym.key + "\t" + sym.value); } } catch (IOException e) { throw Throwables.propagate(e); } }
java
private static void exportSymbols(SymbolTable syms, String filename) { if (syms == null) { return; } try (PrintWriter out = new PrintWriter(new FileWriter(filename))) { for (ObjectIntCursor<String> sym : syms) { out.println(sym.key + "\t" + sym.value); } } catch (IOException e) { throw Throwables.propagate(e); } }
[ "private", "static", "void", "exportSymbols", "(", "SymbolTable", "syms", ",", "String", "filename", ")", "{", "if", "(", "syms", "==", "null", ")", "{", "return", ";", "}", "try", "(", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "FileWriter", "(", "filename", ")", ")", ")", "{", "for", "(", "ObjectIntCursor", "<", "String", ">", "sym", ":", "syms", ")", "{", "out", ".", "println", "(", "sym", ".", "key", "+", "\"\\t\"", "+", "sym", ".", "value", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "Throwables", ".", "propagate", "(", "e", ")", ";", "}", "}" ]
Exports a symbols' map to the openfst text format @param syms the symbols' map @param filename the the openfst's symbols filename
[ "Exports", "a", "symbols", "map", "to", "the", "openfst", "text", "format" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/io/Convert.java#L215-L227
601
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/io/Convert.java
Convert.importSymbols
private static Optional<MutableSymbolTable> importSymbols(String filename) { URL resource; try { resource = Resources.getResource(filename); } catch (IllegalArgumentException e) { return Optional.absent(); } return importSymbolsFrom(asCharSource(resource, Charsets.UTF_8)); }
java
private static Optional<MutableSymbolTable> importSymbols(String filename) { URL resource; try { resource = Resources.getResource(filename); } catch (IllegalArgumentException e) { return Optional.absent(); } return importSymbolsFrom(asCharSource(resource, Charsets.UTF_8)); }
[ "private", "static", "Optional", "<", "MutableSymbolTable", ">", "importSymbols", "(", "String", "filename", ")", "{", "URL", "resource", ";", "try", "{", "resource", "=", "Resources", ".", "getResource", "(", "filename", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "return", "Optional", ".", "absent", "(", ")", ";", "}", "return", "importSymbolsFrom", "(", "asCharSource", "(", "resource", ",", "Charsets", ".", "UTF_8", ")", ")", ";", "}" ]
Imports an openfst's symbols file @param filename the symbols' filename @return HashMap containing the impprted string-to-id mapping
[ "Imports", "an", "openfst", "s", "symbols", "file" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/io/Convert.java#L235-L244
602
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/semiring/UnionSemiring.java
UnionSemiring.makeForOrdering
public static <W, S extends GenericSemiring<W>> UnionSemiring<W, S> makeForOrdering(S weightSemiring, Ordering<W> ordering, MergeStrategy<W> merge) { return makeForOrdering(weightSemiring, ordering, merge, UnionMode.NORMAL); }
java
public static <W, S extends GenericSemiring<W>> UnionSemiring<W, S> makeForOrdering(S weightSemiring, Ordering<W> ordering, MergeStrategy<W> merge) { return makeForOrdering(weightSemiring, ordering, merge, UnionMode.NORMAL); }
[ "public", "static", "<", "W", ",", "S", "extends", "GenericSemiring", "<", "W", ">", ">", "UnionSemiring", "<", "W", ",", "S", ">", "makeForOrdering", "(", "S", "weightSemiring", ",", "Ordering", "<", "W", ">", "ordering", ",", "MergeStrategy", "<", "W", ">", "merge", ")", "{", "return", "makeForOrdering", "(", "weightSemiring", ",", "ordering", ",", "merge", ",", "UnionMode", ".", "NORMAL", ")", ";", "}" ]
Creates a new union semirng for the given underlying weight semiring and ordering @param weightSemiring underlying weight semiring @param ordering the ordering to govern elements in the union set; note that when ordering indicates that two elements are equal, that is when the merge strategy will be called to merge them @param merge the way two elements should be combined when the ordering strategy indicates they are equal @param <W> the underlying weight type @param <S> the underlying semiring type for W @return
[ "Creates", "a", "new", "union", "semirng", "for", "the", "given", "underlying", "weight", "semiring", "and", "ordering" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/semiring/UnionSemiring.java#L84-L88
603
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/semiring/GallicSemiring.java
GallicSemiring.commonDivisor
@Override public GallicWeight commonDivisor(GallicWeight a, GallicWeight b) { double newWeight = this.weightSemiring.plus(a.getWeight(), b.getWeight()); if (isZero(a)) { if (isZero(b)) { return zero; } if (b.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } // just the first char of b return GallicWeight.createSingleLabel(b.getLabels().get(0), newWeight); } else if (isZero(b)) { if (a.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } // just the first char of a return GallicWeight.createSingleLabel(a.getLabels().get(0), newWeight); } else { // neither are zero, emit one char if they share it, otherwise empty if (a.getLabels().isEmpty() || b.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } if (a.getLabels().get(0) == b.getLabels().get(0)) { return GallicWeight.createSingleLabel(a.getLabels().get(0), newWeight); } return GallicWeight.create(GallicWeight.EMPTY, newWeight); } }
java
@Override public GallicWeight commonDivisor(GallicWeight a, GallicWeight b) { double newWeight = this.weightSemiring.plus(a.getWeight(), b.getWeight()); if (isZero(a)) { if (isZero(b)) { return zero; } if (b.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } // just the first char of b return GallicWeight.createSingleLabel(b.getLabels().get(0), newWeight); } else if (isZero(b)) { if (a.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } // just the first char of a return GallicWeight.createSingleLabel(a.getLabels().get(0), newWeight); } else { // neither are zero, emit one char if they share it, otherwise empty if (a.getLabels().isEmpty() || b.getLabels().isEmpty()) { return GallicWeight.create(GallicWeight.EMPTY, newWeight); } if (a.getLabels().get(0) == b.getLabels().get(0)) { return GallicWeight.createSingleLabel(a.getLabels().get(0), newWeight); } return GallicWeight.create(GallicWeight.EMPTY, newWeight); } }
[ "@", "Override", "public", "GallicWeight", "commonDivisor", "(", "GallicWeight", "a", ",", "GallicWeight", "b", ")", "{", "double", "newWeight", "=", "this", ".", "weightSemiring", ".", "plus", "(", "a", ".", "getWeight", "(", ")", ",", "b", ".", "getWeight", "(", ")", ")", ";", "if", "(", "isZero", "(", "a", ")", ")", "{", "if", "(", "isZero", "(", "b", ")", ")", "{", "return", "zero", ";", "}", "if", "(", "b", ".", "getLabels", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "GallicWeight", ".", "create", "(", "GallicWeight", ".", "EMPTY", ",", "newWeight", ")", ";", "}", "// just the first char of b", "return", "GallicWeight", ".", "createSingleLabel", "(", "b", ".", "getLabels", "(", ")", ".", "get", "(", "0", ")", ",", "newWeight", ")", ";", "}", "else", "if", "(", "isZero", "(", "b", ")", ")", "{", "if", "(", "a", ".", "getLabels", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "GallicWeight", ".", "create", "(", "GallicWeight", ".", "EMPTY", ",", "newWeight", ")", ";", "}", "// just the first char of a", "return", "GallicWeight", ".", "createSingleLabel", "(", "a", ".", "getLabels", "(", ")", ".", "get", "(", "0", ")", ",", "newWeight", ")", ";", "}", "else", "{", "// neither are zero, emit one char if they share it, otherwise empty", "if", "(", "a", ".", "getLabels", "(", ")", ".", "isEmpty", "(", ")", "||", "b", ".", "getLabels", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "GallicWeight", ".", "create", "(", "GallicWeight", ".", "EMPTY", ",", "newWeight", ")", ";", "}", "if", "(", "a", ".", "getLabels", "(", ")", ".", "get", "(", "0", ")", "==", "b", ".", "getLabels", "(", ")", ".", "get", "(", "0", ")", ")", "{", "return", "GallicWeight", ".", "createSingleLabel", "(", "a", ".", "getLabels", "(", ")", ".", "get", "(", "0", ")", ",", "newWeight", ")", ";", "}", "return", "GallicWeight", ".", "create", "(", "GallicWeight", ".", "EMPTY", ",", "newWeight", ")", ";", "}", "}" ]
In this gallic semiring we restrict the common divisor to only be the first character in the stringweight In more general real-time FSTs that support substrings this could be longer, but openfst doesn't support this and we don't support this @param a @param b @return
[ "In", "this", "gallic", "semiring", "we", "restrict", "the", "common", "divisor", "to", "only", "be", "the", "first", "character", "in", "the", "stringweight", "In", "more", "general", "real", "-", "time", "FSTs", "that", "support", "substrings", "this", "could", "be", "longer", "but", "openfst", "doesn", "t", "support", "this", "and", "we", "don", "t", "support", "this" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/semiring/GallicSemiring.java#L202-L230
604
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/Reverse.java
Reverse.reverse
public static MutableFst reverse(Fst infst) { infst.throwIfInvalid(); MutableFst fst = ExtendFinal.apply(infst); Semiring semiring = fst.getSemiring(); MutableFst result = new MutableFst(fst.getStateCount(), semiring); result.setInputSymbolsAsCopy(fst.getInputSymbols()); result.setOutputSymbolsAsCopy(fst.getOutputSymbols()); MutableState[] stateMap = initStateMap(fst, semiring, result); for (int i = 0; i < fst.getStateCount(); i++) { State oldState = fst.getState(i); MutableState newState = stateMap[oldState.getId()]; for (int j = 0; j < oldState.getArcCount(); j++) { Arc oldArc = oldState.getArc(j); MutableState newNextState = stateMap[oldArc.getNextState().getId()]; double newWeight = semiring.reverse(oldArc.getWeight()); result.addArc(newNextState, oldArc.getIlabel(), oldArc.getOlabel(), newState, newWeight); } } return result; }
java
public static MutableFst reverse(Fst infst) { infst.throwIfInvalid(); MutableFst fst = ExtendFinal.apply(infst); Semiring semiring = fst.getSemiring(); MutableFst result = new MutableFst(fst.getStateCount(), semiring); result.setInputSymbolsAsCopy(fst.getInputSymbols()); result.setOutputSymbolsAsCopy(fst.getOutputSymbols()); MutableState[] stateMap = initStateMap(fst, semiring, result); for (int i = 0; i < fst.getStateCount(); i++) { State oldState = fst.getState(i); MutableState newState = stateMap[oldState.getId()]; for (int j = 0; j < oldState.getArcCount(); j++) { Arc oldArc = oldState.getArc(j); MutableState newNextState = stateMap[oldArc.getNextState().getId()]; double newWeight = semiring.reverse(oldArc.getWeight()); result.addArc(newNextState, oldArc.getIlabel(), oldArc.getOlabel(), newState, newWeight); } } return result; }
[ "public", "static", "MutableFst", "reverse", "(", "Fst", "infst", ")", "{", "infst", ".", "throwIfInvalid", "(", ")", ";", "MutableFst", "fst", "=", "ExtendFinal", ".", "apply", "(", "infst", ")", ";", "Semiring", "semiring", "=", "fst", ".", "getSemiring", "(", ")", ";", "MutableFst", "result", "=", "new", "MutableFst", "(", "fst", ".", "getStateCount", "(", ")", ",", "semiring", ")", ";", "result", ".", "setInputSymbolsAsCopy", "(", "fst", ".", "getInputSymbols", "(", ")", ")", ";", "result", ".", "setOutputSymbolsAsCopy", "(", "fst", ".", "getOutputSymbols", "(", ")", ")", ";", "MutableState", "[", "]", "stateMap", "=", "initStateMap", "(", "fst", ",", "semiring", ",", "result", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fst", ".", "getStateCount", "(", ")", ";", "i", "++", ")", "{", "State", "oldState", "=", "fst", ".", "getState", "(", "i", ")", ";", "MutableState", "newState", "=", "stateMap", "[", "oldState", ".", "getId", "(", ")", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "oldState", ".", "getArcCount", "(", ")", ";", "j", "++", ")", "{", "Arc", "oldArc", "=", "oldState", ".", "getArc", "(", "j", ")", ";", "MutableState", "newNextState", "=", "stateMap", "[", "oldArc", ".", "getNextState", "(", ")", ".", "getId", "(", ")", "]", ";", "double", "newWeight", "=", "semiring", ".", "reverse", "(", "oldArc", ".", "getWeight", "(", ")", ")", ";", "result", ".", "addArc", "(", "newNextState", ",", "oldArc", ".", "getIlabel", "(", ")", ",", "oldArc", ".", "getOlabel", "(", ")", ",", "newState", ",", "newWeight", ")", ";", "}", "}", "return", "result", ";", "}" ]
Reverses an fst @param infst the fst to reverse @return the reversed fst
[ "Reverses", "an", "fst" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/Reverse.java#L39-L62
605
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/ExtendFinal.java
ExtendFinal.apply
public static MutableFst apply(Fst fst) { fst.throwIfInvalid(); MutableFst copy = MutableFst.copyFrom(fst); Semiring semiring = copy.getSemiring(); ArrayList<MutableState> resultStates = initResultStates(copy, semiring); // Add a new single final MutableState newFinal = new MutableState(semiring.one()); copy.addState(newFinal); int epsILabel = copy.getInputSymbols().get(Fst.EPS); int epsOLabel = copy.getOutputSymbols().get(Fst.EPS); for (MutableState s : resultStates) { // add epsilon transition from the old final to the new one copy.addArc(s, epsILabel, epsOLabel, newFinal, s.getFinalWeight()); // set old state's weight to zero s.setFinalWeight(semiring.zero()); } return copy; }
java
public static MutableFst apply(Fst fst) { fst.throwIfInvalid(); MutableFst copy = MutableFst.copyFrom(fst); Semiring semiring = copy.getSemiring(); ArrayList<MutableState> resultStates = initResultStates(copy, semiring); // Add a new single final MutableState newFinal = new MutableState(semiring.one()); copy.addState(newFinal); int epsILabel = copy.getInputSymbols().get(Fst.EPS); int epsOLabel = copy.getOutputSymbols().get(Fst.EPS); for (MutableState s : resultStates) { // add epsilon transition from the old final to the new one copy.addArc(s, epsILabel, epsOLabel, newFinal, s.getFinalWeight()); // set old state's weight to zero s.setFinalWeight(semiring.zero()); } return copy; }
[ "public", "static", "MutableFst", "apply", "(", "Fst", "fst", ")", "{", "fst", ".", "throwIfInvalid", "(", ")", ";", "MutableFst", "copy", "=", "MutableFst", ".", "copyFrom", "(", "fst", ")", ";", "Semiring", "semiring", "=", "copy", ".", "getSemiring", "(", ")", ";", "ArrayList", "<", "MutableState", ">", "resultStates", "=", "initResultStates", "(", "copy", ",", "semiring", ")", ";", "// Add a new single final", "MutableState", "newFinal", "=", "new", "MutableState", "(", "semiring", ".", "one", "(", ")", ")", ";", "copy", ".", "addState", "(", "newFinal", ")", ";", "int", "epsILabel", "=", "copy", ".", "getInputSymbols", "(", ")", ".", "get", "(", "Fst", ".", "EPS", ")", ";", "int", "epsOLabel", "=", "copy", ".", "getOutputSymbols", "(", ")", ".", "get", "(", "Fst", ".", "EPS", ")", ";", "for", "(", "MutableState", "s", ":", "resultStates", ")", "{", "// add epsilon transition from the old final to the new one", "copy", ".", "addArc", "(", "s", ",", "epsILabel", ",", "epsOLabel", ",", "newFinal", ",", "s", ".", "getFinalWeight", "(", ")", ")", ";", "// set old state's weight to zero", "s", ".", "setFinalWeight", "(", "semiring", ".", "zero", "(", ")", ")", ";", "}", "return", "copy", ";", "}" ]
Creates a new FST that is a copy of the existing with a new signle final state It adds a new final state with a 0.0 (Semiring's 1) final wight and connects the current final states to it using epsilon transitions with weight equal to the original final state's weight. @param fst the input fst -- it will not be modified @return a mutable fst that is a copy of the input + extended with a single final
[ "Creates", "a", "new", "FST", "that", "is", "a", "copy", "of", "the", "existing", "with", "a", "new", "signle", "final", "state" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/ExtendFinal.java#L42-L60
606
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/utils/FstUtils.java
FstUtils.symbolTableEffectiveCopy
public static WriteableSymbolTable symbolTableEffectiveCopy(SymbolTable syms) { if (syms instanceof ImmutableSymbolTable) { return new UnionSymbolTable(syms); } if (syms instanceof UnionSymbolTable) { return UnionSymbolTable.copyFrom((UnionSymbolTable) syms); } if (syms instanceof FrozenSymbolTable) { return (FrozenSymbolTable) syms; } // maybe consider the size and if its "big" return a union of the mutable version? return new MutableSymbolTable(syms); }
java
public static WriteableSymbolTable symbolTableEffectiveCopy(SymbolTable syms) { if (syms instanceof ImmutableSymbolTable) { return new UnionSymbolTable(syms); } if (syms instanceof UnionSymbolTable) { return UnionSymbolTable.copyFrom((UnionSymbolTable) syms); } if (syms instanceof FrozenSymbolTable) { return (FrozenSymbolTable) syms; } // maybe consider the size and if its "big" return a union of the mutable version? return new MutableSymbolTable(syms); }
[ "public", "static", "WriteableSymbolTable", "symbolTableEffectiveCopy", "(", "SymbolTable", "syms", ")", "{", "if", "(", "syms", "instanceof", "ImmutableSymbolTable", ")", "{", "return", "new", "UnionSymbolTable", "(", "syms", ")", ";", "}", "if", "(", "syms", "instanceof", "UnionSymbolTable", ")", "{", "return", "UnionSymbolTable", ".", "copyFrom", "(", "(", "UnionSymbolTable", ")", "syms", ")", ";", "}", "if", "(", "syms", "instanceof", "FrozenSymbolTable", ")", "{", "return", "(", "FrozenSymbolTable", ")", "syms", ";", "}", "// maybe consider the size and if its \"big\" return a union of the mutable version?", "return", "new", "MutableSymbolTable", "(", "syms", ")", ";", "}" ]
Returns an "effective" copy of the given symbol table which might be a unioned symbol table that is just a mutable filter on top of a backing table which is treated as immutable NOTE a frozen symbol table indicates that you do NOT want writes to be allowed @param syms @return
[ "Returns", "an", "effective", "copy", "of", "the", "given", "symbol", "table", "which", "might", "be", "a", "unioned", "symbol", "table", "that", "is", "just", "a", "mutable", "filter", "on", "top", "of", "a", "backing", "table", "which", "is", "treated", "as", "immutable", "NOTE", "a", "frozen", "symbol", "table", "indicates", "that", "you", "do", "NOT", "want", "writes", "to", "be", "allowed" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/utils/FstUtils.java#L265-L277
607
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java
RemoveEpsilon.remove
public static MutableFst remove(Fst fst) { Preconditions.checkNotNull(fst); Preconditions.checkNotNull(fst.getSemiring()); Semiring semiring = fst.getSemiring(); MutableFst result = MutableFst.emptyWithCopyOfSymbols(fst); int iEps = fst.getInputSymbols().get(Fst.EPS); int oEps = fst.getOutputSymbols().get(Fst.EPS); @SuppressWarnings("unchecked") HashMap<Integer,Double>[] closure = new HashMap[fst.getStateCount()]; MutableState[] oldToNewStateMap = new MutableState[fst.getStateCount()]; State[] newToOldStateMap = new State[fst.getStateCount()]; initResultStates(fst, result, oldToNewStateMap, newToOldStateMap); addNonEpsilonArcs(fst, result, iEps, oEps, closure, oldToNewStateMap); // augment fst with arcs generated from epsilon moves. for (int i = 0; i < result.getStateCount(); i++) { MutableState state = result.getState(i); State oldState = newToOldStateMap[state.getId()]; if (closure[oldState.getId()] == null) { continue; } for (Integer pathFinalStateIndex : closure[oldState.getId()].keySet()) { State closureState = fst.getState(pathFinalStateIndex); if (semiring.isNotZero(closureState.getFinalWeight())) { Double prevWeight = getPathWeight(oldState, closureState, closure); Preconditions.checkNotNull(prevWeight, "problem with prev weight on closure from %s", oldState); state.setFinalWeight(semiring.plus(state.getFinalWeight(), semiring.times(prevWeight, closureState.getFinalWeight()))); } for (int j = 0; j < closureState.getArcCount(); j++) { Arc arc = closureState.getArc(j); if ((arc.getIlabel() != iEps) || (arc.getOlabel() != oEps)) { Double pathWeight = getPathWeight(oldState, closureState, closure); Preconditions.checkNotNull(pathWeight, "problem with prev weight on closure from %s", oldState); double newWeight = semiring.times(arc.getWeight(), pathWeight); MutableState nextState = oldToNewStateMap[arc.getNextState().getId()]; result.addArc(state, arc.getIlabel(), arc.getOlabel(), nextState, newWeight); } } } } Connect.apply(result); ArcSort.sortByInput(result); return result; }
java
public static MutableFst remove(Fst fst) { Preconditions.checkNotNull(fst); Preconditions.checkNotNull(fst.getSemiring()); Semiring semiring = fst.getSemiring(); MutableFst result = MutableFst.emptyWithCopyOfSymbols(fst); int iEps = fst.getInputSymbols().get(Fst.EPS); int oEps = fst.getOutputSymbols().get(Fst.EPS); @SuppressWarnings("unchecked") HashMap<Integer,Double>[] closure = new HashMap[fst.getStateCount()]; MutableState[] oldToNewStateMap = new MutableState[fst.getStateCount()]; State[] newToOldStateMap = new State[fst.getStateCount()]; initResultStates(fst, result, oldToNewStateMap, newToOldStateMap); addNonEpsilonArcs(fst, result, iEps, oEps, closure, oldToNewStateMap); // augment fst with arcs generated from epsilon moves. for (int i = 0; i < result.getStateCount(); i++) { MutableState state = result.getState(i); State oldState = newToOldStateMap[state.getId()]; if (closure[oldState.getId()] == null) { continue; } for (Integer pathFinalStateIndex : closure[oldState.getId()].keySet()) { State closureState = fst.getState(pathFinalStateIndex); if (semiring.isNotZero(closureState.getFinalWeight())) { Double prevWeight = getPathWeight(oldState, closureState, closure); Preconditions.checkNotNull(prevWeight, "problem with prev weight on closure from %s", oldState); state.setFinalWeight(semiring.plus(state.getFinalWeight(), semiring.times(prevWeight, closureState.getFinalWeight()))); } for (int j = 0; j < closureState.getArcCount(); j++) { Arc arc = closureState.getArc(j); if ((arc.getIlabel() != iEps) || (arc.getOlabel() != oEps)) { Double pathWeight = getPathWeight(oldState, closureState, closure); Preconditions.checkNotNull(pathWeight, "problem with prev weight on closure from %s", oldState); double newWeight = semiring.times(arc.getWeight(), pathWeight); MutableState nextState = oldToNewStateMap[arc.getNextState().getId()]; result.addArc(state, arc.getIlabel(), arc.getOlabel(), nextState, newWeight); } } } } Connect.apply(result); ArcSort.sortByInput(result); return result; }
[ "public", "static", "MutableFst", "remove", "(", "Fst", "fst", ")", "{", "Preconditions", ".", "checkNotNull", "(", "fst", ")", ";", "Preconditions", ".", "checkNotNull", "(", "fst", ".", "getSemiring", "(", ")", ")", ";", "Semiring", "semiring", "=", "fst", ".", "getSemiring", "(", ")", ";", "MutableFst", "result", "=", "MutableFst", ".", "emptyWithCopyOfSymbols", "(", "fst", ")", ";", "int", "iEps", "=", "fst", ".", "getInputSymbols", "(", ")", ".", "get", "(", "Fst", ".", "EPS", ")", ";", "int", "oEps", "=", "fst", ".", "getOutputSymbols", "(", ")", ".", "get", "(", "Fst", ".", "EPS", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "HashMap", "<", "Integer", ",", "Double", ">", "[", "]", "closure", "=", "new", "HashMap", "[", "fst", ".", "getStateCount", "(", ")", "]", ";", "MutableState", "[", "]", "oldToNewStateMap", "=", "new", "MutableState", "[", "fst", ".", "getStateCount", "(", ")", "]", ";", "State", "[", "]", "newToOldStateMap", "=", "new", "State", "[", "fst", ".", "getStateCount", "(", ")", "]", ";", "initResultStates", "(", "fst", ",", "result", ",", "oldToNewStateMap", ",", "newToOldStateMap", ")", ";", "addNonEpsilonArcs", "(", "fst", ",", "result", ",", "iEps", ",", "oEps", ",", "closure", ",", "oldToNewStateMap", ")", ";", "// augment fst with arcs generated from epsilon moves.", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "getStateCount", "(", ")", ";", "i", "++", ")", "{", "MutableState", "state", "=", "result", ".", "getState", "(", "i", ")", ";", "State", "oldState", "=", "newToOldStateMap", "[", "state", ".", "getId", "(", ")", "]", ";", "if", "(", "closure", "[", "oldState", ".", "getId", "(", ")", "]", "==", "null", ")", "{", "continue", ";", "}", "for", "(", "Integer", "pathFinalStateIndex", ":", "closure", "[", "oldState", ".", "getId", "(", ")", "]", ".", "keySet", "(", ")", ")", "{", "State", "closureState", "=", "fst", ".", "getState", "(", "pathFinalStateIndex", ")", ";", "if", "(", "semiring", ".", "isNotZero", "(", "closureState", ".", "getFinalWeight", "(", ")", ")", ")", "{", "Double", "prevWeight", "=", "getPathWeight", "(", "oldState", ",", "closureState", ",", "closure", ")", ";", "Preconditions", ".", "checkNotNull", "(", "prevWeight", ",", "\"problem with prev weight on closure from %s\"", ",", "oldState", ")", ";", "state", ".", "setFinalWeight", "(", "semiring", ".", "plus", "(", "state", ".", "getFinalWeight", "(", ")", ",", "semiring", ".", "times", "(", "prevWeight", ",", "closureState", ".", "getFinalWeight", "(", ")", ")", ")", ")", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "closureState", ".", "getArcCount", "(", ")", ";", "j", "++", ")", "{", "Arc", "arc", "=", "closureState", ".", "getArc", "(", "j", ")", ";", "if", "(", "(", "arc", ".", "getIlabel", "(", ")", "!=", "iEps", ")", "||", "(", "arc", ".", "getOlabel", "(", ")", "!=", "oEps", ")", ")", "{", "Double", "pathWeight", "=", "getPathWeight", "(", "oldState", ",", "closureState", ",", "closure", ")", ";", "Preconditions", ".", "checkNotNull", "(", "pathWeight", ",", "\"problem with prev weight on closure from %s\"", ",", "oldState", ")", ";", "double", "newWeight", "=", "semiring", ".", "times", "(", "arc", ".", "getWeight", "(", ")", ",", "pathWeight", ")", ";", "MutableState", "nextState", "=", "oldToNewStateMap", "[", "arc", ".", "getNextState", "(", ")", ".", "getId", "(", ")", "]", ";", "result", ".", "addArc", "(", "state", ",", "arc", ".", "getIlabel", "(", ")", ",", "arc", ".", "getOlabel", "(", ")", ",", "nextState", ",", "newWeight", ")", ";", "}", "}", "}", "}", "Connect", ".", "apply", "(", "result", ")", ";", "ArcSort", ".", "sortByInput", "(", "result", ")", ";", "return", "result", ";", "}" ]
Removes epsilon transitions from an fst. Returns a new epsilon-free fst and does not modify the original fst @param fst the fst to remove epsilon transitions from @return the epsilon-free fst
[ "Removes", "epsilon", "transitions", "from", "an", "fst", ".", "Returns", "a", "new", "epsilon", "-", "free", "fst", "and", "does", "not", "modify", "the", "original", "fst" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java#L43-L90
608
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java
RemoveEpsilon.put
private static void put(State fromState, State toState, double weight, HashMap<Integer,Double>[] closure) { HashMap<Integer,Double> maybe = closure[fromState.getId()]; if (maybe == null) { maybe = new HashMap<Integer,Double>(); closure[fromState.getId()] = maybe; } maybe.put(toState.getId(), weight); }
java
private static void put(State fromState, State toState, double weight, HashMap<Integer,Double>[] closure) { HashMap<Integer,Double> maybe = closure[fromState.getId()]; if (maybe == null) { maybe = new HashMap<Integer,Double>(); closure[fromState.getId()] = maybe; } maybe.put(toState.getId(), weight); }
[ "private", "static", "void", "put", "(", "State", "fromState", ",", "State", "toState", ",", "double", "weight", ",", "HashMap", "<", "Integer", ",", "Double", ">", "[", "]", "closure", ")", "{", "HashMap", "<", "Integer", ",", "Double", ">", "maybe", "=", "closure", "[", "fromState", ".", "getId", "(", ")", "]", ";", "if", "(", "maybe", "==", "null", ")", "{", "maybe", "=", "new", "HashMap", "<", "Integer", ",", "Double", ">", "(", ")", ";", "closure", "[", "fromState", ".", "getId", "(", ")", "]", "=", "maybe", ";", "}", "maybe", ".", "put", "(", "toState", ".", "getId", "(", ")", ",", "weight", ")", ";", "}" ]
Put a new state in the epsilon closure
[ "Put", "a", "new", "state", "in", "the", "epsilon", "closure" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java#L129-L136
609
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java
RemoveEpsilon.add
private static void add(State fromState, State toState, double weight, HashMap<Integer,Double>[] closure, Semiring semiring) { Double old = getPathWeight(fromState, toState, closure); if (old == null) { put(fromState, toState, weight, closure); } else { put(fromState, toState, semiring.plus(weight, old), closure); } }
java
private static void add(State fromState, State toState, double weight, HashMap<Integer,Double>[] closure, Semiring semiring) { Double old = getPathWeight(fromState, toState, closure); if (old == null) { put(fromState, toState, weight, closure); } else { put(fromState, toState, semiring.plus(weight, old), closure); } }
[ "private", "static", "void", "add", "(", "State", "fromState", ",", "State", "toState", ",", "double", "weight", ",", "HashMap", "<", "Integer", ",", "Double", ">", "[", "]", "closure", ",", "Semiring", "semiring", ")", "{", "Double", "old", "=", "getPathWeight", "(", "fromState", ",", "toState", ",", "closure", ")", ";", "if", "(", "old", "==", "null", ")", "{", "put", "(", "fromState", ",", "toState", ",", "weight", ",", "closure", ")", ";", "}", "else", "{", "put", "(", "fromState", ",", "toState", ",", "semiring", ".", "plus", "(", "weight", ",", "old", ")", ",", "closure", ")", ";", "}", "}" ]
Add a state in the epsilon closure
[ "Add", "a", "state", "in", "the", "epsilon", "closure" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java#L141-L149
610
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java
RemoveEpsilon.calculateClosure
private static void calculateClosure(Fst fst, State state, HashMap<Integer,Double>[] closure, Semiring semiring, int iEps, int oEps) { for (int j = 0; j < state.getArcCount(); j++) { Arc arc = state.getArc(j); if ((arc.getIlabel() != iEps) || (arc.getOlabel() != oEps)) { continue; } int nextStateId = arc.getNextState().getId(); if (closure[nextStateId] == null) { calculateClosure(fst, arc.getNextState(), closure, semiring, iEps, oEps); } HashMap<Integer,Double> closureEntry = closure[nextStateId]; if (closureEntry != null) { for (Integer pathFinalStateIndex : closureEntry.keySet()) { State pathFinalState = fst.getState(pathFinalStateIndex); Double prevPathWeight = getPathWeight(arc.getNextState(), pathFinalState, closure); Preconditions.checkNotNull(prevPathWeight, "prev arc %s never set in closure", arc); double newPathWeight = semiring.times(prevPathWeight, arc.getWeight()); add(state, pathFinalState, newPathWeight, closure, semiring); } } add(state, arc.getNextState(), arc.getWeight(), closure, semiring); } }
java
private static void calculateClosure(Fst fst, State state, HashMap<Integer,Double>[] closure, Semiring semiring, int iEps, int oEps) { for (int j = 0; j < state.getArcCount(); j++) { Arc arc = state.getArc(j); if ((arc.getIlabel() != iEps) || (arc.getOlabel() != oEps)) { continue; } int nextStateId = arc.getNextState().getId(); if (closure[nextStateId] == null) { calculateClosure(fst, arc.getNextState(), closure, semiring, iEps, oEps); } HashMap<Integer,Double> closureEntry = closure[nextStateId]; if (closureEntry != null) { for (Integer pathFinalStateIndex : closureEntry.keySet()) { State pathFinalState = fst.getState(pathFinalStateIndex); Double prevPathWeight = getPathWeight(arc.getNextState(), pathFinalState, closure); Preconditions.checkNotNull(prevPathWeight, "prev arc %s never set in closure", arc); double newPathWeight = semiring.times(prevPathWeight, arc.getWeight()); add(state, pathFinalState, newPathWeight, closure, semiring); } } add(state, arc.getNextState(), arc.getWeight(), closure, semiring); } }
[ "private", "static", "void", "calculateClosure", "(", "Fst", "fst", ",", "State", "state", ",", "HashMap", "<", "Integer", ",", "Double", ">", "[", "]", "closure", ",", "Semiring", "semiring", ",", "int", "iEps", ",", "int", "oEps", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "state", ".", "getArcCount", "(", ")", ";", "j", "++", ")", "{", "Arc", "arc", "=", "state", ".", "getArc", "(", "j", ")", ";", "if", "(", "(", "arc", ".", "getIlabel", "(", ")", "!=", "iEps", ")", "||", "(", "arc", ".", "getOlabel", "(", ")", "!=", "oEps", ")", ")", "{", "continue", ";", "}", "int", "nextStateId", "=", "arc", ".", "getNextState", "(", ")", ".", "getId", "(", ")", ";", "if", "(", "closure", "[", "nextStateId", "]", "==", "null", ")", "{", "calculateClosure", "(", "fst", ",", "arc", ".", "getNextState", "(", ")", ",", "closure", ",", "semiring", ",", "iEps", ",", "oEps", ")", ";", "}", "HashMap", "<", "Integer", ",", "Double", ">", "closureEntry", "=", "closure", "[", "nextStateId", "]", ";", "if", "(", "closureEntry", "!=", "null", ")", "{", "for", "(", "Integer", "pathFinalStateIndex", ":", "closureEntry", ".", "keySet", "(", ")", ")", "{", "State", "pathFinalState", "=", "fst", ".", "getState", "(", "pathFinalStateIndex", ")", ";", "Double", "prevPathWeight", "=", "getPathWeight", "(", "arc", ".", "getNextState", "(", ")", ",", "pathFinalState", ",", "closure", ")", ";", "Preconditions", ".", "checkNotNull", "(", "prevPathWeight", ",", "\"prev arc %s never set in closure\"", ",", "arc", ")", ";", "double", "newPathWeight", "=", "semiring", ".", "times", "(", "prevPathWeight", ",", "arc", ".", "getWeight", "(", ")", ")", ";", "add", "(", "state", ",", "pathFinalState", ",", "newPathWeight", ",", "closure", ",", "semiring", ")", ";", "}", "}", "add", "(", "state", ",", "arc", ".", "getNextState", "(", ")", ",", "arc", ".", "getWeight", "(", ")", ",", "closure", ",", "semiring", ")", ";", "}", "}" ]
Calculate the epsilon closure
[ "Calculate", "the", "epsilon", "closure" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java#L154-L177
611
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java
RemoveEpsilon.getPathWeight
@Nullable private static Double getPathWeight(State inState, State outState, HashMap<Integer,Double>[] closure) { if (closure[inState.getId()] != null) { return closure[inState.getId()].get(outState.getId()); } return null; }
java
@Nullable private static Double getPathWeight(State inState, State outState, HashMap<Integer,Double>[] closure) { if (closure[inState.getId()] != null) { return closure[inState.getId()].get(outState.getId()); } return null; }
[ "@", "Nullable", "private", "static", "Double", "getPathWeight", "(", "State", "inState", ",", "State", "outState", ",", "HashMap", "<", "Integer", ",", "Double", ">", "[", "]", "closure", ")", "{", "if", "(", "closure", "[", "inState", ".", "getId", "(", ")", "]", "!=", "null", ")", "{", "return", "closure", "[", "inState", ".", "getId", "(", ")", "]", ".", "get", "(", "outState", ".", "getId", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Get an epsilon path's cost in epsilon closure
[ "Get", "an", "epsilon", "path", "s", "cost", "in", "epsilon", "closure" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/operations/RemoveEpsilon.java#L182-L188
612
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/AbstractSymbolTable.java
AbstractSymbolTable.maxIdIn
public static int maxIdIn(SymbolTable table) { int max = 0; for (ObjectIntCursor<String> cursor : table) { max = Math.max(max, cursor.value); } return max; }
java
public static int maxIdIn(SymbolTable table) { int max = 0; for (ObjectIntCursor<String> cursor : table) { max = Math.max(max, cursor.value); } return max; }
[ "public", "static", "int", "maxIdIn", "(", "SymbolTable", "table", ")", "{", "int", "max", "=", "0", ";", "for", "(", "ObjectIntCursor", "<", "String", ">", "cursor", ":", "table", ")", "{", "max", "=", "Math", ".", "max", "(", "max", ",", "cursor", ".", "value", ")", ";", "}", "return", "max", ";", "}" ]
Returns the current max id mapped in this symbol table or 0 if this has no mappings @param table @return
[ "Returns", "the", "current", "max", "id", "mapped", "in", "this", "symbol", "table", "or", "0", "if", "this", "has", "no", "mappings" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/AbstractSymbolTable.java#L53-L59
613
steveash/jopenfst
src/main/java/com/github/steveash/jopenfst/AbstractSymbolTable.java
AbstractSymbolTable.get
@Override public int get(String symbol) { int id = symbolToId.getOrDefault(symbol, -1); if (id < 0) { throw new IllegalArgumentException("No symbol exists for key " + symbol); } return id; }
java
@Override public int get(String symbol) { int id = symbolToId.getOrDefault(symbol, -1); if (id < 0) { throw new IllegalArgumentException("No symbol exists for key " + symbol); } return id; }
[ "@", "Override", "public", "int", "get", "(", "String", "symbol", ")", "{", "int", "id", "=", "symbolToId", ".", "getOrDefault", "(", "symbol", ",", "-", "1", ")", ";", "if", "(", "id", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No symbol exists for key \"", "+", "symbol", ")", ";", "}", "return", "id", ";", "}" ]
Returns the id of the symbol or throws an exception if this symbol isnt in the table
[ "Returns", "the", "id", "of", "the", "symbol", "or", "throws", "an", "exception", "if", "this", "symbol", "isnt", "in", "the", "table" ]
4c675203015c1cfad2072556cb532b6edc73261d
https://github.com/steveash/jopenfst/blob/4c675203015c1cfad2072556cb532b6edc73261d/src/main/java/com/github/steveash/jopenfst/AbstractSymbolTable.java#L116-L123
614
Grasia/phatsim
phat-device-server/src/main/java/phat/server/PHATServerManager.java
PHATServerManager.getAddress
public static InetAddress getAddress() { try { return InetAddress.getByAddress(new byte[] {0,0,0,0}); /*for (Enumeration e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) { NetworkInterface ni = (NetworkInterface) e.nextElement(); System.out.println("NetworkInterface = " + ni.getName()); if (!ni.getName().contains("lo")) { for (Enumeration ee = ni.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } //System.out.println("Ip's: " + ip.getHostAddress()); } } } NetworkInterface lo = NetworkInterface.getByName("lo"); if (lo != null) { for (Enumeration ee = lo.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } } } NetworkInterface lo0 = NetworkInterface.getByName("lo0"); if (lo0 != null) { for (Enumeration ee = lo0.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } } }*/ } catch (Exception e) { System.err.println("Error"); } return null; }
java
public static InetAddress getAddress() { try { return InetAddress.getByAddress(new byte[] {0,0,0,0}); /*for (Enumeration e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) { NetworkInterface ni = (NetworkInterface) e.nextElement(); System.out.println("NetworkInterface = " + ni.getName()); if (!ni.getName().contains("lo")) { for (Enumeration ee = ni.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } //System.out.println("Ip's: " + ip.getHostAddress()); } } } NetworkInterface lo = NetworkInterface.getByName("lo"); if (lo != null) { for (Enumeration ee = lo.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } } } NetworkInterface lo0 = NetworkInterface.getByName("lo0"); if (lo0 != null) { for (Enumeration ee = lo0.getInetAddresses(); ee.hasMoreElements();) { InetAddress ip = (InetAddress) ee.nextElement(); if (ip instanceof Inet4Address && ip.getAddress() != null) { return ip; } } }*/ } catch (Exception e) { System.err.println("Error"); } return null; }
[ "public", "static", "InetAddress", "getAddress", "(", ")", "{", "try", "{", "return", "InetAddress", ".", "getByAddress", "(", "new", "byte", "[", "]", "{", "0", ",", "0", ",", "0", ",", "0", "}", ")", ";", "/*for (Enumeration e = NetworkInterface.getNetworkInterfaces();\n e.hasMoreElements();) {\n\n NetworkInterface ni = (NetworkInterface) e.nextElement();\n System.out.println(\"NetworkInterface = \" + ni.getName());\n if (!ni.getName().contains(\"lo\")) {\n for (Enumeration ee = ni.getInetAddresses(); ee.hasMoreElements();) {\n InetAddress ip = (InetAddress) ee.nextElement();\n if (ip instanceof Inet4Address && ip.getAddress() != null) {\n return ip;\n }\n //System.out.println(\"Ip's: \" + ip.getHostAddress());\n }\n }\n }\n NetworkInterface lo = NetworkInterface.getByName(\"lo\");\n if (lo != null) {\n for (Enumeration ee = lo.getInetAddresses(); ee.hasMoreElements();) {\n InetAddress ip = (InetAddress) ee.nextElement();\n if (ip instanceof Inet4Address && ip.getAddress() != null) {\n return ip;\n }\n }\n }\n \n NetworkInterface lo0 = NetworkInterface.getByName(\"lo0\");\n if (lo0 != null) {\n for (Enumeration ee = lo0.getInetAddresses(); ee.hasMoreElements();) {\n InetAddress ip = (InetAddress) ee.nextElement();\n if (ip instanceof Inet4Address && ip.getAddress() != null) {\n return ip;\n }\n }\n }*/", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"Error\"", ")", ";", "}", "return", "null", ";", "}" ]
This method returns the address of the machine. It is needed to successfully communicate with emulators hosted into other machines. @return
[ "This", "method", "returns", "the", "address", "of", "the", "machine", ".", "It", "is", "needed", "to", "successfully", "communicate", "with", "emulators", "hosted", "into", "other", "machines", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-device-server/src/main/java/phat/server/PHATServerManager.java#L239-L281
615
Grasia/phatsim
phat-env/src/main/java/phat/world/WorldAppState.java
WorldAppState.setCalendar
public void setCalendar(int year, int month, int dayOfMonth, int hour, int minute, int second) { this.year = year; this.month = month; this.dayOfMonth = dayOfMonth; this.hour = hour; this.minute = minute; this.second = second; this.createCalendar(); }
java
public void setCalendar(int year, int month, int dayOfMonth, int hour, int minute, int second) { this.year = year; this.month = month; this.dayOfMonth = dayOfMonth; this.hour = hour; this.minute = minute; this.second = second; this.createCalendar(); }
[ "public", "void", "setCalendar", "(", "int", "year", ",", "int", "month", ",", "int", "dayOfMonth", ",", "int", "hour", ",", "int", "minute", ",", "int", "second", ")", "{", "this", ".", "year", "=", "year", ";", "this", ".", "month", "=", "month", ";", "this", ".", "dayOfMonth", "=", "dayOfMonth", ";", "this", ".", "hour", "=", "hour", ";", "this", ".", "minute", "=", "minute", ";", "this", ".", "second", "=", "second", ";", "this", ".", "createCalendar", "(", ")", ";", "}" ]
It sets the simulation time. @param year @param month @param dayOfMonth @param hour @param minute @param second
[ "It", "sets", "the", "simulation", "time", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-env/src/main/java/phat/world/WorldAppState.java#L368-L376
616
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/helper/HistogramLikeValue.java
HistogramLikeValue.addValue
public void addValue(long newValue) { // keep a "total" timer for all values InApplicationMonitor.getInstance().addTimerMeasurement(timerName, newValue); // keep track of the current maximum value if (newValue > currentMaxValue) { currentMaxValue = newValue; } // select the bin to put this value in long binIndex; if (newValue > maxLimit) { binIndex = maxLimit / factor; } else { binIndex = newValue / factor; } // add the new value to the appropriate bin String binName = getBinName(binIndex); InApplicationMonitor.getInstance().incrementCounter(binName); }
java
public void addValue(long newValue) { // keep a "total" timer for all values InApplicationMonitor.getInstance().addTimerMeasurement(timerName, newValue); // keep track of the current maximum value if (newValue > currentMaxValue) { currentMaxValue = newValue; } // select the bin to put this value in long binIndex; if (newValue > maxLimit) { binIndex = maxLimit / factor; } else { binIndex = newValue / factor; } // add the new value to the appropriate bin String binName = getBinName(binIndex); InApplicationMonitor.getInstance().incrementCounter(binName); }
[ "public", "void", "addValue", "(", "long", "newValue", ")", "{", "// keep a \"total\" timer for all values\r", "InApplicationMonitor", ".", "getInstance", "(", ")", ".", "addTimerMeasurement", "(", "timerName", ",", "newValue", ")", ";", "// keep track of the current maximum value\r", "if", "(", "newValue", ">", "currentMaxValue", ")", "{", "currentMaxValue", "=", "newValue", ";", "}", "// select the bin to put this value in\r", "long", "binIndex", ";", "if", "(", "newValue", ">", "maxLimit", ")", "{", "binIndex", "=", "maxLimit", "/", "factor", ";", "}", "else", "{", "binIndex", "=", "newValue", "/", "factor", ";", "}", "// add the new value to the appropriate bin\r", "String", "binName", "=", "getBinName", "(", "binIndex", ")", ";", "InApplicationMonitor", ".", "getInstance", "(", ")", ".", "incrementCounter", "(", "binName", ")", ";", "}" ]
adds a new value to the InApplicationMonitor, grouping it into the appropriate bin. @param newValue the value that should be added
[ "adds", "a", "new", "value", "to", "the", "InApplicationMonitor", "grouping", "it", "into", "the", "appropriate", "bin", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/helper/HistogramLikeValue.java#L138-L158
617
Grasia/phatsim
phat-agents/src/main/java/phat/agents/automaton/conditions/AutomatonCondition.java
AutomatonCondition.evaluate
public boolean evaluate(Agent agent) { long t = agent.getAgentsAppState().getPHAInterface().getSimTime().getTimeInMillis(); if (t != timestamp) { timestamp = t; evaluation = simpleEvaluation(agent); } return evaluation; }
java
public boolean evaluate(Agent agent) { long t = agent.getAgentsAppState().getPHAInterface().getSimTime().getTimeInMillis(); if (t != timestamp) { timestamp = t; evaluation = simpleEvaluation(agent); } return evaluation; }
[ "public", "boolean", "evaluate", "(", "Agent", "agent", ")", "{", "long", "t", "=", "agent", ".", "getAgentsAppState", "(", ")", ".", "getPHAInterface", "(", ")", ".", "getSimTime", "(", ")", ".", "getTimeInMillis", "(", ")", ";", "if", "(", "t", "!=", "timestamp", ")", "{", "timestamp", "=", "t", ";", "evaluation", "=", "simpleEvaluation", "(", "agent", ")", ";", "}", "return", "evaluation", ";", "}" ]
It tells if the condition is met @param agent @return
[ "It", "tells", "if", "the", "condition", "is", "met" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-agents/src/main/java/phat/agents/automaton/conditions/AutomatonCondition.java#L42-L49
618
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/jmx/InApplicationMonitorJMXConnector.java
InApplicationMonitorJMXConnector.registerJMXStuff
private void registerJMXStuff() { LOG.info("registering InApplicationMonitorDynamicMBean on JMX server"); try { jmxBeanRegistrationHelper.registerMBeanOnJMX(this, "InApplicationMonitor", null); } catch (Exception e) { LOG.error("could not register MBean server : ", e); } }
java
private void registerJMXStuff() { LOG.info("registering InApplicationMonitorDynamicMBean on JMX server"); try { jmxBeanRegistrationHelper.registerMBeanOnJMX(this, "InApplicationMonitor", null); } catch (Exception e) { LOG.error("could not register MBean server : ", e); } }
[ "private", "void", "registerJMXStuff", "(", ")", "{", "LOG", ".", "info", "(", "\"registering InApplicationMonitorDynamicMBean on JMX server\"", ")", ";", "try", "{", "jmxBeanRegistrationHelper", ".", "registerMBeanOnJMX", "(", "this", ",", "\"InApplicationMonitor\"", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"could not register MBean server : \"", ",", "e", ")", ";", "}", "}" ]
registers the InApplicationMonitor as JMX MBean on the running JMX server - if no JMX server is running, one is started automagically.
[ "registers", "the", "InApplicationMonitor", "as", "JMX", "MBean", "on", "the", "running", "JMX", "server", "-", "if", "no", "JMX", "server", "is", "running", "one", "is", "started", "automagically", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/jmx/InApplicationMonitorJMXConnector.java#L113-L121
619
Grasia/phatsim
phat-core/src/main/java/phat/util/SpatialFactory.java
SpatialFactory.createCube
public static Geometry createCube(Vector3f dimensions, ColorRGBA color) { checkInit(); Box b = new Box(dimensions.getX(), dimensions.getY(), dimensions.getZ()); // create cube shape at the origin Geometry geom = new Geometry("Box", b); // create cube geometry from the shape Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material mat.setColor("Color", color); // set color of material to blue geom.setMaterial(mat); // set the cube's material return geom; }
java
public static Geometry createCube(Vector3f dimensions, ColorRGBA color) { checkInit(); Box b = new Box(dimensions.getX(), dimensions.getY(), dimensions.getZ()); // create cube shape at the origin Geometry geom = new Geometry("Box", b); // create cube geometry from the shape Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material mat.setColor("Color", color); // set color of material to blue geom.setMaterial(mat); // set the cube's material return geom; }
[ "public", "static", "Geometry", "createCube", "(", "Vector3f", "dimensions", ",", "ColorRGBA", "color", ")", "{", "checkInit", "(", ")", ";", "Box", "b", "=", "new", "Box", "(", "dimensions", ".", "getX", "(", ")", ",", "dimensions", ".", "getY", "(", ")", ",", "dimensions", ".", "getZ", "(", ")", ")", ";", "// create cube shape at the origin", "Geometry", "geom", "=", "new", "Geometry", "(", "\"Box\"", ",", "b", ")", ";", "// create cube geometry from the shape", "Material", "mat", "=", "new", "Material", "(", "assetManager", ",", "\"Common/MatDefs/Misc/Unshaded.j3md\"", ")", ";", "// create a simple material", "mat", ".", "setColor", "(", "\"Color\"", ",", "color", ")", ";", "// set color of material to blue", "geom", ".", "setMaterial", "(", "mat", ")", ";", "// set the cube's material", "return", "geom", ";", "}" ]
Creates a cube given its dimensions and its color @param dimensions @param color @return a cube Geometry
[ "Creates", "a", "cube", "given", "its", "dimensions", "and", "its", "color" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/SpatialFactory.java#L75-L85
620
Grasia/phatsim
phat-core/src/main/java/phat/util/SpatialFactory.java
SpatialFactory.createShape
public static Geometry createShape(String name, Mesh shape, ColorRGBA color) { checkInit(); Geometry g = new Geometry(name, shape); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", color); g.setMaterial(mat); return g; }
java
public static Geometry createShape(String name, Mesh shape, ColorRGBA color) { checkInit(); Geometry g = new Geometry(name, shape); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", color); g.setMaterial(mat); return g; }
[ "public", "static", "Geometry", "createShape", "(", "String", "name", ",", "Mesh", "shape", ",", "ColorRGBA", "color", ")", "{", "checkInit", "(", ")", ";", "Geometry", "g", "=", "new", "Geometry", "(", "name", ",", "shape", ")", ";", "Material", "mat", "=", "new", "Material", "(", "assetManager", ",", "\"Common/MatDefs/Misc/Unshaded.j3md\"", ")", ";", "mat", ".", "getAdditionalRenderState", "(", ")", ".", "setWireframe", "(", "true", ")", ";", "mat", ".", "setColor", "(", "\"Color\"", ",", "color", ")", ";", "g", ".", "setMaterial", "(", "mat", ")", ";", "return", "g", ";", "}" ]
Creates a geometry given its name, its mesh and its color @param name @param shape @param color @return
[ "Creates", "a", "geometry", "given", "its", "name", "its", "mesh", "and", "its", "color" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/SpatialFactory.java#L100-L109
621
Grasia/phatsim
phat-core/src/main/java/phat/util/SpatialFactory.java
SpatialFactory.attachAName
public static BitmapText attachAName(Node node, String name) { checkInit(); BitmapFont guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setName("BitmapText"); ch.setSize(guiFont.getCharSet().getRenderedSize() * 0.02f); ch.setText(name); // crosshairs ch.setColor(new ColorRGBA(0f, 0f, 0f, 1f)); ch.getLocalScale().divideLocal(node.getLocalScale()); // controlador para que los objetos miren a la cámara. BillboardControl control = new BillboardControl(); ch.addControl(control); node.attachChild(ch); return ch; }
java
public static BitmapText attachAName(Node node, String name) { checkInit(); BitmapFont guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setName("BitmapText"); ch.setSize(guiFont.getCharSet().getRenderedSize() * 0.02f); ch.setText(name); // crosshairs ch.setColor(new ColorRGBA(0f, 0f, 0f, 1f)); ch.getLocalScale().divideLocal(node.getLocalScale()); // controlador para que los objetos miren a la cámara. BillboardControl control = new BillboardControl(); ch.addControl(control); node.attachChild(ch); return ch; }
[ "public", "static", "BitmapText", "attachAName", "(", "Node", "node", ",", "String", "name", ")", "{", "checkInit", "(", ")", ";", "BitmapFont", "guiFont", "=", "assetManager", ".", "loadFont", "(", "\"Interface/Fonts/Default.fnt\"", ")", ";", "BitmapText", "ch", "=", "new", "BitmapText", "(", "guiFont", ",", "false", ")", ";", "ch", ".", "setName", "(", "\"BitmapText\"", ")", ";", "ch", ".", "setSize", "(", "guiFont", ".", "getCharSet", "(", ")", ".", "getRenderedSize", "(", ")", "*", "0.02f", ")", ";", "ch", ".", "setText", "(", "name", ")", ";", "// crosshairs", "ch", ".", "setColor", "(", "new", "ColorRGBA", "(", "0f", ",", "0f", ",", "0f", ",", "1f", ")", ")", ";", "ch", ".", "getLocalScale", "(", ")", ".", "divideLocal", "(", "node", ".", "getLocalScale", "(", ")", ")", ";", "// controlador para que los objetos miren a la cámara.", "BillboardControl", "control", "=", "new", "BillboardControl", "(", ")", ";", "ch", ".", "addControl", "(", "control", ")", ";", "node", ".", "attachChild", "(", "ch", ")", ";", "return", "ch", ";", "}" ]
Creates a geometry with the same name of the given node. It adds a controller called BillboardControl that turns the name of the node in order to look at the camera. Letter's size can be changed using setSize() method, the text with setText() method and the color using setColor() method. @param node @return
[ "Creates", "a", "geometry", "with", "the", "same", "name", "of", "the", "given", "node", ".", "It", "adds", "a", "controller", "called", "BillboardControl", "that", "turns", "the", "name", "of", "the", "node", "in", "order", "to", "look", "at", "the", "camera", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/SpatialFactory.java#L153-L168
622
Grasia/phatsim
phat-core/src/main/java/phat/util/PHATScreenshotAppState.java
PHATScreenshotAppState.setFilePath
public void setFilePath(String filePath) { this.filePath = filePath; if (!this.filePath.endsWith(File.separator)) { this.filePath += File.separator; } }
java
public void setFilePath(String filePath) { this.filePath = filePath; if (!this.filePath.endsWith(File.separator)) { this.filePath += File.separator; } }
[ "public", "void", "setFilePath", "(", "String", "filePath", ")", "{", "this", ".", "filePath", "=", "filePath", ";", "if", "(", "!", "this", ".", "filePath", ".", "endsWith", "(", "File", ".", "separator", ")", ")", "{", "this", ".", "filePath", "+=", "File", ".", "separator", ";", "}", "}" ]
Set the file path to store the screenshot. Include the seperator at the end of the path. Use an emptry string to use the application folder. Use NULL to use the system default storage folder. @param file File path to use to store the screenshot. Include the seperator at the end of the path.
[ "Set", "the", "file", "path", "to", "store", "the", "screenshot", ".", "Include", "the", "seperator", "at", "the", "end", "of", "the", "path", ".", "Use", "an", "emptry", "string", "to", "use", "the", "application", "folder", ".", "Use", "NULL", "to", "use", "the", "system", "default", "storage", "folder", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/PHATScreenshotAppState.java#L200-L205
623
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/CorePlugin.java
CorePlugin.addReportableObserver
public void addReportableObserver(final ReportableObserver reportableObserver) { reportableObservers.add(reportableObserver); LOGGER.info("registering new ReportableObserver (" + reportableObserver.getClass().getName() + ")"); // iterate over all reportables that are registered already and call the observer for each one of them reportInto(new ReportVisitor() { public void notifyReportableObserver(Reportable reportable) { reportableObserver.addNewReportable(reportable); } @Override public void reportCounter(Counter counter) { notifyReportableObserver(counter); } @Override public void reportTimer(Timer timer) { notifyReportableObserver(timer); } @Override public void reportStateValue(StateValueProvider stateValueProvider) { notifyReportableObserver(stateValueProvider); } @Override public void reportMultiValue(MultiValueProvider multiValueProvider) { notifyReportableObserver(multiValueProvider); } @Override public void reportHistorizableList(HistorizableList historizableList) { notifyReportableObserver(historizableList); } @Override public void reportVersion(Version version) { notifyReportableObserver(version); } }); }
java
public void addReportableObserver(final ReportableObserver reportableObserver) { reportableObservers.add(reportableObserver); LOGGER.info("registering new ReportableObserver (" + reportableObserver.getClass().getName() + ")"); // iterate over all reportables that are registered already and call the observer for each one of them reportInto(new ReportVisitor() { public void notifyReportableObserver(Reportable reportable) { reportableObserver.addNewReportable(reportable); } @Override public void reportCounter(Counter counter) { notifyReportableObserver(counter); } @Override public void reportTimer(Timer timer) { notifyReportableObserver(timer); } @Override public void reportStateValue(StateValueProvider stateValueProvider) { notifyReportableObserver(stateValueProvider); } @Override public void reportMultiValue(MultiValueProvider multiValueProvider) { notifyReportableObserver(multiValueProvider); } @Override public void reportHistorizableList(HistorizableList historizableList) { notifyReportableObserver(historizableList); } @Override public void reportVersion(Version version) { notifyReportableObserver(version); } }); }
[ "public", "void", "addReportableObserver", "(", "final", "ReportableObserver", "reportableObserver", ")", "{", "reportableObservers", ".", "add", "(", "reportableObserver", ")", ";", "LOGGER", ".", "info", "(", "\"registering new ReportableObserver (\"", "+", "reportableObserver", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\")\"", ")", ";", "// iterate over all reportables that are registered already and call the observer for each one of them", "reportInto", "(", "new", "ReportVisitor", "(", ")", "{", "public", "void", "notifyReportableObserver", "(", "Reportable", "reportable", ")", "{", "reportableObserver", ".", "addNewReportable", "(", "reportable", ")", ";", "}", "@", "Override", "public", "void", "reportCounter", "(", "Counter", "counter", ")", "{", "notifyReportableObserver", "(", "counter", ")", ";", "}", "@", "Override", "public", "void", "reportTimer", "(", "Timer", "timer", ")", "{", "notifyReportableObserver", "(", "timer", ")", ";", "}", "@", "Override", "public", "void", "reportStateValue", "(", "StateValueProvider", "stateValueProvider", ")", "{", "notifyReportableObserver", "(", "stateValueProvider", ")", ";", "}", "@", "Override", "public", "void", "reportMultiValue", "(", "MultiValueProvider", "multiValueProvider", ")", "{", "notifyReportableObserver", "(", "multiValueProvider", ")", ";", "}", "@", "Override", "public", "void", "reportHistorizableList", "(", "HistorizableList", "historizableList", ")", "{", "notifyReportableObserver", "(", "historizableList", ")", ";", "}", "@", "Override", "public", "void", "reportVersion", "(", "Version", "version", ")", "{", "notifyReportableObserver", "(", "version", ")", ";", "}", "}", ")", ";", "}" ]
adds a new ReportableObserver that wants to be notified about new Reportables that are registered on the InApplicationMonitor @param reportableObserver the class that wants to be notified
[ "adds", "a", "new", "ReportableObserver", "that", "wants", "to", "be", "notified", "about", "new", "Reportables", "that", "are", "registered", "on", "the", "InApplicationMonitor" ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/CorePlugin.java#L146-L189
624
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/CorePlugin.java
CorePlugin.getHistorizableList
HistorizableList getHistorizableList(final String name) { return historizableLists.get(name, new Monitors.Factory<HistorizableList>() { @Override public HistorizableList createMonitor() { return new HistorizableList(name, maxHistoryEntriesToKeep); } }); }
java
HistorizableList getHistorizableList(final String name) { return historizableLists.get(name, new Monitors.Factory<HistorizableList>() { @Override public HistorizableList createMonitor() { return new HistorizableList(name, maxHistoryEntriesToKeep); } }); }
[ "HistorizableList", "getHistorizableList", "(", "final", "String", "name", ")", "{", "return", "historizableLists", ".", "get", "(", "name", ",", "new", "Monitors", ".", "Factory", "<", "HistorizableList", ">", "(", ")", "{", "@", "Override", "public", "HistorizableList", "createMonitor", "(", ")", "{", "return", "new", "HistorizableList", "(", "name", ",", "maxHistoryEntriesToKeep", ")", ";", "}", "}", ")", ";", "}" ]
internally used method to retrieve or create and register a named HistorizableList. @param name of the required {@link de.is24.util.monitoring.HistorizableList} @return {@link de.is24.util.monitoring.HistorizableList} instance registered for the given name
[ "internally", "used", "method", "to", "retrieve", "or", "create", "and", "register", "a", "named", "HistorizableList", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/CorePlugin.java#L429-L436
625
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/InApplicationMonitor.java
InApplicationMonitor.initializeCounter
public void initializeCounter(String name) { String escapedName = keyHandler.handle(name); for (MonitorPlugin p : getPlugins()) { p.initializeCounter(escapedName); } }
java
public void initializeCounter(String name) { String escapedName = keyHandler.handle(name); for (MonitorPlugin p : getPlugins()) { p.initializeCounter(escapedName); } }
[ "public", "void", "initializeCounter", "(", "String", "name", ")", "{", "String", "escapedName", "=", "keyHandler", ".", "handle", "(", "name", ")", ";", "for", "(", "MonitorPlugin", "p", ":", "getPlugins", "(", ")", ")", "{", "p", ".", "initializeCounter", "(", "escapedName", ")", ";", "}", "}" ]
If you want to ensure existance of a counter, for example you want to prevent spelling errors in an operational monitoring configuration, you may initialize a counter using this method. The plugins will decide how to handle this initialization. @param name the name of the counter to be initialized
[ "If", "you", "want", "to", "ensure", "existance", "of", "a", "counter", "for", "example", "you", "want", "to", "prevent", "spelling", "errors", "in", "an", "operational", "monitoring", "configuration", "you", "may", "initialize", "a", "counter", "using", "this", "method", ".", "The", "plugins", "will", "decide", "how", "to", "handle", "this", "initialization", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/InApplicationMonitor.java#L212-L217
626
Grasia/phatsim
phat-agents/src/main/java/phat/agents/automaton/FSM.java
FSM.registerAllPossibleTransition
public void registerAllPossibleTransition(Automaton[] states) { for (int i = 0; i < states.length; i++) { for (int j = i; j < states.length; j++) { registerTransition(states[i], states[j]); registerTransition(states[j], states[i]); } } }
java
public void registerAllPossibleTransition(Automaton[] states) { for (int i = 0; i < states.length; i++) { for (int j = i; j < states.length; j++) { registerTransition(states[i], states[j]); registerTransition(states[j], states[i]); } } }
[ "public", "void", "registerAllPossibleTransition", "(", "Automaton", "[", "]", "states", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "i", ";", "j", "<", "states", ".", "length", ";", "j", "++", ")", "{", "registerTransition", "(", "states", "[", "i", "]", ",", "states", "[", "j", "]", ")", ";", "registerTransition", "(", "states", "[", "j", "]", ",", "states", "[", "i", "]", ")", ";", "}", "}", "}" ]
Pasandole un array genera todas las transiciones posibles entre los estados.
[ "Pasandole", "un", "array", "genera", "todas", "las", "transiciones", "posibles", "entre", "los", "estados", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-agents/src/main/java/phat/agents/automaton/FSM.java#L139-L146
627
Grasia/phatsim
phat-agents/src/main/java/phat/agents/automaton/FSM.java
FSM.possibleNextStates
public ArrayList<Transition> possibleNextStates(Automaton source) { ArrayList<Transition> r = possibleTransitions.get(source); if (r == null) { throw new UnsupportedOperationException( "Not transitions registered from " + source.getName() + ", automaton " + this.getName()); } ArrayList<Transition> activatedTransitions = new ArrayList<Transition>(); for (Transition t : r) { if (t.evaluate()) { activatedTransitions.add(t); } } ; return activatedTransitions; }
java
public ArrayList<Transition> possibleNextStates(Automaton source) { ArrayList<Transition> r = possibleTransitions.get(source); if (r == null) { throw new UnsupportedOperationException( "Not transitions registered from " + source.getName() + ", automaton " + this.getName()); } ArrayList<Transition> activatedTransitions = new ArrayList<Transition>(); for (Transition t : r) { if (t.evaluate()) { activatedTransitions.add(t); } } ; return activatedTransitions; }
[ "public", "ArrayList", "<", "Transition", ">", "possibleNextStates", "(", "Automaton", "source", ")", "{", "ArrayList", "<", "Transition", ">", "r", "=", "possibleTransitions", ".", "get", "(", "source", ")", ";", "if", "(", "r", "==", "null", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Not transitions registered from \"", "+", "source", ".", "getName", "(", ")", "+", "\", automaton \"", "+", "this", ".", "getName", "(", ")", ")", ";", "}", "ArrayList", "<", "Transition", ">", "activatedTransitions", "=", "new", "ArrayList", "<", "Transition", ">", "(", ")", ";", "for", "(", "Transition", "t", ":", "r", ")", "{", "if", "(", "t", ".", "evaluate", "(", ")", ")", "{", "activatedTransitions", ".", "add", "(", "t", ")", ";", "}", "}", ";", "return", "activatedTransitions", ";", "}" ]
Dado un estado se devuelve una lista con los posibles estados que le siguen en el protocolo. @param source @return
[ "Dado", "un", "estado", "se", "devuelve", "una", "lista", "con", "los", "posibles", "estados", "que", "le", "siguen", "en", "el", "protocolo", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-agents/src/main/java/phat/agents/automaton/FSM.java#L163-L179
628
Grasia/phatsim
phat-bodies/src/main/java/phat/body/sensing/hearing/GrammarFacilitator.java
GrammarFacilitator.createFile
public boolean createFile() { try { try (FileWriter newDic = new FileWriter(path + "/" + name + "." + FILE_EXTENSION); BufferedWriter bufWriter = new BufferedWriter(newDic)) { bufWriter.write(HEAD); if (sentences.size() > 0) { bufWriter.write("public <sentence> = (" + sentences.get(0)); for (int i = 1; i < sentences.size(); i++) { bufWriter.write(" | " + sentences.get(i)); } bufWriter.write(" );\n"); } bufWriter.flush(); } return true; } catch (IOException ex) { Logger.getLogger(GrammarFacilitator.class.getName()).log(Level.SEVERE, null, ex); } return false; }
java
public boolean createFile() { try { try (FileWriter newDic = new FileWriter(path + "/" + name + "." + FILE_EXTENSION); BufferedWriter bufWriter = new BufferedWriter(newDic)) { bufWriter.write(HEAD); if (sentences.size() > 0) { bufWriter.write("public <sentence> = (" + sentences.get(0)); for (int i = 1; i < sentences.size(); i++) { bufWriter.write(" | " + sentences.get(i)); } bufWriter.write(" );\n"); } bufWriter.flush(); } return true; } catch (IOException ex) { Logger.getLogger(GrammarFacilitator.class.getName()).log(Level.SEVERE, null, ex); } return false; }
[ "public", "boolean", "createFile", "(", ")", "{", "try", "{", "try", "(", "FileWriter", "newDic", "=", "new", "FileWriter", "(", "path", "+", "\"/\"", "+", "name", "+", "\".\"", "+", "FILE_EXTENSION", ")", ";", "BufferedWriter", "bufWriter", "=", "new", "BufferedWriter", "(", "newDic", ")", ")", "{", "bufWriter", ".", "write", "(", "HEAD", ")", ";", "if", "(", "sentences", ".", "size", "(", ")", ">", "0", ")", "{", "bufWriter", ".", "write", "(", "\"public <sentence> = (\"", "+", "sentences", ".", "get", "(", "0", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "sentences", ".", "size", "(", ")", ";", "i", "++", ")", "{", "bufWriter", ".", "write", "(", "\" | \"", "+", "sentences", ".", "get", "(", "i", ")", ")", ";", "}", "bufWriter", ".", "write", "(", "\" );\\n\"", ")", ";", "}", "bufWriter", ".", "flush", "(", ")", ";", "}", "return", "true", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "Logger", ".", "getLogger", "(", "GrammarFacilitator", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "}", "return", "false", ";", "}" ]
Create a file with the JSGF Grammar @return
[ "Create", "a", "file", "with", "the", "JSGF", "Grammar" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-bodies/src/main/java/phat/body/sensing/hearing/GrammarFacilitator.java#L70-L89
629
Tirasa/ConnIdCSVDirBundle
src/main/java/net/tirasa/connid/bundles/csvdir/CSVDirConfiguration.java
CSVDirConfiguration.validate
@Override public void validate() { // make sure the encoding is set.. if (this.encoding == null) { throw new IllegalArgumentException("File encoding must not be null!"); } //make sure it's a valid charset Charset.forName(this.encoding); // make sure the delimiter and the text qualifier are not the same.. if (this.textQualifier == this.fieldDelimiter) { throw new IllegalStateException("Field delimiter and text qualifier can not be equal!"); } // make sure file mask is set.. if (StringUtil.isBlank(this.fileMask)) { throw new IllegalArgumentException("File mask must not be blank!"); } // make sure source path is set.. if (StringUtil.isBlank(this.sourcePath)) { throw new IllegalArgumentException("Source path must not be blank!"); } // make sure keyColumnName is set.. if (this.keyColumnNames == null || this.keyColumnNames.length == 0) { throw new IllegalArgumentException("key column name must not be blank!"); } // make sure fields is set.. if (this.fields == null || this.fields.length == 0) { throw new IllegalArgumentException("Column names must not be blank!"); } // make sure key separator is set.. if (StringUtil.isBlank(this.keyseparator)) { throw new IllegalArgumentException("File mask must not be blank!"); } }
java
@Override public void validate() { // make sure the encoding is set.. if (this.encoding == null) { throw new IllegalArgumentException("File encoding must not be null!"); } //make sure it's a valid charset Charset.forName(this.encoding); // make sure the delimiter and the text qualifier are not the same.. if (this.textQualifier == this.fieldDelimiter) { throw new IllegalStateException("Field delimiter and text qualifier can not be equal!"); } // make sure file mask is set.. if (StringUtil.isBlank(this.fileMask)) { throw new IllegalArgumentException("File mask must not be blank!"); } // make sure source path is set.. if (StringUtil.isBlank(this.sourcePath)) { throw new IllegalArgumentException("Source path must not be blank!"); } // make sure keyColumnName is set.. if (this.keyColumnNames == null || this.keyColumnNames.length == 0) { throw new IllegalArgumentException("key column name must not be blank!"); } // make sure fields is set.. if (this.fields == null || this.fields.length == 0) { throw new IllegalArgumentException("Column names must not be blank!"); } // make sure key separator is set.. if (StringUtil.isBlank(this.keyseparator)) { throw new IllegalArgumentException("File mask must not be blank!"); } }
[ "@", "Override", "public", "void", "validate", "(", ")", "{", "// make sure the encoding is set..\r", "if", "(", "this", ".", "encoding", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"File encoding must not be null!\"", ")", ";", "}", "//make sure it's a valid charset\r", "Charset", ".", "forName", "(", "this", ".", "encoding", ")", ";", "// make sure the delimiter and the text qualifier are not the same..\r", "if", "(", "this", ".", "textQualifier", "==", "this", ".", "fieldDelimiter", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Field delimiter and text qualifier can not be equal!\"", ")", ";", "}", "// make sure file mask is set..\r", "if", "(", "StringUtil", ".", "isBlank", "(", "this", ".", "fileMask", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"File mask must not be blank!\"", ")", ";", "}", "// make sure source path is set..\r", "if", "(", "StringUtil", ".", "isBlank", "(", "this", ".", "sourcePath", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Source path must not be blank!\"", ")", ";", "}", "// make sure keyColumnName is set..\r", "if", "(", "this", ".", "keyColumnNames", "==", "null", "||", "this", ".", "keyColumnNames", ".", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"key column name must not be blank!\"", ")", ";", "}", "// make sure fields is set..\r", "if", "(", "this", ".", "fields", "==", "null", "||", "this", ".", "fields", ".", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Column names must not be blank!\"", ")", ";", "}", "// make sure key separator is set..\r", "if", "(", "StringUtil", ".", "isBlank", "(", "this", ".", "keyseparator", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"File mask must not be blank!\"", ")", ";", "}", "}" ]
Determine if all the values are valid. @throws IllegalArgumentException if encoding or fileMask or sourcePath or keyColumnName or passwordColumnName or deleteColumnName or fields is blank or null. @throws IllegalStateException if the text qualifier and field delimiter are the same. @throws RuntimeException if the file is not found. @throws java.nio.charset.IllegalCharsetNameException if the character set name is invalid
[ "Determine", "if", "all", "the", "values", "are", "valid", "." ]
22262da2641087598d6d869295314ae3bd940c1a
https://github.com/Tirasa/ConnIdCSVDirBundle/blob/22262da2641087598d6d869295314ae3bd940c1a/src/main/java/net/tirasa/connid/bundles/csvdir/CSVDirConfiguration.java#L359-L398
630
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/ExampleReportGenerator.java
ExampleReportGenerator.run
public void run() { try { StringBuffer sb = this.generateReport(); ingenias.editor.Log.getInstance().log("Statistics of usage of meta-model entities and relationships"); ingenias.editor.Log.getInstance().log("Name Number of times it appears"); ingenias.editor.Log.getInstance().log("---- --------------------------"); ingenias.editor.Log.getInstance().log(sb.toString()); } catch (Exception ex) { ex.printStackTrace(); } }
java
public void run() { try { StringBuffer sb = this.generateReport(); ingenias.editor.Log.getInstance().log("Statistics of usage of meta-model entities and relationships"); ingenias.editor.Log.getInstance().log("Name Number of times it appears"); ingenias.editor.Log.getInstance().log("---- --------------------------"); ingenias.editor.Log.getInstance().log(sb.toString()); } catch (Exception ex) { ex.printStackTrace(); } }
[ "public", "void", "run", "(", ")", "{", "try", "{", "StringBuffer", "sb", "=", "this", ".", "generateReport", "(", ")", ";", "ingenias", ".", "editor", ".", "Log", ".", "getInstance", "(", ")", ".", "log", "(", "\"Statistics of usage of meta-model entities and relationships\"", ")", ";", "ingenias", ".", "editor", ".", "Log", ".", "getInstance", "(", ")", ".", "log", "(", "\"Name Number of times it appears\"", ")", ";", "ingenias", ".", "editor", ".", "Log", ".", "getInstance", "(", ")", ".", "log", "(", "\"---- --------------------------\"", ")", ";", "ingenias", ".", "editor", ".", "Log", ".", "getInstance", "(", ")", ".", "log", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
It creates stats of usage by traversing diagrams of your specification. Resulting report appears in standard output or in the IDE
[ "It", "creates", "stats", "of", "usage", "by", "traversing", "diagrams", "of", "your", "specification", ".", "Resulting", "report", "appears", "in", "standard", "output", "or", "in", "the", "IDE" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/ExampleReportGenerator.java#L81-L92
631
Grasia/phatsim
phat-audio/src/main/java/phat/audio/Advanced.java
Advanced.main
public static void main(String[] args) { Advanced app = new Advanced(); AppSettings settings = new AppSettings(true); settings.setAudioRenderer(AurellemSystemDelegate.SEND); JmeSystem.setSystemDelegate(new AurellemSystemDelegate()); app.setSettings(settings); app.setShowSettings(false); app.setPauseOnLostFocus(false); /*try { //Capture.captureVideo(app, File.createTempFile("advanced",".avi")); Capture.captureAudio(app, File.createTempFile("advanced",".wav")); } catch (IOException e) {e.printStackTrace();}*/ app.start(); }
java
public static void main(String[] args) { Advanced app = new Advanced(); AppSettings settings = new AppSettings(true); settings.setAudioRenderer(AurellemSystemDelegate.SEND); JmeSystem.setSystemDelegate(new AurellemSystemDelegate()); app.setSettings(settings); app.setShowSettings(false); app.setPauseOnLostFocus(false); /*try { //Capture.captureVideo(app, File.createTempFile("advanced",".avi")); Capture.captureAudio(app, File.createTempFile("advanced",".wav")); } catch (IOException e) {e.printStackTrace();}*/ app.start(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Advanced", "app", "=", "new", "Advanced", "(", ")", ";", "AppSettings", "settings", "=", "new", "AppSettings", "(", "true", ")", ";", "settings", ".", "setAudioRenderer", "(", "AurellemSystemDelegate", ".", "SEND", ")", ";", "JmeSystem", ".", "setSystemDelegate", "(", "new", "AurellemSystemDelegate", "(", ")", ")", ";", "app", ".", "setSettings", "(", "settings", ")", ";", "app", ".", "setShowSettings", "(", "false", ")", ";", "app", ".", "setPauseOnLostFocus", "(", "false", ")", ";", "/*try {\n //Capture.captureVideo(app, File.createTempFile(\"advanced\",\".avi\"));\n Capture.captureAudio(app, File.createTempFile(\"advanced\",\".wav\"));\n }\n catch (IOException e) {e.printStackTrace();}*/", "app", ".", "start", "(", ")", ";", "}" ]
You will see three grey cubes, a blue sphere, and a path which circles each cube. The blue sphere is generating a constant monotone sound as it moves along the track. Each cube is listening for sound; when a cube hears sound whose intensity is greater than a certain threshold, it changes its color from grey to green. Each cube is also saving whatever it hears to a file. The scene from the perspective of the viewer is also saved to a video file. When you listen to each of the sound files alongside the video, the sound will get louder when the sphere approaches the cube that generated that sound file. This shows that each listener is hearing the world from its own perspective.
[ "You", "will", "see", "three", "grey", "cubes", "a", "blue", "sphere", "and", "a", "path", "which", "circles", "each", "cube", ".", "The", "blue", "sphere", "is", "generating", "a", "constant", "monotone", "sound", "as", "it", "moves", "along", "the", "track", ".", "Each", "cube", "is", "listening", "for", "sound", ";", "when", "a", "cube", "hears", "sound", "whose", "intensity", "is", "greater", "than", "a", "certain", "threshold", "it", "changes", "its", "color", "from", "grey", "to", "green", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-audio/src/main/java/phat/audio/Advanced.java#L94-L110
632
Grasia/phatsim
phat-core/src/main/java/phat/sensors/Sensor.java
Sensor.add
public void add(SensorListener sensorListener) { if (!listeners.contains(sensorListener)) { listeners.add(sensorListener); if (!isEnabled()) { setEnabled(true); } } }
java
public void add(SensorListener sensorListener) { if (!listeners.contains(sensorListener)) { listeners.add(sensorListener); if (!isEnabled()) { setEnabled(true); } } }
[ "public", "void", "add", "(", "SensorListener", "sensorListener", ")", "{", "if", "(", "!", "listeners", ".", "contains", "(", "sensorListener", ")", ")", "{", "listeners", ".", "add", "(", "sensorListener", ")", ";", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "setEnabled", "(", "true", ")", ";", "}", "}", "}" ]
Adds a sensor listener and the sensor is enabled if it was disabled in order to feed data to the listener @param sensorListener
[ "Adds", "a", "sensor", "listener", "and", "the", "sensor", "is", "enabled", "if", "it", "was", "disabled", "in", "order", "to", "feed", "data", "to", "the", "listener" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/sensors/Sensor.java#L62-L69
633
Grasia/phatsim
phat-core/src/main/java/phat/sensors/Sensor.java
Sensor.remove
public void remove(SensorListener sensorListener) { listeners.remove(sensorListener); if (listeners.isEmpty() && isEnabled()) { setEnabled(false); } }
java
public void remove(SensorListener sensorListener) { listeners.remove(sensorListener); if (listeners.isEmpty() && isEnabled()) { setEnabled(false); } }
[ "public", "void", "remove", "(", "SensorListener", "sensorListener", ")", "{", "listeners", ".", "remove", "(", "sensorListener", ")", ";", "if", "(", "listeners", ".", "isEmpty", "(", ")", "&&", "isEnabled", "(", ")", ")", "{", "setEnabled", "(", "false", ")", ";", "}", "}" ]
Removes a listener and if there are not more listener the sensor is disabled in order to save resources @param sensorListener
[ "Removes", "a", "listener", "and", "if", "there", "are", "not", "more", "listener", "the", "sensor", "is", "disabled", "in", "order", "to", "save", "resources" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/sensors/Sensor.java#L85-L90
634
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/tools/VirtualMachineMBeans.java
VirtualMachineMBeans.getDeadlockedThreads
public Set<String> getDeadlockedThreads() { final long[] threadIds = threads.findDeadlockedThreads(); if (threadIds != null) { final Set<String> threads = new HashSet<String>(); for (ThreadInfo info : this.threads.getThreadInfo(threadIds, MAX_STACK_TRACE_DEPTH)) { final StringBuilder stackTrace = new StringBuilder(); for (StackTraceElement element : info.getStackTrace()) { stackTrace.append("\t at ").append(element.toString()).append('\n'); } threads.add( String.format( "%s locked on %s (owned by %s):\n%s", info.getThreadName(), info.getLockName(), info.getLockOwnerName(), stackTrace.toString())); } return Collections.unmodifiableSet(threads); } return Collections.emptySet(); }
java
public Set<String> getDeadlockedThreads() { final long[] threadIds = threads.findDeadlockedThreads(); if (threadIds != null) { final Set<String> threads = new HashSet<String>(); for (ThreadInfo info : this.threads.getThreadInfo(threadIds, MAX_STACK_TRACE_DEPTH)) { final StringBuilder stackTrace = new StringBuilder(); for (StackTraceElement element : info.getStackTrace()) { stackTrace.append("\t at ").append(element.toString()).append('\n'); } threads.add( String.format( "%s locked on %s (owned by %s):\n%s", info.getThreadName(), info.getLockName(), info.getLockOwnerName(), stackTrace.toString())); } return Collections.unmodifiableSet(threads); } return Collections.emptySet(); }
[ "public", "Set", "<", "String", ">", "getDeadlockedThreads", "(", ")", "{", "final", "long", "[", "]", "threadIds", "=", "threads", ".", "findDeadlockedThreads", "(", ")", ";", "if", "(", "threadIds", "!=", "null", ")", "{", "final", "Set", "<", "String", ">", "threads", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "ThreadInfo", "info", ":", "this", ".", "threads", ".", "getThreadInfo", "(", "threadIds", ",", "MAX_STACK_TRACE_DEPTH", ")", ")", "{", "final", "StringBuilder", "stackTrace", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "StackTraceElement", "element", ":", "info", ".", "getStackTrace", "(", ")", ")", "{", "stackTrace", ".", "append", "(", "\"\\t at \"", ")", ".", "append", "(", "element", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "threads", ".", "add", "(", "String", ".", "format", "(", "\"%s locked on %s (owned by %s):\\n%s\"", ",", "info", ".", "getThreadName", "(", ")", ",", "info", ".", "getLockName", "(", ")", ",", "info", ".", "getLockOwnerName", "(", ")", ",", "stackTrace", ".", "toString", "(", ")", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "threads", ")", ";", "}", "return", "Collections", ".", "emptySet", "(", ")", ";", "}" ]
Returns a set of strings describing deadlocked threads, if any are deadlocked. @return a set of any deadlocked threads
[ "Returns", "a", "set", "of", "strings", "describing", "deadlocked", "threads", "if", "any", "are", "deadlocked", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/tools/VirtualMachineMBeans.java#L125-L145
635
Grasia/phatsim
phat-devices/src/main/java/phat/sensors/accelerometer/AccelerometerControl.java
AccelerometerControl.filter
private void filter(Vector3f acc) { float threshold = 15f; if (acc.x > threshold) { acc.x = threshold; } else if(acc.x < -threshold) { acc.x = -threshold; } if (acc.y > threshold) { acc.y = threshold; } else if(acc.y < -threshold) { acc.y = -threshold; } if (acc.z > threshold) { acc.z = threshold; } else if(acc.z < -threshold) { acc.z = -threshold; } }
java
private void filter(Vector3f acc) { float threshold = 15f; if (acc.x > threshold) { acc.x = threshold; } else if(acc.x < -threshold) { acc.x = -threshold; } if (acc.y > threshold) { acc.y = threshold; } else if(acc.y < -threshold) { acc.y = -threshold; } if (acc.z > threshold) { acc.z = threshold; } else if(acc.z < -threshold) { acc.z = -threshold; } }
[ "private", "void", "filter", "(", "Vector3f", "acc", ")", "{", "float", "threshold", "=", "15f", ";", "if", "(", "acc", ".", "x", ">", "threshold", ")", "{", "acc", ".", "x", "=", "threshold", ";", "}", "else", "if", "(", "acc", ".", "x", "<", "-", "threshold", ")", "{", "acc", ".", "x", "=", "-", "threshold", ";", "}", "if", "(", "acc", ".", "y", ">", "threshold", ")", "{", "acc", ".", "y", "=", "threshold", ";", "}", "else", "if", "(", "acc", ".", "y", "<", "-", "threshold", ")", "{", "acc", ".", "y", "=", "-", "threshold", ";", "}", "if", "(", "acc", ".", "z", ">", "threshold", ")", "{", "acc", ".", "z", "=", "threshold", ";", "}", "else", "if", "(", "acc", ".", "z", "<", "-", "threshold", ")", "{", "acc", ".", "z", "=", "-", "threshold", ";", "}", "}" ]
remove pointed values
[ "remove", "pointed", "values" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-devices/src/main/java/phat/sensors/accelerometer/AccelerometerControl.java#L218-L235
636
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java
GenericMonitoringWrapper.wrapObject
@SuppressWarnings("unchecked") public static <E> E wrapObject(final Class<E> clazz, final Object target, final TimingReporter timingReporter) { return (E) Proxy.newProxyInstance(GenericMonitoringWrapper.class.getClassLoader(), new Class[] { clazz }, new GenericMonitoringWrapper<E>(clazz, target, timingReporter)); }
java
@SuppressWarnings("unchecked") public static <E> E wrapObject(final Class<E> clazz, final Object target, final TimingReporter timingReporter) { return (E) Proxy.newProxyInstance(GenericMonitoringWrapper.class.getClassLoader(), new Class[] { clazz }, new GenericMonitoringWrapper<E>(clazz, target, timingReporter)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "E", ">", "E", "wrapObject", "(", "final", "Class", "<", "E", ">", "clazz", ",", "final", "Object", "target", ",", "final", "TimingReporter", "timingReporter", ")", "{", "return", "(", "E", ")", "Proxy", ".", "newProxyInstance", "(", "GenericMonitoringWrapper", ".", "class", ".", "getClassLoader", "(", ")", ",", "new", "Class", "[", "]", "{", "clazz", "}", ",", "new", "GenericMonitoringWrapper", "<", "E", ">", "(", "clazz", ",", "target", ",", "timingReporter", ")", ")", ";", "}" ]
Wraps the given object and returns the reporting proxy. Uses the given timing reporter to report timings. @param <E> the type of the public interface of the wrapped object @param clazz the class object to the interface @param target the object to wrap @param timingReporter the reporter to report timing information to @return the monitoring wrapper
[ "Wraps", "the", "given", "object", "and", "returns", "the", "reporting", "proxy", ".", "Uses", "the", "given", "timing", "reporter", "to", "report", "timings", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java#L86-L91
637
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java
GenericMonitoringWrapper.invoke
@Override public Object invoke(Object proxy, Method method, Object[] args) /* CSOFF: IllegalThrows */ throws Throwable /* CSON: IllegalThrows */ { final long startTime = System.currentTimeMillis(); Object result = null; try { result = method.invoke(target, args); if ((result != null) && !method.getReturnType().equals(Void.TYPE) && method.getReturnType().isInterface()) { result = wrapObject(method.getReturnType(), result, reporter); } } catch (InvocationTargetException t) { if (t.getCause() != null) { throw t.getCause(); } } finally { final long endTime = System.currentTimeMillis(); reporter.reportTimedOperation(targetClass, method, startTime, endTime); } return result; }
java
@Override public Object invoke(Object proxy, Method method, Object[] args) /* CSOFF: IllegalThrows */ throws Throwable /* CSON: IllegalThrows */ { final long startTime = System.currentTimeMillis(); Object result = null; try { result = method.invoke(target, args); if ((result != null) && !method.getReturnType().equals(Void.TYPE) && method.getReturnType().isInterface()) { result = wrapObject(method.getReturnType(), result, reporter); } } catch (InvocationTargetException t) { if (t.getCause() != null) { throw t.getCause(); } } finally { final long endTime = System.currentTimeMillis(); reporter.reportTimedOperation(targetClass, method, startTime, endTime); } return result; }
[ "@", "Override", "public", "Object", "invoke", "(", "Object", "proxy", ",", "Method", "method", ",", "Object", "[", "]", "args", ")", "/* CSOFF: IllegalThrows */", "throws", "Throwable", "/* CSON: IllegalThrows */", "{", "final", "long", "startTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "Object", "result", "=", "null", ";", "try", "{", "result", "=", "method", ".", "invoke", "(", "target", ",", "args", ")", ";", "if", "(", "(", "result", "!=", "null", ")", "&&", "!", "method", ".", "getReturnType", "(", ")", ".", "equals", "(", "Void", ".", "TYPE", ")", "&&", "method", ".", "getReturnType", "(", ")", ".", "isInterface", "(", ")", ")", "{", "result", "=", "wrapObject", "(", "method", ".", "getReturnType", "(", ")", ",", "result", ",", "reporter", ")", ";", "}", "}", "catch", "(", "InvocationTargetException", "t", ")", "{", "if", "(", "t", ".", "getCause", "(", ")", "!=", "null", ")", "{", "throw", "t", ".", "getCause", "(", ")", ";", "}", "}", "finally", "{", "final", "long", "endTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "reporter", ".", "reportTimedOperation", "(", "targetClass", ",", "method", ",", "startTime", ",", "endTime", ")", ";", "}", "return", "result", ";", "}" ]
Handles method invocations on the generated proxy. Measures the time needed to execute the given method on the wrapped object. @see java.lang.reflect.InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])
[ "Handles", "method", "invocations", "on", "the", "generated", "proxy", ".", "Measures", "the", "time", "needed", "to", "execute", "the", "given", "method", "on", "the", "wrapped", "object", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java#L117-L136
638
Grasia/phatsim
phat-agents/src/main/java/phat/agents/filters/FSMSymptomEvolution.java
FSMSymptomEvolution.areNextStatesAvailable
private boolean areNextStatesAvailable(Automaton source) { ArrayList<Transition> r = possibleTransitions.get(source); if (r != null) { for (Transition t : r) { if (t.evaluate()) { return true; } } } return false; }
java
private boolean areNextStatesAvailable(Automaton source) { ArrayList<Transition> r = possibleTransitions.get(source); if (r != null) { for (Transition t : r) { if (t.evaluate()) { return true; } } } return false; }
[ "private", "boolean", "areNextStatesAvailable", "(", "Automaton", "source", ")", "{", "ArrayList", "<", "Transition", ">", "r", "=", "possibleTransitions", ".", "get", "(", "source", ")", ";", "if", "(", "r", "!=", "null", ")", "{", "for", "(", "Transition", "t", ":", "r", ")", "{", "if", "(", "t", ".", "evaluate", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Return true if there are transitions available as true. @param source @return
[ "Return", "true", "if", "there", "are", "transitions", "available", "as", "true", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-agents/src/main/java/phat/agents/filters/FSMSymptomEvolution.java#L148-L158
639
Grasia/phatsim
phat-core/src/main/java/phat/util/PHATUtils.java
PHATUtils.isMultiListener
public static boolean isMultiListener(String[] args) { for(int i = 0; i < args.length; i++) { if(args[i].equals("-ml")) { return true; } } return false; }
java
public static boolean isMultiListener(String[] args) { for(int i = 0; i < args.length; i++) { if(args[i].equals("-ml")) { return true; } } return false; }
[ "public", "static", "boolean", "isMultiListener", "(", "String", "[", "]", "args", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "args", "[", "i", "]", ".", "equals", "(", "\"-ml\"", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if arguments contains multilisterner option "-lm" @param args @return
[ "Checks", "if", "arguments", "contains", "multilisterner", "option", "-", "lm" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/PHATUtils.java#L78-L85
640
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.getAscendantsOfRole
public static Collection<? extends GraphEntity> getAscendantsOfRole( GraphEntity ge) { Vector<GraphEntity> allAscendants = new Vector<GraphEntity>(); try { Vector<GraphEntity> ascendants = Utils.getRelatedElementsVector(ge, "ARoleInheritance", "ARoleInheritancetarget"); while (!ascendants.isEmpty()) { allAscendants.addAll(ascendants); ascendants.clear(); for (GraphEntity ascendant : allAscendants) { ascendants.addAll(Utils.getRelatedElementsVector(ascendant, "ARoleInheritance", "ARoleInheritancetarget")); } ascendants.removeAll(allAscendants); } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return allAscendants; }
java
public static Collection<? extends GraphEntity> getAscendantsOfRole( GraphEntity ge) { Vector<GraphEntity> allAscendants = new Vector<GraphEntity>(); try { Vector<GraphEntity> ascendants = Utils.getRelatedElementsVector(ge, "ARoleInheritance", "ARoleInheritancetarget"); while (!ascendants.isEmpty()) { allAscendants.addAll(ascendants); ascendants.clear(); for (GraphEntity ascendant : allAscendants) { ascendants.addAll(Utils.getRelatedElementsVector(ascendant, "ARoleInheritance", "ARoleInheritancetarget")); } ascendants.removeAll(allAscendants); } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return allAscendants; }
[ "public", "static", "Collection", "<", "?", "extends", "GraphEntity", ">", "getAscendantsOfRole", "(", "GraphEntity", "ge", ")", "{", "Vector", "<", "GraphEntity", ">", "allAscendants", "=", "new", "Vector", "<", "GraphEntity", ">", "(", ")", ";", "try", "{", "Vector", "<", "GraphEntity", ">", "ascendants", "=", "Utils", ".", "getRelatedElementsVector", "(", "ge", ",", "\"ARoleInheritance\"", ",", "\"ARoleInheritancetarget\"", ")", ";", "while", "(", "!", "ascendants", ".", "isEmpty", "(", ")", ")", "{", "allAscendants", ".", "addAll", "(", "ascendants", ")", ";", "ascendants", ".", "clear", "(", ")", ";", "for", "(", "GraphEntity", "ascendant", ":", "allAscendants", ")", "{", "ascendants", ".", "addAll", "(", "Utils", ".", "getRelatedElementsVector", "(", "ascendant", ",", "\"ARoleInheritance\"", ",", "\"ARoleInheritancetarget\"", ")", ")", ";", "}", "ascendants", ".", "removeAll", "(", "allAscendants", ")", ";", "}", "}", "catch", "(", "NullEntity", "e", ")", "{", "// TODO Auto-generated catch block", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "allAscendants", ";", "}" ]
It obtains all ascendants of a role through the ARoleInheritance relationship. @param ge @return
[ "It", "obtains", "all", "ascendants", "of", "a", "role", "through", "the", "ARoleInheritance", "relationship", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L159-L182
641
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.getRelatedElementsVector
public static Vector getRelatedElementsVector(String pathname, GraphEntity element, String relationshipname, String role) throws NullEntity { Vector rels = element.getAllRelationships(); Enumeration enumeration = rels.elements(); Vector related = new Vector(); while (enumeration.hasMoreElements()) { GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); String[] path = gr.getGraph().getPath(); boolean found = false; for (int k = 0; k < path.length && !found; k++) { found = path[k].toLowerCase().indexOf(pathname) >= 0; } if (found && gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase() .equals(role.toLowerCase())) { related.add(roles[k].getPlayer()); } } } } return new Vector(new HashSet(related)); }
java
public static Vector getRelatedElementsVector(String pathname, GraphEntity element, String relationshipname, String role) throws NullEntity { Vector rels = element.getAllRelationships(); Enumeration enumeration = rels.elements(); Vector related = new Vector(); while (enumeration.hasMoreElements()) { GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); String[] path = gr.getGraph().getPath(); boolean found = false; for (int k = 0; k < path.length && !found; k++) { found = path[k].toLowerCase().indexOf(pathname) >= 0; } if (found && gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase() .equals(role.toLowerCase())) { related.add(roles[k].getPlayer()); } } } } return new Vector(new HashSet(related)); }
[ "public", "static", "Vector", "getRelatedElementsVector", "(", "String", "pathname", ",", "GraphEntity", "element", ",", "String", "relationshipname", ",", "String", "role", ")", "throws", "NullEntity", "{", "Vector", "rels", "=", "element", ".", "getAllRelationships", "(", ")", ";", "Enumeration", "enumeration", "=", "rels", ".", "elements", "(", ")", ";", "Vector", "related", "=", "new", "Vector", "(", ")", ";", "while", "(", "enumeration", ".", "hasMoreElements", "(", ")", ")", "{", "GraphRelationship", "gr", "=", "(", "GraphRelationship", ")", "enumeration", ".", "nextElement", "(", ")", ";", "String", "[", "]", "path", "=", "gr", ".", "getGraph", "(", ")", ".", "getPath", "(", ")", ";", "boolean", "found", "=", "false", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "path", ".", "length", "&&", "!", "found", ";", "k", "++", ")", "{", "found", "=", "path", "[", "k", "]", ".", "toLowerCase", "(", ")", ".", "indexOf", "(", "pathname", ")", ">=", "0", ";", "}", "if", "(", "found", "&&", "gr", ".", "getType", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "relationshipname", ".", "toLowerCase", "(", ")", ")", ")", "{", "GraphRole", "[", "]", "roles", "=", "gr", ".", "getRoles", "(", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "roles", ".", "length", ";", "k", "++", ")", "{", "if", "(", "roles", "[", "k", "]", ".", "getName", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "role", ".", "toLowerCase", "(", ")", ")", ")", "{", "related", ".", "add", "(", "roles", "[", "k", "]", ".", "getPlayer", "(", ")", ")", ";", "}", "}", "}", "}", "return", "new", "Vector", "(", "new", "HashSet", "(", "related", ")", ")", ";", "}" ]
It obtains all elements related with "element" with "relationshipname" and occupying the extreme "role. Also, the association where these elements appear must be allocated in the package whose pathname matches the "pathname" parameter @param pathname Part of a path name. It will force located relationships to belong to concrete sets of diagrams allocated in concrete packages @param element The element to be studied @param relationshipname The name of the relationship which will be studied @param role The name of the extreme of the relationship that has to be studied @return A list of entities. @throws NullEntity
[ "It", "obtains", "all", "elements", "related", "with", "element", "with", "relationshipname", "and", "occupying", "the", "extreme", "role", ".", "Also", "the", "association", "where", "these", "elements", "appear", "must", "be", "allocated", "in", "the", "package", "whose", "pathname", "matches", "the", "pathname", "parameter" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L397-L424
642
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.toGEArray
public static GraphEntity[] toGEArray(Object[] o) { GraphEntity[] result = new GraphEntity[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
java
public static GraphEntity[] toGEArray(Object[] o) { GraphEntity[] result = new GraphEntity[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
[ "public", "static", "GraphEntity", "[", "]", "toGEArray", "(", "Object", "[", "]", "o", ")", "{", "GraphEntity", "[", "]", "result", "=", "new", "GraphEntity", "[", "o", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "o", ",", "0", ",", "result", ",", "0", ",", "o", ".", "length", ")", ";", "return", "result", ";", "}" ]
It casts an array of objets to an array of GraphEntity @param o the array of objects @return
[ "It", "casts", "an", "array", "of", "objets", "to", "an", "array", "of", "GraphEntity" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L659-L663
643
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.toGRArray
public static GraphRelationship[] toGRArray(Object[] o) { GraphRelationship[] result = new GraphRelationship[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
java
public static GraphRelationship[] toGRArray(Object[] o) { GraphRelationship[] result = new GraphRelationship[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
[ "public", "static", "GraphRelationship", "[", "]", "toGRArray", "(", "Object", "[", "]", "o", ")", "{", "GraphRelationship", "[", "]", "result", "=", "new", "GraphRelationship", "[", "o", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "o", ",", "0", ",", "result", ",", "0", ",", "o", ".", "length", ")", ";", "return", "result", ";", "}" ]
It casts an array of objets to an array of GraphRelationship @param o the array of objects @return
[ "It", "casts", "an", "array", "of", "objets", "to", "an", "array", "of", "GraphRelationship" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L671-L675
644
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.toGRoArray
public static GraphRole[] toGRoArray(Object[] o) { GraphRole[] result = new GraphRole[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
java
public static GraphRole[] toGRoArray(Object[] o) { GraphRole[] result = new GraphRole[o.length]; System.arraycopy(o, 0, result, 0, o.length); return result; }
[ "public", "static", "GraphRole", "[", "]", "toGRoArray", "(", "Object", "[", "]", "o", ")", "{", "GraphRole", "[", "]", "result", "=", "new", "GraphRole", "[", "o", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "o", ",", "0", ",", "result", ",", "0", ",", "o", ".", "length", ")", ";", "return", "result", ";", "}" ]
It casts an array of objets to an array of GraphRole @param o the array of objects @return
[ "It", "casts", "an", "array", "of", "objets", "to", "an", "array", "of", "GraphRole" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L683-L687
645
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.generateEntitiesOfType
public static GraphEntity[] generateEntitiesOfType(String type, Browser browser) throws NotInitialised { Graph[] gs = browser.getGraphs(); Sequences p = new Sequences(); GraphEntity[] ges = browser.getAllEntities(); HashSet actors = new HashSet(); for (int k = 0; k < ges.length; k++) { if (ges[k].getType().equals(type)) { actors.add(ges[k]); } } return toGEArray(actors.toArray()); }
java
public static GraphEntity[] generateEntitiesOfType(String type, Browser browser) throws NotInitialised { Graph[] gs = browser.getGraphs(); Sequences p = new Sequences(); GraphEntity[] ges = browser.getAllEntities(); HashSet actors = new HashSet(); for (int k = 0; k < ges.length; k++) { if (ges[k].getType().equals(type)) { actors.add(ges[k]); } } return toGEArray(actors.toArray()); }
[ "public", "static", "GraphEntity", "[", "]", "generateEntitiesOfType", "(", "String", "type", ",", "Browser", "browser", ")", "throws", "NotInitialised", "{", "Graph", "[", "]", "gs", "=", "browser", ".", "getGraphs", "(", ")", ";", "Sequences", "p", "=", "new", "Sequences", "(", ")", ";", "GraphEntity", "[", "]", "ges", "=", "browser", ".", "getAllEntities", "(", ")", ";", "HashSet", "actors", "=", "new", "HashSet", "(", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "ges", ".", "length", ";", "k", "++", ")", "{", "if", "(", "ges", "[", "k", "]", ".", "getType", "(", ")", ".", "equals", "(", "type", ")", ")", "{", "actors", ".", "add", "(", "ges", "[", "k", "]", ")", ";", "}", "}", "return", "toGEArray", "(", "actors", ".", "toArray", "(", ")", ")", ";", "}" ]
It obtains all entities in the specification whose type represented as string is the same as the string passed as parameter @param type The type the application is looking for @return @throws NotInitialised
[ "It", "obtains", "all", "entities", "in", "the", "specification", "whose", "type", "represented", "as", "string", "is", "the", "same", "as", "the", "string", "passed", "as", "parameter" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L697-L709
646
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.getRelatedElementsRoles
public static GraphRole[] getRelatedElementsRoles(GraphEntity element, String relationshipname, String role) { Vector rels = element.getAllRelationships(); Enumeration enumeration = rels.elements(); Vector related = new Vector(); while (enumeration.hasMoreElements()) { GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); if (gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase() .equals(role.toLowerCase())) { related.add(roles[k]); } } } } return toGRoArray(related.toArray()); }
java
public static GraphRole[] getRelatedElementsRoles(GraphEntity element, String relationshipname, String role) { Vector rels = element.getAllRelationships(); Enumeration enumeration = rels.elements(); Vector related = new Vector(); while (enumeration.hasMoreElements()) { GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); if (gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase() .equals(role.toLowerCase())) { related.add(roles[k]); } } } } return toGRoArray(related.toArray()); }
[ "public", "static", "GraphRole", "[", "]", "getRelatedElementsRoles", "(", "GraphEntity", "element", ",", "String", "relationshipname", ",", "String", "role", ")", "{", "Vector", "rels", "=", "element", ".", "getAllRelationships", "(", ")", ";", "Enumeration", "enumeration", "=", "rels", ".", "elements", "(", ")", ";", "Vector", "related", "=", "new", "Vector", "(", ")", ";", "while", "(", "enumeration", ".", "hasMoreElements", "(", ")", ")", "{", "GraphRelationship", "gr", "=", "(", "GraphRelationship", ")", "enumeration", ".", "nextElement", "(", ")", ";", "if", "(", "gr", ".", "getType", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "relationshipname", ".", "toLowerCase", "(", ")", ")", ")", "{", "GraphRole", "[", "]", "roles", "=", "gr", ".", "getRoles", "(", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "roles", ".", "length", ";", "k", "++", ")", "{", "if", "(", "roles", "[", "k", "]", ".", "getName", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "role", ".", "toLowerCase", "(", ")", ")", ")", "{", "related", ".", "add", "(", "roles", "[", "k", "]", ")", ";", "}", "}", "}", "}", "return", "toGRoArray", "(", "related", ".", "toArray", "(", ")", ")", ";", "}" ]
It obtains the extremes of the association of type "relationshipname", where one of their roles is "role", and originated in the "element" @param element The element to be studied @param relationshipname The name of the relationship which will be studied @param role The name of the extreme of the relationship that has to be studied @return An array of roles
[ "It", "obtains", "the", "extremes", "of", "the", "association", "of", "type", "relationshipname", "where", "one", "of", "their", "roles", "is", "role", "and", "originated", "in", "the", "element" ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L722-L742
647
Grasia/phatsim
phat-generator/src/main/java/phat/codeproc/Utils.java
Utils.getEntities
public static List<GraphEntity> getEntities(Graph g, String typeName) throws NullEntity { GraphEntity[] ge = g.getEntities(); List<GraphEntity> result = new ArrayList<>(); for (int k = 0; k < ge.length; k++) { if (ge[k].getType().equals(typeName)) { result.add(ge[k]); } } return result; }
java
public static List<GraphEntity> getEntities(Graph g, String typeName) throws NullEntity { GraphEntity[] ge = g.getEntities(); List<GraphEntity> result = new ArrayList<>(); for (int k = 0; k < ge.length; k++) { if (ge[k].getType().equals(typeName)) { result.add(ge[k]); } } return result; }
[ "public", "static", "List", "<", "GraphEntity", ">", "getEntities", "(", "Graph", "g", ",", "String", "typeName", ")", "throws", "NullEntity", "{", "GraphEntity", "[", "]", "ge", "=", "g", ".", "getEntities", "(", ")", ";", "List", "<", "GraphEntity", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "ge", ".", "length", ";", "k", "++", ")", "{", "if", "(", "ge", "[", "k", "]", ".", "getType", "(", ")", ".", "equals", "(", "typeName", ")", ")", "{", "result", ".", "add", "(", "ge", "[", "k", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
It obtains the entities in the graph "g" whose type is the same as "typeName". @param g The graph considered @param typeName The type being searched @return The list of entities @throws NullEntity
[ "It", "obtains", "the", "entities", "in", "the", "graph", "g", "whose", "type", "is", "the", "same", "as", "typeName", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-generator/src/main/java/phat/codeproc/Utils.java#L836-L846
648
Grasia/phatsim
phat-audio/src/main/java/phat/audio/textToSpeech/TextToSpeechManager.java
TextToSpeechManager.listAllVoices
public static void listAllVoices() { System.out.println(); System.out.println("All voices available:"); VoiceManager voiceManager = VoiceManager.getInstance(); Voice[] voices = voiceManager.getVoices(); for (int i = 0; i < voices.length; i++) { System.out.println(" " + voices[i].getName() + " (" + voices[i].getDomain() + " domain)"); } }
java
public static void listAllVoices() { System.out.println(); System.out.println("All voices available:"); VoiceManager voiceManager = VoiceManager.getInstance(); Voice[] voices = voiceManager.getVoices(); for (int i = 0; i < voices.length; i++) { System.out.println(" " + voices[i].getName() + " (" + voices[i].getDomain() + " domain)"); } }
[ "public", "static", "void", "listAllVoices", "(", ")", "{", "System", ".", "out", ".", "println", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"All voices available:\"", ")", ";", "VoiceManager", "voiceManager", "=", "VoiceManager", ".", "getInstance", "(", ")", ";", "Voice", "[", "]", "voices", "=", "voiceManager", ".", "getVoices", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "voices", ".", "length", ";", "i", "++", ")", "{", "System", ".", "out", ".", "println", "(", "\" \"", "+", "voices", "[", "i", "]", ".", "getName", "(", ")", "+", "\" (\"", "+", "voices", "[", "i", "]", ".", "getDomain", "(", ")", "+", "\" domain)\"", ")", ";", "}", "}" ]
Example of how to list all the known voices.
[ "Example", "of", "how", "to", "list", "all", "the", "known", "voices", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-audio/src/main/java/phat/audio/textToSpeech/TextToSpeechManager.java#L84-L93
649
Grasia/phatsim
phat-gui/src/main/java/phat/gui/logging/control/TableFilterDemo.java
TableFilterDemo.newFilter
private void newFilter() { RowFilter<MyTableModel, Object> rf = null; //If current expression doesn't parse, don't update. try { rf = RowFilter.regexFilter(filterText.getText(), 0); } catch (java.util.regex.PatternSyntaxException e) { return; } sorter.setRowFilter(rf); }
java
private void newFilter() { RowFilter<MyTableModel, Object> rf = null; //If current expression doesn't parse, don't update. try { rf = RowFilter.regexFilter(filterText.getText(), 0); } catch (java.util.regex.PatternSyntaxException e) { return; } sorter.setRowFilter(rf); }
[ "private", "void", "newFilter", "(", ")", "{", "RowFilter", "<", "MyTableModel", ",", "Object", ">", "rf", "=", "null", ";", "//If current expression doesn't parse, don't update.", "try", "{", "rf", "=", "RowFilter", ".", "regexFilter", "(", "filterText", ".", "getText", "(", ")", ",", "0", ")", ";", "}", "catch", "(", "java", ".", "util", ".", "regex", ".", "PatternSyntaxException", "e", ")", "{", "return", ";", "}", "sorter", ".", "setRowFilter", "(", "rf", ")", ";", "}" ]
Update the row filter regular expression from the expression in the text box.
[ "Update", "the", "row", "filter", "regular", "expression", "from", "the", "expression", "in", "the", "text", "box", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-gui/src/main/java/phat/gui/logging/control/TableFilterDemo.java#L103-L112
650
lookfirst/WePay-Java-SDK
src/main/java/com/lookfirst/wepay/WePayApi.java
WePayApi.checkForError
private void checkForError(JsonNode resp) throws WePayException { JsonNode errorNode = resp.get("error"); if (errorNode != null) throw new WePayException(errorNode.asText(), resp.path("error_description").asText(), resp.path("error_code").asInt()); }
java
private void checkForError(JsonNode resp) throws WePayException { JsonNode errorNode = resp.get("error"); if (errorNode != null) throw new WePayException(errorNode.asText(), resp.path("error_description").asText(), resp.path("error_code").asInt()); }
[ "private", "void", "checkForError", "(", "JsonNode", "resp", ")", "throws", "WePayException", "{", "JsonNode", "errorNode", "=", "resp", ".", "get", "(", "\"error\"", ")", ";", "if", "(", "errorNode", "!=", "null", ")", "throw", "new", "WePayException", "(", "errorNode", ".", "asText", "(", ")", ",", "resp", ".", "path", "(", "\"error_description\"", ")", ".", "asText", "(", ")", ",", "resp", ".", "path", "(", "\"error_code\"", ")", ".", "asInt", "(", ")", ")", ";", "}" ]
If the response node is recognized as an error, throw a WePayException @throws WePayException if the node is an error node
[ "If", "the", "response", "node", "is", "recognized", "as", "an", "error", "throw", "a", "WePayException" ]
3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0
https://github.com/lookfirst/WePay-Java-SDK/blob/3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0/src/main/java/com/lookfirst/wepay/WePayApi.java#L253-L258
651
lookfirst/WePay-Java-SDK
src/main/java/com/lookfirst/wepay/WePayApi.java
WePayApi.getConnection
private HttpURLConnection getConnection(String uri, String postJson, String token) throws IOException { int tries = 0; IOException last = null; while (tries++ <= retries) { try { return getConnectionOnce(uri, postJson, token); } catch (IOException ex) { last = ex; } } throw last; }
java
private HttpURLConnection getConnection(String uri, String postJson, String token) throws IOException { int tries = 0; IOException last = null; while (tries++ <= retries) { try { return getConnectionOnce(uri, postJson, token); } catch (IOException ex) { last = ex; } } throw last; }
[ "private", "HttpURLConnection", "getConnection", "(", "String", "uri", ",", "String", "postJson", ",", "String", "token", ")", "throws", "IOException", "{", "int", "tries", "=", "0", ";", "IOException", "last", "=", "null", ";", "while", "(", "tries", "++", "<=", "retries", ")", "{", "try", "{", "return", "getConnectionOnce", "(", "uri", ",", "postJson", ",", "token", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "last", "=", "ex", ";", "}", "}", "throw", "last", ";", "}" ]
Common functionality for posting data. Smart about retries. WePay's API is not strictly RESTful, so all requests are sent as POST unless there are no request values
[ "Common", "functionality", "for", "posting", "data", ".", "Smart", "about", "retries", "." ]
3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0
https://github.com/lookfirst/WePay-Java-SDK/blob/3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0/src/main/java/com/lookfirst/wepay/WePayApi.java#L265-L278
652
lookfirst/WePay-Java-SDK
src/main/java/com/lookfirst/wepay/WePayApi.java
WePayApi.getConnectionOnce
private HttpURLConnection getConnectionOnce(String uri, String postJson, String token) throws IOException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (timeout > 0) { conn.setReadTimeout(timeout); conn.setConnectTimeout(timeout); } if (postJson != null && postJson.equals("{}")) postJson = null; if (postJson != null) { conn.setDoOutput(true); // Triggers POST. } conn.setRequestProperty("Content-Type", "application/json; charset=" + UTF8.name()); conn.setRequestProperty("User-Agent", "WePay Java SDK"); if (token != null) { conn.setRequestProperty("Authorization", "Bearer " + token); } if (postJson != null) { OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), UTF8); writer.write(postJson); writer.close(); } return conn; }
java
private HttpURLConnection getConnectionOnce(String uri, String postJson, String token) throws IOException { URL url = new URL(uri); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (timeout > 0) { conn.setReadTimeout(timeout); conn.setConnectTimeout(timeout); } if (postJson != null && postJson.equals("{}")) postJson = null; if (postJson != null) { conn.setDoOutput(true); // Triggers POST. } conn.setRequestProperty("Content-Type", "application/json; charset=" + UTF8.name()); conn.setRequestProperty("User-Agent", "WePay Java SDK"); if (token != null) { conn.setRequestProperty("Authorization", "Bearer " + token); } if (postJson != null) { OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), UTF8); writer.write(postJson); writer.close(); } return conn; }
[ "private", "HttpURLConnection", "getConnectionOnce", "(", "String", "uri", ",", "String", "postJson", ",", "String", "token", ")", "throws", "IOException", "{", "URL", "url", "=", "new", "URL", "(", "uri", ")", ";", "HttpURLConnection", "conn", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "if", "(", "timeout", ">", "0", ")", "{", "conn", ".", "setReadTimeout", "(", "timeout", ")", ";", "conn", ".", "setConnectTimeout", "(", "timeout", ")", ";", "}", "if", "(", "postJson", "!=", "null", "&&", "postJson", ".", "equals", "(", "\"{}\"", ")", ")", "postJson", "=", "null", ";", "if", "(", "postJson", "!=", "null", ")", "{", "conn", ".", "setDoOutput", "(", "true", ")", ";", "// Triggers POST.", "}", "conn", ".", "setRequestProperty", "(", "\"Content-Type\"", ",", "\"application/json; charset=\"", "+", "UTF8", ".", "name", "(", ")", ")", ";", "conn", ".", "setRequestProperty", "(", "\"User-Agent\"", ",", "\"WePay Java SDK\"", ")", ";", "if", "(", "token", "!=", "null", ")", "{", "conn", ".", "setRequestProperty", "(", "\"Authorization\"", ",", "\"Bearer \"", "+", "token", ")", ";", "}", "if", "(", "postJson", "!=", "null", ")", "{", "OutputStreamWriter", "writer", "=", "new", "OutputStreamWriter", "(", "conn", ".", "getOutputStream", "(", ")", ",", "UTF8", ")", ";", "writer", ".", "write", "(", "postJson", ")", ";", "writer", ".", "close", "(", ")", ";", "}", "return", "conn", ";", "}" ]
Sets up the headers and writes the post data.
[ "Sets", "up", "the", "headers", "and", "writes", "the", "post", "data", "." ]
3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0
https://github.com/lookfirst/WePay-Java-SDK/blob/3c0a47d6fa051d531c8fdbbfd54a0ef2891aa8f0/src/main/java/com/lookfirst/wepay/WePayApi.java#L283-L313
653
Scout24/appmon4j
agent/src/main/java/de/is24/util/monitoring/agent/Appmon4JAgent.java
Appmon4JAgent.premain
public static void premain(final String agentArgs, final Instrumentation instrumentation) { System.out.println("Initialiting Appmon4jAgent"); Appmon4JAgentConfiguration configuration = null; try { configuration = Appmon4JAgentConfiguration.load(agentArgs); } catch (Exception e) { System.err.println("failed to load appmon4j agent configuration from " + agentArgs + "."); e.printStackTrace(); } if (configuration != null) { new Appmon4JAgent(configuration, instrumentation); } else { System.err.println("appmon4j Agent: Unable to start up. No valid configuration found. Will do nothing. "); } }
java
public static void premain(final String agentArgs, final Instrumentation instrumentation) { System.out.println("Initialiting Appmon4jAgent"); Appmon4JAgentConfiguration configuration = null; try { configuration = Appmon4JAgentConfiguration.load(agentArgs); } catch (Exception e) { System.err.println("failed to load appmon4j agent configuration from " + agentArgs + "."); e.printStackTrace(); } if (configuration != null) { new Appmon4JAgent(configuration, instrumentation); } else { System.err.println("appmon4j Agent: Unable to start up. No valid configuration found. Will do nothing. "); } }
[ "public", "static", "void", "premain", "(", "final", "String", "agentArgs", ",", "final", "Instrumentation", "instrumentation", ")", "{", "System", ".", "out", ".", "println", "(", "\"Initialiting Appmon4jAgent\"", ")", ";", "Appmon4JAgentConfiguration", "configuration", "=", "null", ";", "try", "{", "configuration", "=", "Appmon4JAgentConfiguration", ".", "load", "(", "agentArgs", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"failed to load appmon4j agent configuration from \"", "+", "agentArgs", "+", "\".\"", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "if", "(", "configuration", "!=", "null", ")", "{", "new", "Appmon4JAgent", "(", "configuration", ",", "instrumentation", ")", ";", "}", "else", "{", "System", ".", "err", ".", "println", "(", "\"appmon4j Agent: Unable to start up. No valid configuration found. Will do nothing. \"", ")", ";", "}", "}" ]
The premain method to be implemented by java agents to provide an entry point for the instrumentation. @param agentArgs arguments passed to the agent. @param instrumentation the Instrumentation.
[ "The", "premain", "method", "to", "be", "implemented", "by", "java", "agents", "to", "provide", "an", "entry", "point", "for", "the", "instrumentation", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/agent/src/main/java/de/is24/util/monitoring/agent/Appmon4JAgent.java#L110-L126
654
Scout24/appmon4j
core/src/main/java/de/is24/util/monitoring/Math.java
Math.stdDeviation
public static double stdDeviation(final long n, final double sum, final double sumOfSquares) { double stdDev = 0; if (n > 1) { // std deviation for 1 entry is 0 by definition final double numerator = sumOfSquares - ((sum * sum) / n); stdDev = java.lang.Math.sqrt(numerator / (n - 1)); } return stdDev; }
java
public static double stdDeviation(final long n, final double sum, final double sumOfSquares) { double stdDev = 0; if (n > 1) { // std deviation for 1 entry is 0 by definition final double numerator = sumOfSquares - ((sum * sum) / n); stdDev = java.lang.Math.sqrt(numerator / (n - 1)); } return stdDev; }
[ "public", "static", "double", "stdDeviation", "(", "final", "long", "n", ",", "final", "double", "sum", ",", "final", "double", "sumOfSquares", ")", "{", "double", "stdDev", "=", "0", ";", "if", "(", "n", ">", "1", ")", "{", "// std deviation for 1 entry is 0 by definition\r", "final", "double", "numerator", "=", "sumOfSquares", "-", "(", "(", "sum", "*", "sum", ")", "/", "n", ")", ";", "stdDev", "=", "java", ".", "lang", ".", "Math", ".", "sqrt", "(", "numerator", "/", "(", "n", "-", "1", ")", ")", ";", "}", "return", "stdDev", ";", "}" ]
Calculate the standard deviation from an amount of values n, a sum and a sum of squares. @param n the number of values measured. @param sum the total sum of values measured. @param sumOfSquares the total sum of squares of the values measured. @return the standard deviation of a number of values.
[ "Calculate", "the", "standard", "deviation", "from", "an", "amount", "of", "values", "n", "a", "sum", "and", "a", "sum", "of", "squares", "." ]
a662e5123805ea455cfd01e1b9ae5d808f83529c
https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/Math.java#L41-L49
655
Grasia/phatsim
phat-core/src/main/java/phat/util/PHATImageUtils.java
PHATImageUtils.getScreenShotABGR
public static void getScreenShotABGR(ByteBuffer bgraBuf, BufferedImage out) { WritableRaster wr = out.getRaster(); DataBufferByte db = (DataBufferByte) wr.getDataBuffer(); byte[] cpuArray = db.getData(); // copy native memory to java memory bgraBuf.clear(); bgraBuf.get(cpuArray); bgraBuf.clear(); int width = wr.getWidth(); int height = wr.getHeight(); // flip the components the way AWT likes them for (int y = 0; y < height / 2; y++) { for (int x = 0; x < width; x++) { int inPtr = (y * width + x) * 4; int outPtr = ((height - y - 1) * width + x) * 4; byte b1 = cpuArray[inPtr + 0]; byte g1 = cpuArray[inPtr + 1]; byte r1 = cpuArray[inPtr + 2]; byte a1 = cpuArray[inPtr + 3]; byte b2 = cpuArray[outPtr + 0]; byte g2 = cpuArray[outPtr + 1]; byte r2 = cpuArray[outPtr + 2]; byte a2 = cpuArray[outPtr + 3]; cpuArray[outPtr + 0] = a1; cpuArray[outPtr + 1] = b1; cpuArray[outPtr + 2] = g1; cpuArray[outPtr + 3] = r1; cpuArray[inPtr + 0] = a2; cpuArray[inPtr + 1] = b2; cpuArray[inPtr + 2] = g2; cpuArray[inPtr + 3] = r2; } } }
java
public static void getScreenShotABGR(ByteBuffer bgraBuf, BufferedImage out) { WritableRaster wr = out.getRaster(); DataBufferByte db = (DataBufferByte) wr.getDataBuffer(); byte[] cpuArray = db.getData(); // copy native memory to java memory bgraBuf.clear(); bgraBuf.get(cpuArray); bgraBuf.clear(); int width = wr.getWidth(); int height = wr.getHeight(); // flip the components the way AWT likes them for (int y = 0; y < height / 2; y++) { for (int x = 0; x < width; x++) { int inPtr = (y * width + x) * 4; int outPtr = ((height - y - 1) * width + x) * 4; byte b1 = cpuArray[inPtr + 0]; byte g1 = cpuArray[inPtr + 1]; byte r1 = cpuArray[inPtr + 2]; byte a1 = cpuArray[inPtr + 3]; byte b2 = cpuArray[outPtr + 0]; byte g2 = cpuArray[outPtr + 1]; byte r2 = cpuArray[outPtr + 2]; byte a2 = cpuArray[outPtr + 3]; cpuArray[outPtr + 0] = a1; cpuArray[outPtr + 1] = b1; cpuArray[outPtr + 2] = g1; cpuArray[outPtr + 3] = r1; cpuArray[inPtr + 0] = a2; cpuArray[inPtr + 1] = b2; cpuArray[inPtr + 2] = g2; cpuArray[inPtr + 3] = r2; } } }
[ "public", "static", "void", "getScreenShotABGR", "(", "ByteBuffer", "bgraBuf", ",", "BufferedImage", "out", ")", "{", "WritableRaster", "wr", "=", "out", ".", "getRaster", "(", ")", ";", "DataBufferByte", "db", "=", "(", "DataBufferByte", ")", "wr", ".", "getDataBuffer", "(", ")", ";", "byte", "[", "]", "cpuArray", "=", "db", ".", "getData", "(", ")", ";", "// copy native memory to java memory", "bgraBuf", ".", "clear", "(", ")", ";", "bgraBuf", ".", "get", "(", "cpuArray", ")", ";", "bgraBuf", ".", "clear", "(", ")", ";", "int", "width", "=", "wr", ".", "getWidth", "(", ")", ";", "int", "height", "=", "wr", ".", "getHeight", "(", ")", ";", "// flip the components the way AWT likes them", "for", "(", "int", "y", "=", "0", ";", "y", "<", "height", "/", "2", ";", "y", "++", ")", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "width", ";", "x", "++", ")", "{", "int", "inPtr", "=", "(", "y", "*", "width", "+", "x", ")", "*", "4", ";", "int", "outPtr", "=", "(", "(", "height", "-", "y", "-", "1", ")", "*", "width", "+", "x", ")", "*", "4", ";", "byte", "b1", "=", "cpuArray", "[", "inPtr", "+", "0", "]", ";", "byte", "g1", "=", "cpuArray", "[", "inPtr", "+", "1", "]", ";", "byte", "r1", "=", "cpuArray", "[", "inPtr", "+", "2", "]", ";", "byte", "a1", "=", "cpuArray", "[", "inPtr", "+", "3", "]", ";", "byte", "b2", "=", "cpuArray", "[", "outPtr", "+", "0", "]", ";", "byte", "g2", "=", "cpuArray", "[", "outPtr", "+", "1", "]", ";", "byte", "r2", "=", "cpuArray", "[", "outPtr", "+", "2", "]", ";", "byte", "a2", "=", "cpuArray", "[", "outPtr", "+", "3", "]", ";", "cpuArray", "[", "outPtr", "+", "0", "]", "=", "a1", ";", "cpuArray", "[", "outPtr", "+", "1", "]", "=", "b1", ";", "cpuArray", "[", "outPtr", "+", "2", "]", "=", "g1", ";", "cpuArray", "[", "outPtr", "+", "3", "]", "=", "r1", ";", "cpuArray", "[", "inPtr", "+", "0", "]", "=", "a2", ";", "cpuArray", "[", "inPtr", "+", "1", "]", "=", "b2", ";", "cpuArray", "[", "inPtr", "+", "2", "]", "=", "g2", ";", "cpuArray", "[", "inPtr", "+", "3", "]", "=", "r2", ";", "}", "}", "}" ]
Good format for java swing. @param bgraBuf @param out
[ "Good", "format", "for", "java", "swing", "." ]
2d4fc8189be9730b34c8e3e1a08fb4800e01c5df
https://github.com/Grasia/phatsim/blob/2d4fc8189be9730b34c8e3e1a08fb4800e01c5df/phat-core/src/main/java/phat/util/PHATImageUtils.java#L197-L238
656
dakusui/actionunit
src/main/java/com/github/dakusui/actionunit/actions/cmd/Commander.java
Commander.downstreamConsumerFactory
@SuppressWarnings("unchecked") public C downstreamConsumerFactory(Supplier<Consumer<String>> downstreamConsumerFactory) { this.downstreamConsumerFactory = requireNonNull(downstreamConsumerFactory); return (C) this; }
java
@SuppressWarnings("unchecked") public C downstreamConsumerFactory(Supplier<Consumer<String>> downstreamConsumerFactory) { this.downstreamConsumerFactory = requireNonNull(downstreamConsumerFactory); return (C) this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "C", "downstreamConsumerFactory", "(", "Supplier", "<", "Consumer", "<", "String", ">", ">", "downstreamConsumerFactory", ")", "{", "this", ".", "downstreamConsumerFactory", "=", "requireNonNull", "(", "downstreamConsumerFactory", ")", ";", "return", "(", "C", ")", "this", ";", "}" ]
Sets a downstream consumer's factory to this builder object. @param downstreamConsumerFactory A supplier of a down-stream consumer. @return This object
[ "Sets", "a", "downstream", "consumer", "s", "factory", "to", "this", "builder", "object", "." ]
b68320e740633d44cc56039f7b5ce54464054dce
https://github.com/dakusui/actionunit/blob/b68320e740633d44cc56039f7b5ce54464054dce/src/main/java/com/github/dakusui/actionunit/actions/cmd/Commander.java#L100-L104
657
axibase/atsd-jdbc
src/main/java/com/axibase/tsd/driver/jdbc/ext/AtsdMeta.java
AtsdMeta.appendMetaColumns
private static void appendMetaColumns(StringBuilder buffer, MetadataColumnDefinition[] values) { for (MetadataColumnDefinition column : values) { buffer.append(", ").append(column.getColumnNamePrefix()); } }
java
private static void appendMetaColumns(StringBuilder buffer, MetadataColumnDefinition[] values) { for (MetadataColumnDefinition column : values) { buffer.append(", ").append(column.getColumnNamePrefix()); } }
[ "private", "static", "void", "appendMetaColumns", "(", "StringBuilder", "buffer", ",", "MetadataColumnDefinition", "[", "]", "values", ")", "{", "for", "(", "MetadataColumnDefinition", "column", ":", "values", ")", "{", "buffer", ".", "append", "(", "\", \"", ")", ".", "append", "(", "column", ".", "getColumnNamePrefix", "(", ")", ")", ";", "}", "}" ]
Append metric and entity metadata columns to series requests. This method must not be used while processing meta tables. @param buffer StringBuilder to append to @param values columns to append
[ "Append", "metric", "and", "entity", "metadata", "columns", "to", "series", "requests", ".", "This", "method", "must", "not", "be", "used", "while", "processing", "meta", "tables", "." ]
8bbd9d65f645272aa1d7fc07081bd10bd3e0c376
https://github.com/axibase/atsd-jdbc/blob/8bbd9d65f645272aa1d7fc07081bd10bd3e0c376/src/main/java/com/axibase/tsd/driver/jdbc/ext/AtsdMeta.java#L578-L582
658
axibase/atsd-jdbc
src/main/java/com/axibase/tsd/driver/jdbc/ext/AtsdMeta.java
AtsdMeta.prepareGetMetricUrls
@Nonnull static Collection<MetricLocation> prepareGetMetricUrls(List<String> metricMasks, String tableFilter, boolean underscoreAsLiteral) { if (WildcardsUtil.isRetrieveAllPattern(tableFilter) || tableFilter.isEmpty()) { if (metricMasks.isEmpty()) { return Collections.emptyList(); } else { return buildPatternDisjunction(metricMasks, underscoreAsLiteral); } } else { return Collections.singletonList(buildAtsdPatternUrl(tableFilter, underscoreAsLiteral)); } }
java
@Nonnull static Collection<MetricLocation> prepareGetMetricUrls(List<String> metricMasks, String tableFilter, boolean underscoreAsLiteral) { if (WildcardsUtil.isRetrieveAllPattern(tableFilter) || tableFilter.isEmpty()) { if (metricMasks.isEmpty()) { return Collections.emptyList(); } else { return buildPatternDisjunction(metricMasks, underscoreAsLiteral); } } else { return Collections.singletonList(buildAtsdPatternUrl(tableFilter, underscoreAsLiteral)); } }
[ "@", "Nonnull", "static", "Collection", "<", "MetricLocation", ">", "prepareGetMetricUrls", "(", "List", "<", "String", ">", "metricMasks", ",", "String", "tableFilter", ",", "boolean", "underscoreAsLiteral", ")", "{", "if", "(", "WildcardsUtil", ".", "isRetrieveAllPattern", "(", "tableFilter", ")", "||", "tableFilter", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "metricMasks", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "return", "buildPatternDisjunction", "(", "metricMasks", ",", "underscoreAsLiteral", ")", ";", "}", "}", "else", "{", "return", "Collections", ".", "singletonList", "(", "buildAtsdPatternUrl", "(", "tableFilter", ",", "underscoreAsLiteral", ")", ")", ";", "}", "}" ]
Prepare URL to retrieve metrics @param metricMasks filter specified in `tables` connection string parameter @param tableFilter filter specified in method parameter @param underscoreAsLiteral treat underscore as not a metacharacter @return MetricLocation
[ "Prepare", "URL", "to", "retrieve", "metrics" ]
8bbd9d65f645272aa1d7fc07081bd10bd3e0c376
https://github.com/axibase/atsd-jdbc/blob/8bbd9d65f645272aa1d7fc07081bd10bd3e0c376/src/main/java/com/axibase/tsd/driver/jdbc/ext/AtsdMeta.java#L661-L672
659
axibase/atsd-jdbc
src/main/java/com/axibase/tsd/driver/jdbc/util/WildcardsUtil.java
WildcardsUtil.splitOnTokens
private static String[] splitOnTokens(String text, String oneAnySymbolStr, String noneOrMoreSymbolsStr) { if (!hasWildcards(text, ONE_ANY_SYMBOL, NONE_OR_MORE_SYMBOLS)) { return new String[] { text }; } List<String> list = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); boolean escapeMode = false; final int length = text.length(); for (int i = 0; i < length; i++) { final char current = text.charAt(i); switch (current) { case ESCAPE_CHAR: if (escapeMode) { buffer.append(current); } else { escapeMode = true; } break; case ONE_ANY_SYMBOL: if (escapeMode) { buffer.append(current); escapeMode = false; } else { flushBuffer(buffer, list); if (!list.isEmpty() && noneOrMoreSymbolsStr.equals(list.get(list.size() - 1))) { list.set(list.size() - 1, oneAnySymbolStr); list.add(noneOrMoreSymbolsStr); } else { list.add(oneAnySymbolStr); } } break; case NONE_OR_MORE_SYMBOLS: if (escapeMode) { buffer.append(current); escapeMode = false; } else { flushBuffer(buffer, list); if (list.isEmpty() || !noneOrMoreSymbolsStr.equals(list.get(list.size() - 1))) { list.add(noneOrMoreSymbolsStr); } } break; default: if (escapeMode) { buffer.append(ESCAPE_CHAR); escapeMode = false; } buffer.append(current); } } if (escapeMode) { buffer.append(ESCAPE_CHAR); } if (buffer.length() != 0) { list.add(buffer.toString()); } return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); }
java
private static String[] splitOnTokens(String text, String oneAnySymbolStr, String noneOrMoreSymbolsStr) { if (!hasWildcards(text, ONE_ANY_SYMBOL, NONE_OR_MORE_SYMBOLS)) { return new String[] { text }; } List<String> list = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); boolean escapeMode = false; final int length = text.length(); for (int i = 0; i < length; i++) { final char current = text.charAt(i); switch (current) { case ESCAPE_CHAR: if (escapeMode) { buffer.append(current); } else { escapeMode = true; } break; case ONE_ANY_SYMBOL: if (escapeMode) { buffer.append(current); escapeMode = false; } else { flushBuffer(buffer, list); if (!list.isEmpty() && noneOrMoreSymbolsStr.equals(list.get(list.size() - 1))) { list.set(list.size() - 1, oneAnySymbolStr); list.add(noneOrMoreSymbolsStr); } else { list.add(oneAnySymbolStr); } } break; case NONE_OR_MORE_SYMBOLS: if (escapeMode) { buffer.append(current); escapeMode = false; } else { flushBuffer(buffer, list); if (list.isEmpty() || !noneOrMoreSymbolsStr.equals(list.get(list.size() - 1))) { list.add(noneOrMoreSymbolsStr); } } break; default: if (escapeMode) { buffer.append(ESCAPE_CHAR); escapeMode = false; } buffer.append(current); } } if (escapeMode) { buffer.append(ESCAPE_CHAR); } if (buffer.length() != 0) { list.add(buffer.toString()); } return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); }
[ "private", "static", "String", "[", "]", "splitOnTokens", "(", "String", "text", ",", "String", "oneAnySymbolStr", ",", "String", "noneOrMoreSymbolsStr", ")", "{", "if", "(", "!", "hasWildcards", "(", "text", ",", "ONE_ANY_SYMBOL", ",", "NONE_OR_MORE_SYMBOLS", ")", ")", "{", "return", "new", "String", "[", "]", "{", "text", "}", ";", "}", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "escapeMode", "=", "false", ";", "final", "int", "length", "=", "text", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "final", "char", "current", "=", "text", ".", "charAt", "(", "i", ")", ";", "switch", "(", "current", ")", "{", "case", "ESCAPE_CHAR", ":", "if", "(", "escapeMode", ")", "{", "buffer", ".", "append", "(", "current", ")", ";", "}", "else", "{", "escapeMode", "=", "true", ";", "}", "break", ";", "case", "ONE_ANY_SYMBOL", ":", "if", "(", "escapeMode", ")", "{", "buffer", ".", "append", "(", "current", ")", ";", "escapeMode", "=", "false", ";", "}", "else", "{", "flushBuffer", "(", "buffer", ",", "list", ")", ";", "if", "(", "!", "list", ".", "isEmpty", "(", ")", "&&", "noneOrMoreSymbolsStr", ".", "equals", "(", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ")", ")", "{", "list", ".", "set", "(", "list", ".", "size", "(", ")", "-", "1", ",", "oneAnySymbolStr", ")", ";", "list", ".", "add", "(", "noneOrMoreSymbolsStr", ")", ";", "}", "else", "{", "list", ".", "add", "(", "oneAnySymbolStr", ")", ";", "}", "}", "break", ";", "case", "NONE_OR_MORE_SYMBOLS", ":", "if", "(", "escapeMode", ")", "{", "buffer", ".", "append", "(", "current", ")", ";", "escapeMode", "=", "false", ";", "}", "else", "{", "flushBuffer", "(", "buffer", ",", "list", ")", ";", "if", "(", "list", ".", "isEmpty", "(", ")", "||", "!", "noneOrMoreSymbolsStr", ".", "equals", "(", "list", ".", "get", "(", "list", ".", "size", "(", ")", "-", "1", ")", ")", ")", "{", "list", ".", "add", "(", "noneOrMoreSymbolsStr", ")", ";", "}", "}", "break", ";", "default", ":", "if", "(", "escapeMode", ")", "{", "buffer", ".", "append", "(", "ESCAPE_CHAR", ")", ";", "escapeMode", "=", "false", ";", "}", "buffer", ".", "append", "(", "current", ")", ";", "}", "}", "if", "(", "escapeMode", ")", "{", "buffer", ".", "append", "(", "ESCAPE_CHAR", ")", ";", "}", "if", "(", "buffer", ".", "length", "(", ")", "!=", "0", ")", "{", "list", ".", "add", "(", "buffer", ".", "toString", "(", ")", ")", ";", "}", "return", "list", ".", "toArray", "(", "ArrayUtils", ".", "EMPTY_STRING_ARRAY", ")", ";", "}" ]
Splits a string into a number of tokens. The text is split by '_' and '%'. Multiple '%' are collapsed into a single '%', patterns like "%_" will be transferred to "_%" @param text the text to split @return the array of tokens, never null
[ "Splits", "a", "string", "into", "a", "number", "of", "tokens", ".", "The", "text", "is", "split", "by", "_", "and", "%", ".", "Multiple", "%", "are", "collapsed", "into", "a", "single", "%", "patterns", "like", "%_", "will", "be", "transferred", "to", "_%" ]
8bbd9d65f645272aa1d7fc07081bd10bd3e0c376
https://github.com/axibase/atsd-jdbc/blob/8bbd9d65f645272aa1d7fc07081bd10bd3e0c376/src/main/java/com/axibase/tsd/driver/jdbc/util/WildcardsUtil.java#L134-L194
660
programingjd/justified
app/src/main/java/com/uncopt/android/example/justify/MyJustifiedTextView.java
MyJustifiedTextView.onTouchEvent
@Override public boolean onTouchEvent(final @NotNull MotionEvent event) { final Spannable text = (Spannable)getText(); if (text != null) { if (event.getAction() == MotionEvent.ACTION_DOWN) { final Layout layout = getLayout(); if (layout != null) { // final int pos = getOffsetForPosition(event.getX(), event.getY()); // API >= 14 only final int line = getLineAtCoordinate(layout, event.getY()); final int pos = getOffsetAtCoordinate(layout, line, event.getX()); final ClickableSpan[] links = text.getSpans(pos, pos, ClickableSpan.class); if (links != null && links.length > 0) { links[0].onClick(this); return true; } } } } return super.onTouchEvent(event); }
java
@Override public boolean onTouchEvent(final @NotNull MotionEvent event) { final Spannable text = (Spannable)getText(); if (text != null) { if (event.getAction() == MotionEvent.ACTION_DOWN) { final Layout layout = getLayout(); if (layout != null) { // final int pos = getOffsetForPosition(event.getX(), event.getY()); // API >= 14 only final int line = getLineAtCoordinate(layout, event.getY()); final int pos = getOffsetAtCoordinate(layout, line, event.getX()); final ClickableSpan[] links = text.getSpans(pos, pos, ClickableSpan.class); if (links != null && links.length > 0) { links[0].onClick(this); return true; } } } } return super.onTouchEvent(event); }
[ "@", "Override", "public", "boolean", "onTouchEvent", "(", "final", "@", "NotNull", "MotionEvent", "event", ")", "{", "final", "Spannable", "text", "=", "(", "Spannable", ")", "getText", "(", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "if", "(", "event", ".", "getAction", "(", ")", "==", "MotionEvent", ".", "ACTION_DOWN", ")", "{", "final", "Layout", "layout", "=", "getLayout", "(", ")", ";", "if", "(", "layout", "!=", "null", ")", "{", "// final int pos = getOffsetForPosition(event.getX(), event.getY()); // API >= 14 only", "final", "int", "line", "=", "getLineAtCoordinate", "(", "layout", ",", "event", ".", "getY", "(", ")", ")", ";", "final", "int", "pos", "=", "getOffsetAtCoordinate", "(", "layout", ",", "line", ",", "event", ".", "getX", "(", ")", ")", ";", "final", "ClickableSpan", "[", "]", "links", "=", "text", ".", "getSpans", "(", "pos", ",", "pos", ",", "ClickableSpan", ".", "class", ")", ";", "if", "(", "links", "!=", "null", "&&", "links", ".", "length", ">", "0", ")", "{", "links", "[", "0", "]", ".", "onClick", "(", "this", ")", ";", "return", "true", ";", "}", "}", "}", "}", "return", "super", ".", "onTouchEvent", "(", "event", ")", ";", "}" ]
We want our text to be selectable, but we still want links to be clickable.
[ "We", "want", "our", "text", "to", "be", "selectable", "but", "we", "still", "want", "links", "to", "be", "clickable", "." ]
106685300b60c325d62cc1070ccbdee9ea166026
https://github.com/programingjd/justified/blob/106685300b60c325d62cc1070ccbdee9ea166026/app/src/main/java/com/uncopt/android/example/justify/MyJustifiedTextView.java#L44-L63
661
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java
SeaGlassSplitPaneUI.installDefaults
protected void installDefaults() { updateStyle(splitPane); setOrientation(splitPane.getOrientation()); setContinuousLayout(splitPane.isContinuousLayout()); resetLayoutManager(); /* * Install the nonContinuousLayoutDivider here to avoid having to * add/remove everything later. */ if (nonContinuousLayoutDivider == null) { setNonContinuousLayoutDivider(createDefaultNonContinuousLayoutDivider(), true); } else { setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true); } // focus forward traversal key if (managingFocusForwardTraversalKeys == null) { managingFocusForwardTraversalKeys = new HashSet(); managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); } splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys); // focus backward traversal key if (managingFocusBackwardTraversalKeys == null) { managingFocusBackwardTraversalKeys = new HashSet(); managingFocusBackwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); } splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys); }
java
protected void installDefaults() { updateStyle(splitPane); setOrientation(splitPane.getOrientation()); setContinuousLayout(splitPane.isContinuousLayout()); resetLayoutManager(); /* * Install the nonContinuousLayoutDivider here to avoid having to * add/remove everything later. */ if (nonContinuousLayoutDivider == null) { setNonContinuousLayoutDivider(createDefaultNonContinuousLayoutDivider(), true); } else { setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true); } // focus forward traversal key if (managingFocusForwardTraversalKeys == null) { managingFocusForwardTraversalKeys = new HashSet(); managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); } splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys); // focus backward traversal key if (managingFocusBackwardTraversalKeys == null) { managingFocusBackwardTraversalKeys = new HashSet(); managingFocusBackwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); } splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys); }
[ "protected", "void", "installDefaults", "(", ")", "{", "updateStyle", "(", "splitPane", ")", ";", "setOrientation", "(", "splitPane", ".", "getOrientation", "(", ")", ")", ";", "setContinuousLayout", "(", "splitPane", ".", "isContinuousLayout", "(", ")", ")", ";", "resetLayoutManager", "(", ")", ";", "/*\n * Install the nonContinuousLayoutDivider here to avoid having to\n * add/remove everything later.\n */", "if", "(", "nonContinuousLayoutDivider", "==", "null", ")", "{", "setNonContinuousLayoutDivider", "(", "createDefaultNonContinuousLayoutDivider", "(", ")", ",", "true", ")", ";", "}", "else", "{", "setNonContinuousLayoutDivider", "(", "nonContinuousLayoutDivider", ",", "true", ")", ";", "}", "// focus forward traversal key", "if", "(", "managingFocusForwardTraversalKeys", "==", "null", ")", "{", "managingFocusForwardTraversalKeys", "=", "new", "HashSet", "(", ")", ";", "managingFocusForwardTraversalKeys", ".", "add", "(", "KeyStroke", ".", "getKeyStroke", "(", "KeyEvent", ".", "VK_TAB", ",", "0", ")", ")", ";", "}", "splitPane", ".", "setFocusTraversalKeys", "(", "KeyboardFocusManager", ".", "FORWARD_TRAVERSAL_KEYS", ",", "managingFocusForwardTraversalKeys", ")", ";", "// focus backward traversal key", "if", "(", "managingFocusBackwardTraversalKeys", "==", "null", ")", "{", "managingFocusBackwardTraversalKeys", "=", "new", "HashSet", "(", ")", ";", "managingFocusBackwardTraversalKeys", ".", "add", "(", "KeyStroke", ".", "getKeyStroke", "(", "KeyEvent", ".", "VK_TAB", ",", "InputEvent", ".", "SHIFT_MASK", ")", ")", ";", "}", "splitPane", ".", "setFocusTraversalKeys", "(", "KeyboardFocusManager", ".", "BACKWARD_TRAVERSAL_KEYS", ",", "managingFocusBackwardTraversalKeys", ")", ";", "}" ]
Installs the UI defaults.
[ "Installs", "the", "UI", "defaults", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java#L88-L118
662
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java
SeaGlassSplitPaneUI.uninstallDefaults
protected void uninstallDefaults() { SeaGlassContext context = getContext(splitPane, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED); dividerStyle.uninstallDefaults(context); context.dispose(); dividerStyle = null; super.uninstallDefaults(); }
java
protected void uninstallDefaults() { SeaGlassContext context = getContext(splitPane, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED); dividerStyle.uninstallDefaults(context); context.dispose(); dividerStyle = null; super.uninstallDefaults(); }
[ "protected", "void", "uninstallDefaults", "(", ")", "{", "SeaGlassContext", "context", "=", "getContext", "(", "splitPane", ",", "ENABLED", ")", ";", "style", ".", "uninstallDefaults", "(", "context", ")", ";", "context", ".", "dispose", "(", ")", ";", "style", "=", "null", ";", "context", "=", "getContext", "(", "splitPane", ",", "Region", ".", "SPLIT_PANE_DIVIDER", ",", "ENABLED", ")", ";", "dividerStyle", ".", "uninstallDefaults", "(", "context", ")", ";", "context", ".", "dispose", "(", ")", ";", "dividerStyle", "=", "null", ";", "super", ".", "uninstallDefaults", "(", ")", ";", "}" ]
Uninstalls the UI defaults.
[ "Uninstalls", "the", "UI", "defaults", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java#L176-L189
663
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java
SeaGlassSplitPaneUI.createDefaultDivider
public BasicSplitPaneDivider createDefaultDivider() { SeaGlassSplitPaneDivider divider = new SeaGlassSplitPaneDivider(this); divider.setDividerSize(splitPane.getDividerSize()); return divider; }
java
public BasicSplitPaneDivider createDefaultDivider() { SeaGlassSplitPaneDivider divider = new SeaGlassSplitPaneDivider(this); divider.setDividerSize(splitPane.getDividerSize()); return divider; }
[ "public", "BasicSplitPaneDivider", "createDefaultDivider", "(", ")", "{", "SeaGlassSplitPaneDivider", "divider", "=", "new", "SeaGlassSplitPaneDivider", "(", "this", ")", ";", "divider", ".", "setDividerSize", "(", "splitPane", ".", "getDividerSize", "(", ")", ")", ";", "return", "divider", ";", "}" ]
Creates the default divider.
[ "Creates", "the", "default", "divider", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassSplitPaneUI.java#L240-L245
664
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/icons/FolderIcon.java
FolderIcon.paint
public void paint(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); origAlpha = 1.0f; Composite origComposite = g.getComposite(); if (origComposite instanceof AlphaComposite) { AlphaComposite origAlphaComposite = (AlphaComposite)origComposite; if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { origAlpha = origAlphaComposite.getAlpha(); } } // _0 AffineTransform trans_0 = g.getTransform(); paintRootGraphicsNode_0(g); g.setTransform(trans_0); }
java
public void paint(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); origAlpha = 1.0f; Composite origComposite = g.getComposite(); if (origComposite instanceof AlphaComposite) { AlphaComposite origAlphaComposite = (AlphaComposite)origComposite; if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { origAlpha = origAlphaComposite.getAlpha(); } } // _0 AffineTransform trans_0 = g.getTransform(); paintRootGraphicsNode_0(g); g.setTransform(trans_0); }
[ "public", "void", "paint", "(", "Graphics2D", "g", ")", "{", "g", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "origAlpha", "=", "1.0f", ";", "Composite", "origComposite", "=", "g", ".", "getComposite", "(", ")", ";", "if", "(", "origComposite", "instanceof", "AlphaComposite", ")", "{", "AlphaComposite", "origAlphaComposite", "=", "(", "AlphaComposite", ")", "origComposite", ";", "if", "(", "origAlphaComposite", ".", "getRule", "(", ")", "==", "AlphaComposite", ".", "SRC_OVER", ")", "{", "origAlpha", "=", "origAlphaComposite", ".", "getAlpha", "(", ")", ";", "}", "}", "// _0", "AffineTransform", "trans_0", "=", "g", ".", "getTransform", "(", ")", ";", "paintRootGraphicsNode_0", "(", "g", ")", ";", "g", ".", "setTransform", "(", "trans_0", ")", ";", "}" ]
Paints the transcoded SVG image on the specified graphics context. You can install a custom transformation on the graphics context to scale the image. @param g Graphics context.
[ "Paints", "the", "transcoded", "SVG", "image", "on", "the", "specified", "graphics", "context", ".", "You", "can", "install", "a", "custom", "transformation", "on", "the", "graphics", "context", "to", "scale", "the", "image", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/icons/FolderIcon.java#L23-L40
665
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java
SeaGlassTextPaneUI.propertyChange
@Override protected void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); String name = evt.getPropertyName(); if (name.equals("foreground")) { updateForeground((Color)evt.getNewValue()); } else if (name.equals("font")) { updateFont((Font)evt.getNewValue()); } else if (name.equals("document")) { JComponent comp = getComponent(); updateForeground(comp.getForeground()); updateFont(comp.getFont()); } }
java
@Override protected void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); String name = evt.getPropertyName(); if (name.equals("foreground")) { updateForeground((Color)evt.getNewValue()); } else if (name.equals("font")) { updateFont((Font)evt.getNewValue()); } else if (name.equals("document")) { JComponent comp = getComponent(); updateForeground(comp.getForeground()); updateFont(comp.getFont()); } }
[ "@", "Override", "protected", "void", "propertyChange", "(", "PropertyChangeEvent", "evt", ")", "{", "super", ".", "propertyChange", "(", "evt", ")", ";", "String", "name", "=", "evt", ".", "getPropertyName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"foreground\"", ")", ")", "{", "updateForeground", "(", "(", "Color", ")", "evt", ".", "getNewValue", "(", ")", ")", ";", "}", "else", "if", "(", "name", ".", "equals", "(", "\"font\"", ")", ")", "{", "updateFont", "(", "(", "Font", ")", "evt", ".", "getNewValue", "(", ")", ")", ";", "}", "else", "if", "(", "name", ".", "equals", "(", "\"document\"", ")", ")", "{", "JComponent", "comp", "=", "getComponent", "(", ")", ";", "updateForeground", "(", "comp", ".", "getForeground", "(", ")", ")", ";", "updateFont", "(", "comp", ".", "getFont", "(", ")", ")", ";", "}", "}" ]
This method gets called when a bound property is changed on the associated JTextComponent. This is a hook which UI implementations may change to reflect how the UI displays bound properties of JTextComponent subclasses. If the font, foreground or document has changed, the the appropriate property is set in the default style of the document. @param evt the property change event
[ "This", "method", "gets", "called", "when", "a", "bound", "property", "is", "changed", "on", "the", "associated", "JTextComponent", ".", "This", "is", "a", "hook", "which", "UI", "implementations", "may", "change", "to", "reflect", "how", "the", "UI", "displays", "bound", "properties", "of", "JTextComponent", "subclasses", ".", "If", "the", "font", "foreground", "or", "document", "has", "changed", "the", "the", "appropriate", "property", "is", "set", "in", "the", "default", "style", "of", "the", "document", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java#L113-L128
666
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java
SeaGlassTextPaneUI.updateForeground
private void updateForeground(Color color) { StyledDocument doc = (StyledDocument)getComponent().getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); if (style == null) { return; } if (color == null) { style.removeAttribute(StyleConstants.Foreground); } else { StyleConstants.setForeground(style, color); } }
java
private void updateForeground(Color color) { StyledDocument doc = (StyledDocument)getComponent().getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); if (style == null) { return; } if (color == null) { style.removeAttribute(StyleConstants.Foreground); } else { StyleConstants.setForeground(style, color); } }
[ "private", "void", "updateForeground", "(", "Color", "color", ")", "{", "StyledDocument", "doc", "=", "(", "StyledDocument", ")", "getComponent", "(", ")", ".", "getDocument", "(", ")", ";", "Style", "style", "=", "doc", ".", "getStyle", "(", "StyleContext", ".", "DEFAULT_STYLE", ")", ";", "if", "(", "style", "==", "null", ")", "{", "return", ";", "}", "if", "(", "color", "==", "null", ")", "{", "style", ".", "removeAttribute", "(", "StyleConstants", ".", "Foreground", ")", ";", "}", "else", "{", "StyleConstants", ".", "setForeground", "(", "style", ",", "color", ")", ";", "}", "}" ]
Update the color in the default style of the document. @param color the new color to use or null to remove the color attribute from the document's style
[ "Update", "the", "color", "in", "the", "default", "style", "of", "the", "document", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java#L136-L149
667
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java
SeaGlassTextPaneUI.updateFont
private void updateFont(Font font) { StyledDocument doc = (StyledDocument)getComponent().getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); if (style == null) { return; } if (font == null) { style.removeAttribute(StyleConstants.FontFamily); style.removeAttribute(StyleConstants.FontSize); style.removeAttribute(StyleConstants.Bold); style.removeAttribute(StyleConstants.Italic); } else { StyleConstants.setFontFamily(style, font.getName()); StyleConstants.setFontSize(style, font.getSize()); StyleConstants.setBold(style, font.isBold()); StyleConstants.setItalic(style, font.isItalic()); } }
java
private void updateFont(Font font) { StyledDocument doc = (StyledDocument)getComponent().getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); if (style == null) { return; } if (font == null) { style.removeAttribute(StyleConstants.FontFamily); style.removeAttribute(StyleConstants.FontSize); style.removeAttribute(StyleConstants.Bold); style.removeAttribute(StyleConstants.Italic); } else { StyleConstants.setFontFamily(style, font.getName()); StyleConstants.setFontSize(style, font.getSize()); StyleConstants.setBold(style, font.isBold()); StyleConstants.setItalic(style, font.isItalic()); } }
[ "private", "void", "updateFont", "(", "Font", "font", ")", "{", "StyledDocument", "doc", "=", "(", "StyledDocument", ")", "getComponent", "(", ")", ".", "getDocument", "(", ")", ";", "Style", "style", "=", "doc", ".", "getStyle", "(", "StyleContext", ".", "DEFAULT_STYLE", ")", ";", "if", "(", "style", "==", "null", ")", "{", "return", ";", "}", "if", "(", "font", "==", "null", ")", "{", "style", ".", "removeAttribute", "(", "StyleConstants", ".", "FontFamily", ")", ";", "style", ".", "removeAttribute", "(", "StyleConstants", ".", "FontSize", ")", ";", "style", ".", "removeAttribute", "(", "StyleConstants", ".", "Bold", ")", ";", "style", ".", "removeAttribute", "(", "StyleConstants", ".", "Italic", ")", ";", "}", "else", "{", "StyleConstants", ".", "setFontFamily", "(", "style", ",", "font", ".", "getName", "(", ")", ")", ";", "StyleConstants", ".", "setFontSize", "(", "style", ",", "font", ".", "getSize", "(", ")", ")", ";", "StyleConstants", ".", "setBold", "(", "style", ",", "font", ".", "isBold", "(", ")", ")", ";", "StyleConstants", ".", "setItalic", "(", "style", ",", "font", ".", "isItalic", "(", ")", ")", ";", "}", "}" ]
Update the font in the default style of the document. @param font the new font to use or null to remove the font attribute from the document's style
[ "Update", "the", "font", "in", "the", "default", "style", "of", "the", "document", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTextPaneUI.java#L157-L176
668
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassViewportUI.java
SeaGlassViewportUI.invokeGetter
private static Object invokeGetter(Object obj, String methodName, Object defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return result; } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } }
java
private static Object invokeGetter(Object obj, String methodName, Object defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return result; } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } }
[ "private", "static", "Object", "invokeGetter", "(", "Object", "obj", ",", "String", "methodName", ",", "Object", "defaultValue", ")", "{", "try", "{", "Method", "method", "=", "obj", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ",", "new", "Class", "[", "0", "]", ")", ";", "Object", "result", "=", "method", ".", "invoke", "(", "obj", ",", "new", "Object", "[", "0", "]", ")", ";", "return", "result", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "return", "defaultValue", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "return", "defaultValue", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "return", "defaultValue", ";", "}", "}" ]
Invokes the specified getter method if it exists. @param obj The object on which to invoke the method. @param methodName The name of the method. @param defaultValue This value is returned, if the method does not exist. @return The value returned by the getter method or the default value.
[ "Invokes", "the", "specified", "getter", "method", "if", "it", "exists", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassViewportUI.java#L173-L185
669
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java
FrameAndRootPainter.getFrameBorderPaint
public Paint getFrameBorderPaint(Shape s) { switch (state) { case BACKGROUND_ENABLED: return frameBorderInactive; case BACKGROUND_ENABLED_WINDOWFOCUSED: return frameBorderActive; } return null; }
java
public Paint getFrameBorderPaint(Shape s) { switch (state) { case BACKGROUND_ENABLED: return frameBorderInactive; case BACKGROUND_ENABLED_WINDOWFOCUSED: return frameBorderActive; } return null; }
[ "public", "Paint", "getFrameBorderPaint", "(", "Shape", "s", ")", "{", "switch", "(", "state", ")", "{", "case", "BACKGROUND_ENABLED", ":", "return", "frameBorderInactive", ";", "case", "BACKGROUND_ENABLED_WINDOWFOCUSED", ":", "return", "frameBorderActive", ";", "}", "return", "null", ";", "}" ]
Get the paint for the border. @param s the border shape. @return the paint.
[ "Get", "the", "paint", "for", "the", "border", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java#L192-L203
670
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java
FrameAndRootPainter.getFrameInteriorPaint
public Paint getFrameInteriorPaint(Shape s, int titleHeight, int topToolBarHeight, int bottomToolBarHeight) { return createFrameGradient(s, titleHeight, topToolBarHeight, bottomToolBarHeight, getFrameInteriorColors()); }
java
public Paint getFrameInteriorPaint(Shape s, int titleHeight, int topToolBarHeight, int bottomToolBarHeight) { return createFrameGradient(s, titleHeight, topToolBarHeight, bottomToolBarHeight, getFrameInteriorColors()); }
[ "public", "Paint", "getFrameInteriorPaint", "(", "Shape", "s", ",", "int", "titleHeight", ",", "int", "topToolBarHeight", ",", "int", "bottomToolBarHeight", ")", "{", "return", "createFrameGradient", "(", "s", ",", "titleHeight", ",", "topToolBarHeight", ",", "bottomToolBarHeight", ",", "getFrameInteriorColors", "(", ")", ")", ";", "}" ]
Get the paint for the frame interior. @param s the frame interior shape. @param titleHeight the height of the title portion. @param topToolBarHeight the height of the top toolbar, or 0 if none. @param bottomToolBarHeight the height of the bottom toolbar, or 0 if none. @return the paint.
[ "Get", "the", "paint", "for", "the", "frame", "interior", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java#L234-L236
671
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java
FrameAndRootPainter.getFrameInnerHighlightPaint
public Paint getFrameInnerHighlightPaint(Shape s) { switch (state) { case BACKGROUND_ENABLED: return frameInnerHighlightInactive; case BACKGROUND_ENABLED_WINDOWFOCUSED: return frameInnerHighlightActive; } return null; }
java
public Paint getFrameInnerHighlightPaint(Shape s) { switch (state) { case BACKGROUND_ENABLED: return frameInnerHighlightInactive; case BACKGROUND_ENABLED_WINDOWFOCUSED: return frameInnerHighlightActive; } return null; }
[ "public", "Paint", "getFrameInnerHighlightPaint", "(", "Shape", "s", ")", "{", "switch", "(", "state", ")", "{", "case", "BACKGROUND_ENABLED", ":", "return", "frameInnerHighlightInactive", ";", "case", "BACKGROUND_ENABLED_WINDOWFOCUSED", ":", "return", "frameInnerHighlightActive", ";", "}", "return", "null", ";", "}" ]
Get the paint to paint the inner highlight with. @param s the highlight shape. @return the paint.
[ "Get", "the", "paint", "to", "paint", "the", "inner", "highlight", "with", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/FrameAndRootPainter.java#L257-L268
672
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.getFocusPaint
public Paint getFocusPaint(Shape s, FocusType focusType, boolean useToolBarFocus) { if (focusType == FocusType.OUTER_FOCUS) { return useToolBarFocus ? outerToolBarFocus : outerFocus; } else { return useToolBarFocus ? innerToolBarFocus : innerFocus; } }
java
public Paint getFocusPaint(Shape s, FocusType focusType, boolean useToolBarFocus) { if (focusType == FocusType.OUTER_FOCUS) { return useToolBarFocus ? outerToolBarFocus : outerFocus; } else { return useToolBarFocus ? innerToolBarFocus : innerFocus; } }
[ "public", "Paint", "getFocusPaint", "(", "Shape", "s", ",", "FocusType", "focusType", ",", "boolean", "useToolBarFocus", ")", "{", "if", "(", "focusType", "==", "FocusType", ".", "OUTER_FOCUS", ")", "{", "return", "useToolBarFocus", "?", "outerToolBarFocus", ":", "outerFocus", ";", "}", "else", "{", "return", "useToolBarFocus", "?", "innerToolBarFocus", ":", "innerFocus", ";", "}", "}" ]
Get the paint to use for a focus ring. @param s the shape to paint. @param focusType the focus type. @param useToolBarFocus whether we should use the colors for a toolbar control. @return the paint to use to paint the focus ring.
[ "Get", "the", "paint", "to", "use", "for", "a", "focus", "ring", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L175-L181
673
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.decodeColor
protected final Color decodeColor(String key, float hOffset, float sOffset, float bOffset, int aOffset) { if (UIManager.getLookAndFeel() instanceof SeaGlassLookAndFeel) { SeaGlassLookAndFeel laf = (SeaGlassLookAndFeel) UIManager.getLookAndFeel(); return laf.getDerivedColor(key, hOffset, sOffset, bOffset, aOffset, true); } else { // can not give a right answer as painter should not be used outside // of nimbus laf but do the best we can return Color.getHSBColor(hOffset, sOffset, bOffset); } }
java
protected final Color decodeColor(String key, float hOffset, float sOffset, float bOffset, int aOffset) { if (UIManager.getLookAndFeel() instanceof SeaGlassLookAndFeel) { SeaGlassLookAndFeel laf = (SeaGlassLookAndFeel) UIManager.getLookAndFeel(); return laf.getDerivedColor(key, hOffset, sOffset, bOffset, aOffset, true); } else { // can not give a right answer as painter should not be used outside // of nimbus laf but do the best we can return Color.getHSBColor(hOffset, sOffset, bOffset); } }
[ "protected", "final", "Color", "decodeColor", "(", "String", "key", ",", "float", "hOffset", ",", "float", "sOffset", ",", "float", "bOffset", ",", "int", "aOffset", ")", "{", "if", "(", "UIManager", ".", "getLookAndFeel", "(", ")", "instanceof", "SeaGlassLookAndFeel", ")", "{", "SeaGlassLookAndFeel", "laf", "=", "(", "SeaGlassLookAndFeel", ")", "UIManager", ".", "getLookAndFeel", "(", ")", ";", "return", "laf", ".", "getDerivedColor", "(", "key", ",", "hOffset", ",", "sOffset", ",", "bOffset", ",", "aOffset", ",", "true", ")", ";", "}", "else", "{", "// can not give a right answer as painter should not be used outside", "// of nimbus laf but do the best we can", "return", "Color", ".", "getHSBColor", "(", "hOffset", ",", "sOffset", ",", "bOffset", ")", ";", "}", "}" ]
Decodes and returns a color, which is derived from a base color in UI defaults. @param key A key corresponding to the value in the UI Defaults table of UIManager where the base color is defined @param hOffset The hue offset used for derivation. @param sOffset The saturation offset used for derivation. @param bOffset The brightness offset used for derivation. @param aOffset The alpha offset used for derivation. Between 0...255 @return The derived color, whos color value will change if the parent uiDefault color changes.
[ "Decodes", "and", "returns", "a", "color", "which", "is", "derived", "from", "a", "base", "color", "in", "UI", "defaults", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L249-L260
674
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.deriveARGB
public static int deriveARGB(Color color1, Color color2, float midPoint) { int r = color1.getRed() + (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f); int g = color1.getGreen() + (int) ((color2.getGreen() - color1.getGreen()) * midPoint + 0.5f); int b = color1.getBlue() + (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f); int a = color1.getAlpha() + (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint + 0.5f); return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF); }
java
public static int deriveARGB(Color color1, Color color2, float midPoint) { int r = color1.getRed() + (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f); int g = color1.getGreen() + (int) ((color2.getGreen() - color1.getGreen()) * midPoint + 0.5f); int b = color1.getBlue() + (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f); int a = color1.getAlpha() + (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint + 0.5f); return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF); }
[ "public", "static", "int", "deriveARGB", "(", "Color", "color1", ",", "Color", "color2", ",", "float", "midPoint", ")", "{", "int", "r", "=", "color1", ".", "getRed", "(", ")", "+", "(", "int", ")", "(", "(", "color2", ".", "getRed", "(", ")", "-", "color1", ".", "getRed", "(", ")", ")", "*", "midPoint", "+", "0.5f", ")", ";", "int", "g", "=", "color1", ".", "getGreen", "(", ")", "+", "(", "int", ")", "(", "(", "color2", ".", "getGreen", "(", ")", "-", "color1", ".", "getGreen", "(", ")", ")", "*", "midPoint", "+", "0.5f", ")", ";", "int", "b", "=", "color1", ".", "getBlue", "(", ")", "+", "(", "int", ")", "(", "(", "color2", ".", "getBlue", "(", ")", "-", "color1", ".", "getBlue", "(", ")", ")", "*", "midPoint", "+", "0.5f", ")", ";", "int", "a", "=", "color1", ".", "getAlpha", "(", ")", "+", "(", "int", ")", "(", "(", "color2", ".", "getAlpha", "(", ")", "-", "color1", ".", "getAlpha", "(", ")", ")", "*", "midPoint", "+", "0.5f", ")", ";", "return", "(", "(", "a", "&", "0xFF", ")", "<<", "24", ")", "|", "(", "(", "r", "&", "0xFF", ")", "<<", "16", ")", "|", "(", "(", "g", "&", "0xFF", ")", "<<", "8", ")", "|", "(", "b", "&", "0xFF", ")", ";", "}" ]
Derives the ARGB value for a color based on an offset between two other colors. @param color1 The first color @param color2 The second color @param midPoint The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2; @return the ARGB value for a new color based on this derivation
[ "Derives", "the", "ARGB", "value", "for", "a", "color", "based", "on", "an", "offset", "between", "two", "other", "colors", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L311-L318
675
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.createGradient
protected final LinearGradientPaint createGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors) { if (x1 == x2 && y1 == y2) { y2 += .00001f; } return new LinearGradientPaint(x1, y1, x2, y2, midpoints, colors); }
java
protected final LinearGradientPaint createGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors) { if (x1 == x2 && y1 == y2) { y2 += .00001f; } return new LinearGradientPaint(x1, y1, x2, y2, midpoints, colors); }
[ "protected", "final", "LinearGradientPaint", "createGradient", "(", "float", "x1", ",", "float", "y1", ",", "float", "x2", ",", "float", "y2", ",", "float", "[", "]", "midpoints", ",", "Color", "[", "]", "colors", ")", "{", "if", "(", "x1", "==", "x2", "&&", "y1", "==", "y2", ")", "{", "y2", "+=", ".00001f", ";", "}", "return", "new", "LinearGradientPaint", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "midpoints", ",", "colors", ")", ";", "}" ]
Given parameters for creating a LinearGradientPaint, this method will create and return a linear gradient paint. One primary purpose for this method is to avoid creating a LinearGradientPaint where the start and end points are equal. In such a case, the end y point is slightly increased to avoid the overlap. @param x1 @param y1 @param x2 @param y2 @param midpoints @param colors @return a valid LinearGradientPaint. This method never returns null.
[ "Given", "parameters", "for", "creating", "a", "LinearGradientPaint", "this", "method", "will", "create", "and", "return", "a", "linear", "gradient", "paint", ".", "One", "primary", "purpose", "for", "this", "method", "is", "to", "avoid", "creating", "a", "LinearGradientPaint", "where", "the", "start", "and", "end", "points", "are", "equal", ".", "In", "such", "a", "case", "the", "end", "y", "point", "is", "slightly", "increased", "to", "avoid", "the", "overlap", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L336-L342
676
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.createRadialGradient
protected final RadialGradientPaint createRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors) { if (r == 0f) { r = .00001f; } return new RadialGradientPaint(x, y, r, midpoints, colors); }
java
protected final RadialGradientPaint createRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors) { if (r == 0f) { r = .00001f; } return new RadialGradientPaint(x, y, r, midpoints, colors); }
[ "protected", "final", "RadialGradientPaint", "createRadialGradient", "(", "float", "x", ",", "float", "y", ",", "float", "r", ",", "float", "[", "]", "midpoints", ",", "Color", "[", "]", "colors", ")", "{", "if", "(", "r", "==", "0f", ")", "{", "r", "=", ".00001f", ";", "}", "return", "new", "RadialGradientPaint", "(", "x", ",", "y", ",", "r", ",", "midpoints", ",", "colors", ")", ";", "}" ]
Given parameters for creating a RadialGradientPaint, this method will create and return a radial gradient paint. One primary purpose for this method is to avoid creating a RadialGradientPaint where the radius is non-positive. In such a case, the radius is just slightly increased to avoid 0. @param x @param y @param r @param midpoints @param colors @return a valid RadialGradientPaint. This method never returns null.
[ "Given", "parameters", "for", "creating", "a", "RadialGradientPaint", "this", "method", "will", "create", "and", "return", "a", "radial", "gradient", "paint", ".", "One", "primary", "purpose", "for", "this", "method", "is", "to", "avoid", "creating", "a", "RadialGradientPaint", "where", "the", "radius", "is", "non", "-", "positive", ".", "In", "such", "a", "case", "the", "radius", "is", "just", "slightly", "increased", "to", "avoid", "0", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L359-L365
677
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.createVerticalGradient
protected Paint createVerticalGradient(Shape s, TwoColors colors) { Rectangle2D bounds = s.getBounds2D(); float xCenter = (float) bounds.getCenterX(); float yMin = (float) bounds.getMinY(); float yMax = (float) bounds.getMaxY(); return createGradient(xCenter, yMin, xCenter, yMax, new float[] { 0f, 1f }, new Color[] { colors.top, colors.bottom }); }
java
protected Paint createVerticalGradient(Shape s, TwoColors colors) { Rectangle2D bounds = s.getBounds2D(); float xCenter = (float) bounds.getCenterX(); float yMin = (float) bounds.getMinY(); float yMax = (float) bounds.getMaxY(); return createGradient(xCenter, yMin, xCenter, yMax, new float[] { 0f, 1f }, new Color[] { colors.top, colors.bottom }); }
[ "protected", "Paint", "createVerticalGradient", "(", "Shape", "s", ",", "TwoColors", "colors", ")", "{", "Rectangle2D", "bounds", "=", "s", ".", "getBounds2D", "(", ")", ";", "float", "xCenter", "=", "(", "float", ")", "bounds", ".", "getCenterX", "(", ")", ";", "float", "yMin", "=", "(", "float", ")", "bounds", ".", "getMinY", "(", ")", ";", "float", "yMax", "=", "(", "float", ")", "bounds", ".", "getMaxY", "(", ")", ";", "return", "createGradient", "(", "xCenter", ",", "yMin", ",", "xCenter", ",", "yMax", ",", "new", "float", "[", "]", "{", "0f", ",", "1f", "}", ",", "new", "Color", "[", "]", "{", "colors", ".", "top", ",", "colors", ".", "bottom", "}", ")", ";", "}" ]
Creates a simple vertical gradient using the shape for bounds and the colors for top and bottom colors. @param s the shape to use for bounds. @param colors the colors to use for the gradient. @return the gradient.
[ "Creates", "a", "simple", "vertical", "gradient", "using", "the", "shape", "for", "bounds", "and", "the", "colors", "for", "top", "and", "bottom", "colors", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L376-L383
678
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.createHorizontalGradient
protected Paint createHorizontalGradient(Shape s, TwoColors colors) { Rectangle2D bounds = s.getBounds2D(); float xMin = (float) bounds.getMinX(); float xMax = (float) bounds.getMaxX(); float yCenter = (float) bounds.getCenterY(); return createGradient(xMin, yCenter, xMax, yCenter, new float[] { 0f, 1f }, new Color[] { colors.top, colors.bottom }); }
java
protected Paint createHorizontalGradient(Shape s, TwoColors colors) { Rectangle2D bounds = s.getBounds2D(); float xMin = (float) bounds.getMinX(); float xMax = (float) bounds.getMaxX(); float yCenter = (float) bounds.getCenterY(); return createGradient(xMin, yCenter, xMax, yCenter, new float[] { 0f, 1f }, new Color[] { colors.top, colors.bottom }); }
[ "protected", "Paint", "createHorizontalGradient", "(", "Shape", "s", ",", "TwoColors", "colors", ")", "{", "Rectangle2D", "bounds", "=", "s", ".", "getBounds2D", "(", ")", ";", "float", "xMin", "=", "(", "float", ")", "bounds", ".", "getMinX", "(", ")", ";", "float", "xMax", "=", "(", "float", ")", "bounds", ".", "getMaxX", "(", ")", ";", "float", "yCenter", "=", "(", "float", ")", "bounds", ".", "getCenterY", "(", ")", ";", "return", "createGradient", "(", "xMin", ",", "yCenter", ",", "xMax", ",", "yCenter", ",", "new", "float", "[", "]", "{", "0f", ",", "1f", "}", ",", "new", "Color", "[", "]", "{", "colors", ".", "top", ",", "colors", ".", "bottom", "}", ")", ";", "}" ]
Creates a simple horizontal gradient using the shape for bounds and the colors for top and bottom colors. @param s the shape to use for bounds. @param colors the colors to use for the gradient. @return the gradient.
[ "Creates", "a", "simple", "horizontal", "gradient", "using", "the", "shape", "for", "bounds", "and", "the", "colors", "for", "top", "and", "bottom", "colors", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L413-L420
679
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.createHorizontalGradient
protected Paint createHorizontalGradient(Shape s, FourColors colors) { Rectangle2D bounds = s.getBounds2D(); float x = (float) bounds.getX(); float y = (float) bounds.getY(); float w = (float) bounds.getWidth(); float h = (float) bounds.getHeight(); return createGradient(x, (0.5f * h) + y, x + w, (0.5f * h) + y, new float[] { 0f, 0.45f, 0.62f, 1f }, new Color[] { colors.top, colors.upperMid, colors.lowerMid, colors.bottom }); }
java
protected Paint createHorizontalGradient(Shape s, FourColors colors) { Rectangle2D bounds = s.getBounds2D(); float x = (float) bounds.getX(); float y = (float) bounds.getY(); float w = (float) bounds.getWidth(); float h = (float) bounds.getHeight(); return createGradient(x, (0.5f * h) + y, x + w, (0.5f * h) + y, new float[] { 0f, 0.45f, 0.62f, 1f }, new Color[] { colors.top, colors.upperMid, colors.lowerMid, colors.bottom }); }
[ "protected", "Paint", "createHorizontalGradient", "(", "Shape", "s", ",", "FourColors", "colors", ")", "{", "Rectangle2D", "bounds", "=", "s", ".", "getBounds2D", "(", ")", ";", "float", "x", "=", "(", "float", ")", "bounds", ".", "getX", "(", ")", ";", "float", "y", "=", "(", "float", ")", "bounds", ".", "getY", "(", ")", ";", "float", "w", "=", "(", "float", ")", "bounds", ".", "getWidth", "(", ")", ";", "float", "h", "=", "(", "float", ")", "bounds", ".", "getHeight", "(", ")", ";", "return", "createGradient", "(", "x", ",", "(", "0.5f", "*", "h", ")", "+", "y", ",", "x", "+", "w", ",", "(", "0.5f", "*", "h", ")", "+", "y", ",", "new", "float", "[", "]", "{", "0f", ",", "0.45f", ",", "0.62f", ",", "1f", "}", ",", "new", "Color", "[", "]", "{", "colors", ".", "top", ",", "colors", ".", "upperMid", ",", "colors", ".", "lowerMid", ",", "colors", ".", "bottom", "}", ")", ";", "}" ]
Creates a simple horizontal gradient using the shape for bounds and the colors for top, two middle, and bottom colors. @param s the shape to use for bounds. @param colors the colors to use for the gradient. @return the gradient.
[ "Creates", "a", "simple", "horizontal", "gradient", "using", "the", "shape", "for", "bounds", "and", "the", "colors", "for", "top", "two", "middle", "and", "bottom", "colors", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L431-L440
680
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.desaturate
protected Color desaturate(Color color) { float[] tmp = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); tmp[1] /= 3.0f; tmp[2] = clamp(1.0f - (1.0f - tmp[2]) / 3f); return new Color((Color.HSBtoRGB(tmp[0], tmp[1], tmp[2]) & 0xFFFFFF)); }
java
protected Color desaturate(Color color) { float[] tmp = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); tmp[1] /= 3.0f; tmp[2] = clamp(1.0f - (1.0f - tmp[2]) / 3f); return new Color((Color.HSBtoRGB(tmp[0], tmp[1], tmp[2]) & 0xFFFFFF)); }
[ "protected", "Color", "desaturate", "(", "Color", "color", ")", "{", "float", "[", "]", "tmp", "=", "Color", ".", "RGBtoHSB", "(", "color", ".", "getRed", "(", ")", ",", "color", ".", "getGreen", "(", ")", ",", "color", ".", "getBlue", "(", ")", ",", "null", ")", ";", "tmp", "[", "1", "]", "/=", "3.0f", ";", "tmp", "[", "2", "]", "=", "clamp", "(", "1.0f", "-", "(", "1.0f", "-", "tmp", "[", "2", "]", ")", "/", "3f", ")", ";", "return", "new", "Color", "(", "(", "Color", ".", "HSBtoRGB", "(", "tmp", "[", "0", "]", ",", "tmp", "[", "1", "]", ",", "tmp", "[", "2", "]", ")", "&", "0xFFFFFF", ")", ")", ";", "}" ]
Returns a new color with the saturation cut to one third the original, and the brightness moved one third closer to white. @param color the original color. @return the new color.
[ "Returns", "a", "new", "color", "with", "the", "saturation", "cut", "to", "one", "third", "the", "original", "and", "the", "brightness", "moved", "one", "third", "closer", "to", "white", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L542-L549
681
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.paintWithCaching
private void paintWithCaching(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) { VolatileImage img = getImage(g.getDeviceConfiguration(), c, w, h, extendedCacheKeys); if (img != null) { // render cached image g.drawImage(img, 0, 0, null); } else { // render directly paintDirectly(g, c, w, h, extendedCacheKeys); } }
java
private void paintWithCaching(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) { VolatileImage img = getImage(g.getDeviceConfiguration(), c, w, h, extendedCacheKeys); if (img != null) { // render cached image g.drawImage(img, 0, 0, null); } else { // render directly paintDirectly(g, c, w, h, extendedCacheKeys); } }
[ "private", "void", "paintWithCaching", "(", "Graphics2D", "g", ",", "JComponent", "c", ",", "int", "w", ",", "int", "h", ",", "Object", "[", "]", "extendedCacheKeys", ")", "{", "VolatileImage", "img", "=", "getImage", "(", "g", ".", "getDeviceConfiguration", "(", ")", ",", "c", ",", "w", ",", "h", ",", "extendedCacheKeys", ")", ";", "if", "(", "img", "!=", "null", ")", "{", "// render cached image", "g", ".", "drawImage", "(", "img", ",", "0", ",", "0", ",", "null", ")", ";", "}", "else", "{", "// render directly", "paintDirectly", "(", "g", ",", "c", ",", "w", ",", "h", ",", "extendedCacheKeys", ")", ";", "}", "}" ]
Paint the component, using a cached image if possible. @param g the Graphics2D context to paint with. @param c the component to paint. @param w the component width. @param h the component height. @param extendedCacheKeys extended cache keys.
[ "Paint", "the", "component", "using", "a", "cached", "image", "if", "possible", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L610-L622
682
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.paintDirectly
private void paintDirectly(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) { g = (Graphics2D) g.create(); configureGraphics(g); doPaint(g, c, w, h, extendedCacheKeys); g.dispose(); }
java
private void paintDirectly(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) { g = (Graphics2D) g.create(); configureGraphics(g); doPaint(g, c, w, h, extendedCacheKeys); g.dispose(); }
[ "private", "void", "paintDirectly", "(", "Graphics2D", "g", ",", "JComponent", "c", ",", "int", "w", ",", "int", "h", ",", "Object", "[", "]", "extendedCacheKeys", ")", "{", "g", "=", "(", "Graphics2D", ")", "g", ".", "create", "(", ")", ";", "configureGraphics", "(", "g", ")", ";", "doPaint", "(", "g", ",", "c", ",", "w", ",", "h", ",", "extendedCacheKeys", ")", ";", "g", ".", "dispose", "(", ")", ";", "}" ]
Convenience method which creates a temporary graphics object by creating a clone of the passed in one, configuring it, drawing with it, disposing it. These steps have to be taken to ensure that any hints set on the graphics are removed subsequent to painting. @param g the Graphics2D context to paint with. @param c the component to paint. @param w the component width. @param h the component height. @param extendedCacheKeys extended cache keys.
[ "Convenience", "method", "which", "creates", "a", "temporary", "graphics", "object", "by", "creating", "a", "clone", "of", "the", "passed", "in", "one", "configuring", "it", "drawing", "with", "it", "disposing", "it", ".", "These", "steps", "have", "to", "be", "taken", "to", "ensure", "that", "any", "hints", "set", "on", "the", "graphics", "are", "removed", "subsequent", "to", "painting", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L636-L641
683
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java
AbstractRegionPainter.getImage
private VolatileImage getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys) { ImageCache imageCache = ImageCache.getInstance(); // get the buffer for this component VolatileImage buffer = (VolatileImage) imageCache.getImage(config, w, h, this, extendedCacheKeys); int renderCounter = 0; // to avoid any potential, though unlikely, // infinite loop do { // validate the buffer so we can check for surface loss int bufferStatus = VolatileImage.IMAGE_INCOMPATIBLE; if (buffer != null) { bufferStatus = buffer.validate(config); } // If the buffer status is incompatible or restored, then we need to // re-render to the volatile image if (bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE || bufferStatus == VolatileImage.IMAGE_RESTORED) { // if the buffer is null (hasn't been created), or isn't the // right size, or has lost its contents, // then recreate the buffer if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h || bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE) { // clear any resources related to the old back buffer if (buffer != null) { buffer.flush(); buffer = null; } // recreate the buffer buffer = config.createCompatibleVolatileImage(w, h, Transparency.TRANSLUCENT); // put in cache for future imageCache.setImage(buffer, config, w, h, this, extendedCacheKeys); } // create the graphics context with which to paint to the buffer Graphics2D bg = buffer.createGraphics(); // clear the background before configuring the graphics bg.setComposite(AlphaComposite.Clear); bg.fillRect(0, 0, w, h); bg.setComposite(AlphaComposite.SrcOver); configureGraphics(bg); // paint the painter into buffer paintDirectly(bg, c, w, h, extendedCacheKeys); // close buffer graphics bg.dispose(); } } while (buffer.contentsLost() && renderCounter++ < 3); // check if we failed if (renderCounter == 3) return null; // return image return buffer; }
java
private VolatileImage getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys) { ImageCache imageCache = ImageCache.getInstance(); // get the buffer for this component VolatileImage buffer = (VolatileImage) imageCache.getImage(config, w, h, this, extendedCacheKeys); int renderCounter = 0; // to avoid any potential, though unlikely, // infinite loop do { // validate the buffer so we can check for surface loss int bufferStatus = VolatileImage.IMAGE_INCOMPATIBLE; if (buffer != null) { bufferStatus = buffer.validate(config); } // If the buffer status is incompatible or restored, then we need to // re-render to the volatile image if (bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE || bufferStatus == VolatileImage.IMAGE_RESTORED) { // if the buffer is null (hasn't been created), or isn't the // right size, or has lost its contents, // then recreate the buffer if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h || bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE) { // clear any resources related to the old back buffer if (buffer != null) { buffer.flush(); buffer = null; } // recreate the buffer buffer = config.createCompatibleVolatileImage(w, h, Transparency.TRANSLUCENT); // put in cache for future imageCache.setImage(buffer, config, w, h, this, extendedCacheKeys); } // create the graphics context with which to paint to the buffer Graphics2D bg = buffer.createGraphics(); // clear the background before configuring the graphics bg.setComposite(AlphaComposite.Clear); bg.fillRect(0, 0, w, h); bg.setComposite(AlphaComposite.SrcOver); configureGraphics(bg); // paint the painter into buffer paintDirectly(bg, c, w, h, extendedCacheKeys); // close buffer graphics bg.dispose(); } } while (buffer.contentsLost() && renderCounter++ < 3); // check if we failed if (renderCounter == 3) return null; // return image return buffer; }
[ "private", "VolatileImage", "getImage", "(", "GraphicsConfiguration", "config", ",", "JComponent", "c", ",", "int", "w", ",", "int", "h", ",", "Object", "[", "]", "extendedCacheKeys", ")", "{", "ImageCache", "imageCache", "=", "ImageCache", ".", "getInstance", "(", ")", ";", "// get the buffer for this component", "VolatileImage", "buffer", "=", "(", "VolatileImage", ")", "imageCache", ".", "getImage", "(", "config", ",", "w", ",", "h", ",", "this", ",", "extendedCacheKeys", ")", ";", "int", "renderCounter", "=", "0", ";", "// to avoid any potential, though unlikely,", "// infinite loop", "do", "{", "// validate the buffer so we can check for surface loss", "int", "bufferStatus", "=", "VolatileImage", ".", "IMAGE_INCOMPATIBLE", ";", "if", "(", "buffer", "!=", "null", ")", "{", "bufferStatus", "=", "buffer", ".", "validate", "(", "config", ")", ";", "}", "// If the buffer status is incompatible or restored, then we need to", "// re-render to the volatile image", "if", "(", "bufferStatus", "==", "VolatileImage", ".", "IMAGE_INCOMPATIBLE", "||", "bufferStatus", "==", "VolatileImage", ".", "IMAGE_RESTORED", ")", "{", "// if the buffer is null (hasn't been created), or isn't the", "// right size, or has lost its contents,", "// then recreate the buffer", "if", "(", "buffer", "==", "null", "||", "buffer", ".", "getWidth", "(", ")", "!=", "w", "||", "buffer", ".", "getHeight", "(", ")", "!=", "h", "||", "bufferStatus", "==", "VolatileImage", ".", "IMAGE_INCOMPATIBLE", ")", "{", "// clear any resources related to the old back buffer", "if", "(", "buffer", "!=", "null", ")", "{", "buffer", ".", "flush", "(", ")", ";", "buffer", "=", "null", ";", "}", "// recreate the buffer", "buffer", "=", "config", ".", "createCompatibleVolatileImage", "(", "w", ",", "h", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "// put in cache for future", "imageCache", ".", "setImage", "(", "buffer", ",", "config", ",", "w", ",", "h", ",", "this", ",", "extendedCacheKeys", ")", ";", "}", "// create the graphics context with which to paint to the buffer", "Graphics2D", "bg", "=", "buffer", ".", "createGraphics", "(", ")", ";", "// clear the background before configuring the graphics", "bg", ".", "setComposite", "(", "AlphaComposite", ".", "Clear", ")", ";", "bg", ".", "fillRect", "(", "0", ",", "0", ",", "w", ",", "h", ")", ";", "bg", ".", "setComposite", "(", "AlphaComposite", ".", "SrcOver", ")", ";", "configureGraphics", "(", "bg", ")", ";", "// paint the painter into buffer", "paintDirectly", "(", "bg", ",", "c", ",", "w", ",", "h", ",", "extendedCacheKeys", ")", ";", "// close buffer graphics", "bg", ".", "dispose", "(", ")", ";", "}", "}", "while", "(", "buffer", ".", "contentsLost", "(", ")", "&&", "renderCounter", "++", "<", "3", ")", ";", "// check if we failed", "if", "(", "renderCounter", "==", "3", ")", "return", "null", ";", "// return image", "return", "buffer", ";", "}" ]
Gets the rendered image for this painter at the requested size, either from cache or create a new one @param config the graphics configuration. @param c the component to paint. @param w the component width. @param h the component height. @param extendedCacheKeys extended cache keys. @return the new image.
[ "Gets", "the", "rendered", "image", "for", "this", "painter", "at", "the", "requested", "size", "either", "from", "cache", "or", "create", "a", "new", "one" ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L655-L719
684
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.updateStyle
private void updateStyle(JTabbedPane c) { SeaGlassContext context = getContext(c, ENABLED); SynthStyle oldStyle = style; style = SeaGlassLookAndFeel.updateStyle(context, this); tabPlacement = tabPane.getTabPlacement(); orientation = ControlOrientation.getOrientation(tabPlacement == LEFT || tabPlacement == RIGHT ? VERTICAL : HORIZONTAL); closeButtonArmedIndex = -1; Object o = c.getClientProperty("JTabbedPane.closeButton"); if (o != null && "left".equals(o)) { tabCloseButtonPlacement = LEFT; } else if (o != null && "right".equals(o)) { tabCloseButtonPlacement = RIGHT; } else { tabCloseButtonPlacement = CENTER; } closeButtonSize = style.getInt(context, "closeButtonSize", 6); closeButtonInsets = (Insets) style.get(context, "closeButtonInsets"); if (closeButtonInsets == null) { closeButtonInsets = new Insets(2, 2, 2, 2); } o = c.getClientProperty("JTabbedPane.closeListener"); if (o != null && o instanceof SeaGlassTabCloseListener) { if (tabCloseListener == null) { tabCloseListener = (SeaGlassTabCloseListener) o; } } // Add properties other than JComponent colors, Borders and // opacity settings here: if (style != oldStyle) { tabRunOverlay = 0; textIconGap = style.getInt(context, "TabbedPane.textIconGap", 0); selectedTabPadInsets = (Insets) style.get(context, "TabbedPane.selectedTabPadInsets"); if (selectedTabPadInsets == null) { selectedTabPadInsets = new Insets(0, 0, 0, 0); } if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); if (tabContext != null) { tabContext.dispose(); } tabContext = getContext(c, Region.TABBED_PANE_TAB, ENABLED); this.tabStyle = SeaGlassLookAndFeel.updateStyle(tabContext, this); tabInsets = tabStyle.getInsets(tabContext, null); if (tabCloseContext != null) { tabCloseContext.dispose(); } tabCloseContext = getContext(c, SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON, ENABLED); this.tabCloseStyle = SeaGlassLookAndFeel.updateStyle(tabCloseContext, this); if (tabAreaContext != null) { tabAreaContext.dispose(); } tabAreaContext = getContext(c, Region.TABBED_PANE_TAB_AREA, ENABLED); this.tabAreaStyle = SeaGlassLookAndFeel.updateStyle(tabAreaContext, this); tabAreaInsets = tabAreaStyle.getInsets(tabAreaContext, null); if (tabContentContext != null) { tabContentContext.dispose(); } tabContentContext = getContext(c, Region.TABBED_PANE_CONTENT, ENABLED); this.tabContentStyle = SeaGlassLookAndFeel.updateStyle(tabContentContext, this); contentBorderInsets = tabContentStyle.getInsets(tabContentContext, null); }
java
private void updateStyle(JTabbedPane c) { SeaGlassContext context = getContext(c, ENABLED); SynthStyle oldStyle = style; style = SeaGlassLookAndFeel.updateStyle(context, this); tabPlacement = tabPane.getTabPlacement(); orientation = ControlOrientation.getOrientation(tabPlacement == LEFT || tabPlacement == RIGHT ? VERTICAL : HORIZONTAL); closeButtonArmedIndex = -1; Object o = c.getClientProperty("JTabbedPane.closeButton"); if (o != null && "left".equals(o)) { tabCloseButtonPlacement = LEFT; } else if (o != null && "right".equals(o)) { tabCloseButtonPlacement = RIGHT; } else { tabCloseButtonPlacement = CENTER; } closeButtonSize = style.getInt(context, "closeButtonSize", 6); closeButtonInsets = (Insets) style.get(context, "closeButtonInsets"); if (closeButtonInsets == null) { closeButtonInsets = new Insets(2, 2, 2, 2); } o = c.getClientProperty("JTabbedPane.closeListener"); if (o != null && o instanceof SeaGlassTabCloseListener) { if (tabCloseListener == null) { tabCloseListener = (SeaGlassTabCloseListener) o; } } // Add properties other than JComponent colors, Borders and // opacity settings here: if (style != oldStyle) { tabRunOverlay = 0; textIconGap = style.getInt(context, "TabbedPane.textIconGap", 0); selectedTabPadInsets = (Insets) style.get(context, "TabbedPane.selectedTabPadInsets"); if (selectedTabPadInsets == null) { selectedTabPadInsets = new Insets(0, 0, 0, 0); } if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); if (tabContext != null) { tabContext.dispose(); } tabContext = getContext(c, Region.TABBED_PANE_TAB, ENABLED); this.tabStyle = SeaGlassLookAndFeel.updateStyle(tabContext, this); tabInsets = tabStyle.getInsets(tabContext, null); if (tabCloseContext != null) { tabCloseContext.dispose(); } tabCloseContext = getContext(c, SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON, ENABLED); this.tabCloseStyle = SeaGlassLookAndFeel.updateStyle(tabCloseContext, this); if (tabAreaContext != null) { tabAreaContext.dispose(); } tabAreaContext = getContext(c, Region.TABBED_PANE_TAB_AREA, ENABLED); this.tabAreaStyle = SeaGlassLookAndFeel.updateStyle(tabAreaContext, this); tabAreaInsets = tabAreaStyle.getInsets(tabAreaContext, null); if (tabContentContext != null) { tabContentContext.dispose(); } tabContentContext = getContext(c, Region.TABBED_PANE_CONTENT, ENABLED); this.tabContentStyle = SeaGlassLookAndFeel.updateStyle(tabContentContext, this); contentBorderInsets = tabContentStyle.getInsets(tabContentContext, null); }
[ "private", "void", "updateStyle", "(", "JTabbedPane", "c", ")", "{", "SeaGlassContext", "context", "=", "getContext", "(", "c", ",", "ENABLED", ")", ";", "SynthStyle", "oldStyle", "=", "style", ";", "style", "=", "SeaGlassLookAndFeel", ".", "updateStyle", "(", "context", ",", "this", ")", ";", "tabPlacement", "=", "tabPane", ".", "getTabPlacement", "(", ")", ";", "orientation", "=", "ControlOrientation", ".", "getOrientation", "(", "tabPlacement", "==", "LEFT", "||", "tabPlacement", "==", "RIGHT", "?", "VERTICAL", ":", "HORIZONTAL", ")", ";", "closeButtonArmedIndex", "=", "-", "1", ";", "Object", "o", "=", "c", ".", "getClientProperty", "(", "\"JTabbedPane.closeButton\"", ")", ";", "if", "(", "o", "!=", "null", "&&", "\"left\"", ".", "equals", "(", "o", ")", ")", "{", "tabCloseButtonPlacement", "=", "LEFT", ";", "}", "else", "if", "(", "o", "!=", "null", "&&", "\"right\"", ".", "equals", "(", "o", ")", ")", "{", "tabCloseButtonPlacement", "=", "RIGHT", ";", "}", "else", "{", "tabCloseButtonPlacement", "=", "CENTER", ";", "}", "closeButtonSize", "=", "style", ".", "getInt", "(", "context", ",", "\"closeButtonSize\"", ",", "6", ")", ";", "closeButtonInsets", "=", "(", "Insets", ")", "style", ".", "get", "(", "context", ",", "\"closeButtonInsets\"", ")", ";", "if", "(", "closeButtonInsets", "==", "null", ")", "{", "closeButtonInsets", "=", "new", "Insets", "(", "2", ",", "2", ",", "2", ",", "2", ")", ";", "}", "o", "=", "c", ".", "getClientProperty", "(", "\"JTabbedPane.closeListener\"", ")", ";", "if", "(", "o", "!=", "null", "&&", "o", "instanceof", "SeaGlassTabCloseListener", ")", "{", "if", "(", "tabCloseListener", "==", "null", ")", "{", "tabCloseListener", "=", "(", "SeaGlassTabCloseListener", ")", "o", ";", "}", "}", "// Add properties other than JComponent colors, Borders and", "// opacity settings here:", "if", "(", "style", "!=", "oldStyle", ")", "{", "tabRunOverlay", "=", "0", ";", "textIconGap", "=", "style", ".", "getInt", "(", "context", ",", "\"TabbedPane.textIconGap\"", ",", "0", ")", ";", "selectedTabPadInsets", "=", "(", "Insets", ")", "style", ".", "get", "(", "context", ",", "\"TabbedPane.selectedTabPadInsets\"", ")", ";", "if", "(", "selectedTabPadInsets", "==", "null", ")", "{", "selectedTabPadInsets", "=", "new", "Insets", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "}", "if", "(", "oldStyle", "!=", "null", ")", "{", "uninstallKeyboardActions", "(", ")", ";", "installKeyboardActions", "(", ")", ";", "}", "}", "context", ".", "dispose", "(", ")", ";", "if", "(", "tabContext", "!=", "null", ")", "{", "tabContext", ".", "dispose", "(", ")", ";", "}", "tabContext", "=", "getContext", "(", "c", ",", "Region", ".", "TABBED_PANE_TAB", ",", "ENABLED", ")", ";", "this", ".", "tabStyle", "=", "SeaGlassLookAndFeel", ".", "updateStyle", "(", "tabContext", ",", "this", ")", ";", "tabInsets", "=", "tabStyle", ".", "getInsets", "(", "tabContext", ",", "null", ")", ";", "if", "(", "tabCloseContext", "!=", "null", ")", "{", "tabCloseContext", ".", "dispose", "(", ")", ";", "}", "tabCloseContext", "=", "getContext", "(", "c", ",", "SeaGlassRegion", ".", "TABBED_PANE_TAB_CLOSE_BUTTON", ",", "ENABLED", ")", ";", "this", ".", "tabCloseStyle", "=", "SeaGlassLookAndFeel", ".", "updateStyle", "(", "tabCloseContext", ",", "this", ")", ";", "if", "(", "tabAreaContext", "!=", "null", ")", "{", "tabAreaContext", ".", "dispose", "(", ")", ";", "}", "tabAreaContext", "=", "getContext", "(", "c", ",", "Region", ".", "TABBED_PANE_TAB_AREA", ",", "ENABLED", ")", ";", "this", ".", "tabAreaStyle", "=", "SeaGlassLookAndFeel", ".", "updateStyle", "(", "tabAreaContext", ",", "this", ")", ";", "tabAreaInsets", "=", "tabAreaStyle", ".", "getInsets", "(", "tabAreaContext", ",", "null", ")", ";", "if", "(", "tabContentContext", "!=", "null", ")", "{", "tabContentContext", ".", "dispose", "(", ")", ";", "}", "tabContentContext", "=", "getContext", "(", "c", ",", "Region", ".", "TABBED_PANE_CONTENT", ",", "ENABLED", ")", ";", "this", ".", "tabContentStyle", "=", "SeaGlassLookAndFeel", ".", "updateStyle", "(", "tabContentContext", ",", "this", ")", ";", "contentBorderInsets", "=", "tabContentStyle", ".", "getInsets", "(", "tabContentContext", ",", "null", ")", ";", "}" ]
Update the Synth styles when something changes. @param c the component.
[ "Update", "the", "Synth", "styles", "when", "something", "changes", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L225-L308
685
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.scrollBackward
protected void scrollBackward() { int selectedIndex = tabPane.getSelectedIndex(); if (--selectedIndex < 0) { tabPane.setSelectedIndex(tabPane.getTabCount() == 0 ? -1 : 0); } else { tabPane.setSelectedIndex(selectedIndex); } tabPane.repaint(); }
java
protected void scrollBackward() { int selectedIndex = tabPane.getSelectedIndex(); if (--selectedIndex < 0) { tabPane.setSelectedIndex(tabPane.getTabCount() == 0 ? -1 : 0); } else { tabPane.setSelectedIndex(selectedIndex); } tabPane.repaint(); }
[ "protected", "void", "scrollBackward", "(", ")", "{", "int", "selectedIndex", "=", "tabPane", ".", "getSelectedIndex", "(", ")", ";", "if", "(", "--", "selectedIndex", "<", "0", ")", "{", "tabPane", ".", "setSelectedIndex", "(", "tabPane", ".", "getTabCount", "(", ")", "==", "0", "?", "-", "1", ":", "0", ")", ";", "}", "else", "{", "tabPane", ".", "setSelectedIndex", "(", "selectedIndex", ")", ";", "}", "tabPane", ".", "repaint", "(", ")", ";", "}" ]
Scroll the tab buttons backwards.
[ "Scroll", "the", "tab", "buttons", "backwards", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L334-L344
686
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.scrollForward
protected void scrollForward() { int selectedIndex = tabPane.getSelectedIndex(); if (++selectedIndex >= tabPane.getTabCount()) { tabPane.setSelectedIndex(tabPane.getTabCount() - 1); } else { tabPane.setSelectedIndex(selectedIndex); } tabPane.repaint(); }
java
protected void scrollForward() { int selectedIndex = tabPane.getSelectedIndex(); if (++selectedIndex >= tabPane.getTabCount()) { tabPane.setSelectedIndex(tabPane.getTabCount() - 1); } else { tabPane.setSelectedIndex(selectedIndex); } tabPane.repaint(); }
[ "protected", "void", "scrollForward", "(", ")", "{", "int", "selectedIndex", "=", "tabPane", ".", "getSelectedIndex", "(", ")", ";", "if", "(", "++", "selectedIndex", ">=", "tabPane", ".", "getTabCount", "(", ")", ")", "{", "tabPane", ".", "setSelectedIndex", "(", "tabPane", ".", "getTabCount", "(", ")", "-", "1", ")", ";", "}", "else", "{", "tabPane", ".", "setSelectedIndex", "(", "selectedIndex", ")", ";", "}", "tabPane", ".", "repaint", "(", ")", ";", "}" ]
Scroll the tab buttons forwards.
[ "Scroll", "the", "tab", "buttons", "forwards", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L349-L359
687
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.getContext
public SeaGlassContext getContext(JComponent c, int state) { return SeaGlassContext.getContext(SeaGlassContext.class, c, SeaGlassLookAndFeel.getRegion(c), style, state); }
java
public SeaGlassContext getContext(JComponent c, int state) { return SeaGlassContext.getContext(SeaGlassContext.class, c, SeaGlassLookAndFeel.getRegion(c), style, state); }
[ "public", "SeaGlassContext", "getContext", "(", "JComponent", "c", ",", "int", "state", ")", "{", "return", "SeaGlassContext", ".", "getContext", "(", "SeaGlassContext", ".", "class", ",", "c", ",", "SeaGlassLookAndFeel", ".", "getRegion", "(", "c", ")", ",", "style", ",", "state", ")", ";", "}" ]
Create a SynthContext for the component and state. Use the default region. @param c the component. @param state the state. @return the newly created SynthContext.
[ "Create", "a", "SynthContext", "for", "the", "component", "and", "state", ".", "Use", "the", "default", "region", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L415-L417
688
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.getContext
public SeaGlassContext getContext(JComponent c, Region subregion) { return getContext(c, subregion, getComponentState(c)); }
java
public SeaGlassContext getContext(JComponent c, Region subregion) { return getContext(c, subregion, getComponentState(c)); }
[ "public", "SeaGlassContext", "getContext", "(", "JComponent", "c", ",", "Region", "subregion", ")", "{", "return", "getContext", "(", "c", ",", "subregion", ",", "getComponentState", "(", "c", ")", ")", ";", "}" ]
Create a SynthContext for the component and subregion. Use the current state. @param c the component. @param subregion the subregion. @return the newly created SynthContext.
[ "Create", "a", "SynthContext", "for", "the", "component", "and", "subregion", ".", "Use", "the", "current", "state", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L428-L430
689
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.getContext
private SeaGlassContext getContext(JComponent c, Region subregion, int state) { SynthStyle style = null; Class klass = SeaGlassContext.class; if (subregion == Region.TABBED_PANE_TAB) { style = tabStyle; } else if (subregion == Region.TABBED_PANE_TAB_AREA) { style = tabAreaStyle; } else if (subregion == Region.TABBED_PANE_CONTENT) { style = tabContentStyle; } else if (subregion == SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON) { style = tabCloseStyle; } return SeaGlassContext.getContext(klass, c, subregion, style, state); }
java
private SeaGlassContext getContext(JComponent c, Region subregion, int state) { SynthStyle style = null; Class klass = SeaGlassContext.class; if (subregion == Region.TABBED_PANE_TAB) { style = tabStyle; } else if (subregion == Region.TABBED_PANE_TAB_AREA) { style = tabAreaStyle; } else if (subregion == Region.TABBED_PANE_CONTENT) { style = tabContentStyle; } else if (subregion == SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON) { style = tabCloseStyle; } return SeaGlassContext.getContext(klass, c, subregion, style, state); }
[ "private", "SeaGlassContext", "getContext", "(", "JComponent", "c", ",", "Region", "subregion", ",", "int", "state", ")", "{", "SynthStyle", "style", "=", "null", ";", "Class", "klass", "=", "SeaGlassContext", ".", "class", ";", "if", "(", "subregion", "==", "Region", ".", "TABBED_PANE_TAB", ")", "{", "style", "=", "tabStyle", ";", "}", "else", "if", "(", "subregion", "==", "Region", ".", "TABBED_PANE_TAB_AREA", ")", "{", "style", "=", "tabAreaStyle", ";", "}", "else", "if", "(", "subregion", "==", "Region", ".", "TABBED_PANE_CONTENT", ")", "{", "style", "=", "tabContentStyle", ";", "}", "else", "if", "(", "subregion", "==", "SeaGlassRegion", ".", "TABBED_PANE_TAB_CLOSE_BUTTON", ")", "{", "style", "=", "tabCloseStyle", ";", "}", "return", "SeaGlassContext", ".", "getContext", "(", "klass", ",", "c", ",", "subregion", ",", "style", ",", "state", ")", ";", "}" ]
Create a SynthContext for the component, subregion, and state. @param c the component. @param subregion the subregion. @param state the state. @return the newly created SynthContext.
[ "Create", "a", "SynthContext", "for", "the", "component", "subregion", "and", "state", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L441-L456
690
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.getCloseButtonState
public int getCloseButtonState(JComponent c, int tabIndex, boolean tabIsMousedOver) { if (!c.isEnabled()) { return DISABLED; } else if (tabIndex == closeButtonArmedIndex) { return PRESSED; } else if (tabIndex == closeButtonHoverIndex) { return FOCUSED; } else if (tabIsMousedOver) { return MOUSE_OVER; } return ENABLED; }
java
public int getCloseButtonState(JComponent c, int tabIndex, boolean tabIsMousedOver) { if (!c.isEnabled()) { return DISABLED; } else if (tabIndex == closeButtonArmedIndex) { return PRESSED; } else if (tabIndex == closeButtonHoverIndex) { return FOCUSED; } else if (tabIsMousedOver) { return MOUSE_OVER; } return ENABLED; }
[ "public", "int", "getCloseButtonState", "(", "JComponent", "c", ",", "int", "tabIndex", ",", "boolean", "tabIsMousedOver", ")", "{", "if", "(", "!", "c", ".", "isEnabled", "(", ")", ")", "{", "return", "DISABLED", ";", "}", "else", "if", "(", "tabIndex", "==", "closeButtonArmedIndex", ")", "{", "return", "PRESSED", ";", "}", "else", "if", "(", "tabIndex", "==", "closeButtonHoverIndex", ")", "{", "return", "FOCUSED", ";", "}", "else", "if", "(", "tabIsMousedOver", ")", "{", "return", "MOUSE_OVER", ";", "}", "return", "ENABLED", ";", "}" ]
Get the state for the specified tab's close button. @param c the tabbed pane. @param tabIndex the index of the tab. @param tabIsMousedOver TODO @return the close button state.
[ "Get", "the", "state", "for", "the", "specified", "tab", "s", "close", "button", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L478-L490
691
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paint
protected void paint(SeaGlassContext context, Graphics g) { int selectedIndex = tabPane.getSelectedIndex(); ensureCurrentLayout(); // Paint content border. paintContentBorder(tabContentContext, g, tabPlacement, selectedIndex); paintTabArea(g, tabPlacement, selectedIndex); }
java
protected void paint(SeaGlassContext context, Graphics g) { int selectedIndex = tabPane.getSelectedIndex(); ensureCurrentLayout(); // Paint content border. paintContentBorder(tabContentContext, g, tabPlacement, selectedIndex); paintTabArea(g, tabPlacement, selectedIndex); }
[ "protected", "void", "paint", "(", "SeaGlassContext", "context", ",", "Graphics", "g", ")", "{", "int", "selectedIndex", "=", "tabPane", ".", "getSelectedIndex", "(", ")", ";", "ensureCurrentLayout", "(", ")", ";", "// Paint content border.", "paintContentBorder", "(", "tabContentContext", ",", "g", ",", "tabPlacement", ",", "selectedIndex", ")", ";", "paintTabArea", "(", "g", ",", "tabPlacement", ",", "selectedIndex", ")", ";", "}" ]
Paint the tabbed pane. @param context the SynthContext describing the control. @param g the Graphics context to paint with.
[ "Paint", "the", "tabbed", "pane", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L612-L620
692
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintTabArea
protected void paintTabArea(SeaGlassContext ss, Graphics g, int tabPlacement, int selectedIndex, Rectangle tabAreaBounds) { Rectangle clipRect = g.getClipBounds(); ss.setComponentState(SynthConstants.ENABLED); // Paint the tab area. SeaGlassLookAndFeel.updateSubregion(ss, g, tabAreaBounds); ss.getPainter().paintTabbedPaneTabAreaBackground(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width, tabAreaBounds.height, tabPlacement); ss.getPainter().paintTabbedPaneTabAreaBorder(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width, tabAreaBounds.height, tabPlacement); iconRect.setBounds(0, 0, 0, 0); textRect.setBounds(0, 0, 0, 0); if (runCount == 0) { return; } if (scrollBackwardButton.isVisible()) { paintScrollButtonBackground(ss, g, scrollBackwardButton); } if (scrollForwardButton.isVisible()) { paintScrollButtonBackground(ss, g, scrollForwardButton); } for (int i = leadingTabIndex; i <= trailingTabIndex; i++) { if (rects[i].intersects(clipRect) && selectedIndex != i) { paintTab(tabContext, g, rects, i, iconRect, textRect); } } if (selectedIndex >= 0) { if (rects[selectedIndex].intersects(clipRect)) { paintTab(tabContext, g, rects, selectedIndex, iconRect, textRect); } } }
java
protected void paintTabArea(SeaGlassContext ss, Graphics g, int tabPlacement, int selectedIndex, Rectangle tabAreaBounds) { Rectangle clipRect = g.getClipBounds(); ss.setComponentState(SynthConstants.ENABLED); // Paint the tab area. SeaGlassLookAndFeel.updateSubregion(ss, g, tabAreaBounds); ss.getPainter().paintTabbedPaneTabAreaBackground(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width, tabAreaBounds.height, tabPlacement); ss.getPainter().paintTabbedPaneTabAreaBorder(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width, tabAreaBounds.height, tabPlacement); iconRect.setBounds(0, 0, 0, 0); textRect.setBounds(0, 0, 0, 0); if (runCount == 0) { return; } if (scrollBackwardButton.isVisible()) { paintScrollButtonBackground(ss, g, scrollBackwardButton); } if (scrollForwardButton.isVisible()) { paintScrollButtonBackground(ss, g, scrollForwardButton); } for (int i = leadingTabIndex; i <= trailingTabIndex; i++) { if (rects[i].intersects(clipRect) && selectedIndex != i) { paintTab(tabContext, g, rects, i, iconRect, textRect); } } if (selectedIndex >= 0) { if (rects[selectedIndex].intersects(clipRect)) { paintTab(tabContext, g, rects, selectedIndex, iconRect, textRect); } } }
[ "protected", "void", "paintTabArea", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "int", "tabPlacement", ",", "int", "selectedIndex", ",", "Rectangle", "tabAreaBounds", ")", "{", "Rectangle", "clipRect", "=", "g", ".", "getClipBounds", "(", ")", ";", "ss", ".", "setComponentState", "(", "SynthConstants", ".", "ENABLED", ")", ";", "// Paint the tab area.", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "ss", ",", "g", ",", "tabAreaBounds", ")", ";", "ss", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabAreaBackground", "(", "ss", ",", "g", ",", "tabAreaBounds", ".", "x", ",", "tabAreaBounds", ".", "y", ",", "tabAreaBounds", ".", "width", ",", "tabAreaBounds", ".", "height", ",", "tabPlacement", ")", ";", "ss", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabAreaBorder", "(", "ss", ",", "g", ",", "tabAreaBounds", ".", "x", ",", "tabAreaBounds", ".", "y", ",", "tabAreaBounds", ".", "width", ",", "tabAreaBounds", ".", "height", ",", "tabPlacement", ")", ";", "iconRect", ".", "setBounds", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "textRect", ".", "setBounds", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "if", "(", "runCount", "==", "0", ")", "{", "return", ";", "}", "if", "(", "scrollBackwardButton", ".", "isVisible", "(", ")", ")", "{", "paintScrollButtonBackground", "(", "ss", ",", "g", ",", "scrollBackwardButton", ")", ";", "}", "if", "(", "scrollForwardButton", ".", "isVisible", "(", ")", ")", "{", "paintScrollButtonBackground", "(", "ss", ",", "g", ",", "scrollForwardButton", ")", ";", "}", "for", "(", "int", "i", "=", "leadingTabIndex", ";", "i", "<=", "trailingTabIndex", ";", "i", "++", ")", "{", "if", "(", "rects", "[", "i", "]", ".", "intersects", "(", "clipRect", ")", "&&", "selectedIndex", "!=", "i", ")", "{", "paintTab", "(", "tabContext", ",", "g", ",", "rects", ",", "i", ",", "iconRect", ",", "textRect", ")", ";", "}", "}", "if", "(", "selectedIndex", ">=", "0", ")", "{", "if", "(", "rects", "[", "selectedIndex", "]", ".", "intersects", "(", "clipRect", ")", ")", "{", "paintTab", "(", "tabContext", ",", "g", ",", "rects", ",", "selectedIndex", ",", "iconRect", ",", "textRect", ")", ";", "}", "}", "}" ]
Paint the tab area, including the tabs. @param ss the SynthContext. @param g the Graphics context. @param tabPlacement the side the tabs are on. @param selectedIndex the current selected tab index. @param tabAreaBounds the bounds of the tab area.
[ "Paint", "the", "tab", "area", "including", "the", "tabs", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L639-L677
693
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintTab
protected void paintTab(SeaGlassContext ss, Graphics g, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { Rectangle tabRect = rects[tabIndex]; int selectedIndex = tabPane.getSelectedIndex(); boolean isSelected = selectedIndex == tabIndex; JComponent b = ss.getComponent(); boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); String segmentPosition = "only"; if (tabPane.getTabCount() > 1) { if (tabIndex == 0 && tabIndex == leadingTabIndex) { segmentPosition = flipSegments ? "last" : "first"; } else if (tabIndex == tabPane.getTabCount() - 1 && tabIndex == trailingTabIndex) { segmentPosition = flipSegments ? "first" : "last"; } else { segmentPosition = "middle"; } } b.putClientProperty("JTabbedPane.Tab.segmentPosition", segmentPosition); updateTabContext(tabIndex, isSelected, isSelected && selectedTabIsPressed, getRolloverTab() == tabIndex, getFocusIndex() == tabIndex); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, tabIndex, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, tabIndex, tabPlacement); if (tabCloseButtonPlacement != CENTER) { tabRect = paintCloseButton(g, tabContext, tabIndex); } if (tabPane.getTabComponentAt(tabIndex) == null) { String title = tabPane.getTitleAt(tabIndex); Font font = ss.getStyle().getFont(ss); FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font); Icon icon = getIconForTab(tabIndex); layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon, tabRect, iconRect, textRect, isSelected); paintText(ss, g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected); paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); } }
java
protected void paintTab(SeaGlassContext ss, Graphics g, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { Rectangle tabRect = rects[tabIndex]; int selectedIndex = tabPane.getSelectedIndex(); boolean isSelected = selectedIndex == tabIndex; JComponent b = ss.getComponent(); boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); String segmentPosition = "only"; if (tabPane.getTabCount() > 1) { if (tabIndex == 0 && tabIndex == leadingTabIndex) { segmentPosition = flipSegments ? "last" : "first"; } else if (tabIndex == tabPane.getTabCount() - 1 && tabIndex == trailingTabIndex) { segmentPosition = flipSegments ? "first" : "last"; } else { segmentPosition = "middle"; } } b.putClientProperty("JTabbedPane.Tab.segmentPosition", segmentPosition); updateTabContext(tabIndex, isSelected, isSelected && selectedTabIsPressed, getRolloverTab() == tabIndex, getFocusIndex() == tabIndex); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, tabIndex, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, tabIndex, tabPlacement); if (tabCloseButtonPlacement != CENTER) { tabRect = paintCloseButton(g, tabContext, tabIndex); } if (tabPane.getTabComponentAt(tabIndex) == null) { String title = tabPane.getTitleAt(tabIndex); Font font = ss.getStyle().getFont(ss); FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font); Icon icon = getIconForTab(tabIndex); layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon, tabRect, iconRect, textRect, isSelected); paintText(ss, g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected); paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); } }
[ "protected", "void", "paintTab", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "Rectangle", "[", "]", "rects", ",", "int", "tabIndex", ",", "Rectangle", "iconRect", ",", "Rectangle", "textRect", ")", "{", "Rectangle", "tabRect", "=", "rects", "[", "tabIndex", "]", ";", "int", "selectedIndex", "=", "tabPane", ".", "getSelectedIndex", "(", ")", ";", "boolean", "isSelected", "=", "selectedIndex", "==", "tabIndex", ";", "JComponent", "b", "=", "ss", ".", "getComponent", "(", ")", ";", "boolean", "flipSegments", "=", "(", "orientation", "==", "ControlOrientation", ".", "HORIZONTAL", "&&", "!", "tabPane", ".", "getComponentOrientation", "(", ")", ".", "isLeftToRight", "(", ")", ")", ";", "String", "segmentPosition", "=", "\"only\"", ";", "if", "(", "tabPane", ".", "getTabCount", "(", ")", ">", "1", ")", "{", "if", "(", "tabIndex", "==", "0", "&&", "tabIndex", "==", "leadingTabIndex", ")", "{", "segmentPosition", "=", "flipSegments", "?", "\"last\"", ":", "\"first\"", ";", "}", "else", "if", "(", "tabIndex", "==", "tabPane", ".", "getTabCount", "(", ")", "-", "1", "&&", "tabIndex", "==", "trailingTabIndex", ")", "{", "segmentPosition", "=", "flipSegments", "?", "\"first\"", ":", "\"last\"", ";", "}", "else", "{", "segmentPosition", "=", "\"middle\"", ";", "}", "}", "b", ".", "putClientProperty", "(", "\"JTabbedPane.Tab.segmentPosition\"", ",", "segmentPosition", ")", ";", "updateTabContext", "(", "tabIndex", ",", "isSelected", ",", "isSelected", "&&", "selectedTabIsPressed", ",", "getRolloverTab", "(", ")", "==", "tabIndex", ",", "getFocusIndex", "(", ")", "==", "tabIndex", ")", ";", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "ss", ",", "g", ",", "tabRect", ")", ";", "int", "x", "=", "tabRect", ".", "x", ";", "int", "y", "=", "tabRect", ".", "y", ";", "int", "height", "=", "tabRect", ".", "height", ";", "int", "width", "=", "tabRect", ".", "width", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBackground", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "tabIndex", ",", "tabPlacement", ")", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBorder", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "tabIndex", ",", "tabPlacement", ")", ";", "if", "(", "tabCloseButtonPlacement", "!=", "CENTER", ")", "{", "tabRect", "=", "paintCloseButton", "(", "g", ",", "tabContext", ",", "tabIndex", ")", ";", "}", "if", "(", "tabPane", ".", "getTabComponentAt", "(", "tabIndex", ")", "==", "null", ")", "{", "String", "title", "=", "tabPane", ".", "getTitleAt", "(", "tabIndex", ")", ";", "Font", "font", "=", "ss", ".", "getStyle", "(", ")", ".", "getFont", "(", "ss", ")", ";", "FontMetrics", "metrics", "=", "SwingUtilities2", ".", "getFontMetrics", "(", "tabPane", ",", "g", ",", "font", ")", ";", "Icon", "icon", "=", "getIconForTab", "(", "tabIndex", ")", ";", "layoutLabel", "(", "ss", ",", "tabPlacement", ",", "metrics", ",", "tabIndex", ",", "title", ",", "icon", ",", "tabRect", ",", "iconRect", ",", "textRect", ",", "isSelected", ")", ";", "paintText", "(", "ss", ",", "g", ",", "tabPlacement", ",", "font", ",", "metrics", ",", "tabIndex", ",", "title", ",", "textRect", ",", "isSelected", ")", ";", "paintIcon", "(", "g", ",", "tabPlacement", ",", "tabIndex", ",", "icon", ",", "iconRect", ",", "isSelected", ")", ";", "}", "}" ]
Paint a tab. @param ss the SynthContext. @param g the Graphics context. @param rects the array containing the bounds for the tabs. @param tabIndex the tab index to paint. @param iconRect the bounds in which to paint the tab icon, if any. @param textRect the bounds in which to paint the tab text, if any.
[ "Paint", "a", "tab", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L716-L763
694
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintCloseButton
protected Rectangle paintCloseButton(Graphics g, SynthContext tabContext, int tabIndex) { Rectangle tabRect = new Rectangle(rects[tabIndex]); Rectangle bounds = getCloseButtonBounds(tabIndex); int offset = bounds.width + textIconGap; boolean onLeft = isCloseButtonOnLeft(); if (onLeft) { tabRect.x += offset; tabRect.width -= offset; } else { tabRect.width -= offset; } SeaGlassContext subcontext = getContext(tabPane, SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON, getCloseButtonState(tabPane, tabIndex, (tabContext.getComponentState() & MOUSE_OVER) != 0)); SeaGlassLookAndFeel.updateSubregion(subcontext, g, bounds); SeaGlassSynthPainterImpl painter = (SeaGlassSynthPainterImpl) subcontext.getPainter(); painter.paintSearchButtonForeground(subcontext, g, bounds.x, bounds.y, bounds.width, bounds.height); subcontext.dispose(); return tabRect; }
java
protected Rectangle paintCloseButton(Graphics g, SynthContext tabContext, int tabIndex) { Rectangle tabRect = new Rectangle(rects[tabIndex]); Rectangle bounds = getCloseButtonBounds(tabIndex); int offset = bounds.width + textIconGap; boolean onLeft = isCloseButtonOnLeft(); if (onLeft) { tabRect.x += offset; tabRect.width -= offset; } else { tabRect.width -= offset; } SeaGlassContext subcontext = getContext(tabPane, SeaGlassRegion.TABBED_PANE_TAB_CLOSE_BUTTON, getCloseButtonState(tabPane, tabIndex, (tabContext.getComponentState() & MOUSE_OVER) != 0)); SeaGlassLookAndFeel.updateSubregion(subcontext, g, bounds); SeaGlassSynthPainterImpl painter = (SeaGlassSynthPainterImpl) subcontext.getPainter(); painter.paintSearchButtonForeground(subcontext, g, bounds.x, bounds.y, bounds.width, bounds.height); subcontext.dispose(); return tabRect; }
[ "protected", "Rectangle", "paintCloseButton", "(", "Graphics", "g", ",", "SynthContext", "tabContext", ",", "int", "tabIndex", ")", "{", "Rectangle", "tabRect", "=", "new", "Rectangle", "(", "rects", "[", "tabIndex", "]", ")", ";", "Rectangle", "bounds", "=", "getCloseButtonBounds", "(", "tabIndex", ")", ";", "int", "offset", "=", "bounds", ".", "width", "+", "textIconGap", ";", "boolean", "onLeft", "=", "isCloseButtonOnLeft", "(", ")", ";", "if", "(", "onLeft", ")", "{", "tabRect", ".", "x", "+=", "offset", ";", "tabRect", ".", "width", "-=", "offset", ";", "}", "else", "{", "tabRect", ".", "width", "-=", "offset", ";", "}", "SeaGlassContext", "subcontext", "=", "getContext", "(", "tabPane", ",", "SeaGlassRegion", ".", "TABBED_PANE_TAB_CLOSE_BUTTON", ",", "getCloseButtonState", "(", "tabPane", ",", "tabIndex", ",", "(", "tabContext", ".", "getComponentState", "(", ")", "&", "MOUSE_OVER", ")", "!=", "0", ")", ")", ";", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "subcontext", ",", "g", ",", "bounds", ")", ";", "SeaGlassSynthPainterImpl", "painter", "=", "(", "SeaGlassSynthPainterImpl", ")", "subcontext", ".", "getPainter", "(", ")", ";", "painter", ".", "paintSearchButtonForeground", "(", "subcontext", ",", "g", ",", "bounds", ".", "x", ",", "bounds", ".", "y", ",", "bounds", ".", "width", ",", "bounds", ".", "height", ")", ";", "subcontext", ".", "dispose", "(", ")", ";", "return", "tabRect", ";", "}" ]
Paint the close button for a tab. @param g the Graphics context. @param tabContext the SynthContext for the tab itself. @param tabIndex the tab index to paint. @return the new tab bounds.
[ "Paint", "the", "close", "button", "for", "a", "tab", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L774-L800
695
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintScrollButtonBackground
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) { Rectangle tabRect = scrollButton.getBounds(); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition", ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last"); int oldState = tabContext.getComponentState(); ButtonModel model = scrollButton.getModel(); int isPressed = model.isPressed() && model.isArmed() ? PRESSED : 0; int buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed; tabContext.setComponentState(buttonState); tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.setComponentState(oldState); }
java
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) { Rectangle tabRect = scrollButton.getBounds(); int x = tabRect.x; int y = tabRect.y; int height = tabRect.height; int width = tabRect.width; boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight()); SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect); tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition", ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last"); int oldState = tabContext.getComponentState(); ButtonModel model = scrollButton.getModel(); int isPressed = model.isPressed() && model.isArmed() ? PRESSED : 0; int buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed; tabContext.setComponentState(buttonState); tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement); tabContext.setComponentState(oldState); }
[ "protected", "void", "paintScrollButtonBackground", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "JButton", "scrollButton", ")", "{", "Rectangle", "tabRect", "=", "scrollButton", ".", "getBounds", "(", ")", ";", "int", "x", "=", "tabRect", ".", "x", ";", "int", "y", "=", "tabRect", ".", "y", ";", "int", "height", "=", "tabRect", ".", "height", ";", "int", "width", "=", "tabRect", ".", "width", ";", "boolean", "flipSegments", "=", "(", "orientation", "==", "ControlOrientation", ".", "HORIZONTAL", "&&", "!", "tabPane", ".", "getComponentOrientation", "(", ")", ".", "isLeftToRight", "(", ")", ")", ";", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "ss", ",", "g", ",", "tabRect", ")", ";", "tabPane", ".", "putClientProperty", "(", "\"JTabbedPane.Tab.segmentPosition\"", ",", "(", "(", "scrollButton", "==", "scrollBackwardButton", ")", "^", "flipSegments", ")", "?", "\"first\"", ":", "\"last\"", ")", ";", "int", "oldState", "=", "tabContext", ".", "getComponentState", "(", ")", ";", "ButtonModel", "model", "=", "scrollButton", ".", "getModel", "(", ")", ";", "int", "isPressed", "=", "model", ".", "isPressed", "(", ")", "&&", "model", ".", "isArmed", "(", ")", "?", "PRESSED", ":", "0", ";", "int", "buttonState", "=", "SeaGlassLookAndFeel", ".", "getComponentState", "(", "scrollButton", ")", "|", "isPressed", ";", "tabContext", ".", "setComponentState", "(", "buttonState", ")", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBackground", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "-", "1", ",", "tabPlacement", ")", ";", "tabContext", ".", "getPainter", "(", ")", ".", "paintTabbedPaneTabBorder", "(", "tabContext", ",", "g", ",", "x", ",", "y", ",", "width", ",", "height", ",", "-", "1", ",", "tabPlacement", ")", ";", "tabContext", ".", "setComponentState", "(", "oldState", ")", ";", "}" ]
Paint the background for a tab scroll button. @param ss the tab subregion SynthContext. @param g the Graphics context. @param scrollButton the button to paint.
[ "Paint", "the", "background", "for", "a", "tab", "scroll", "button", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L809-L832
696
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.layoutLabel
protected void layoutLabel(SeaGlassContext ss, int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected) { View v = getTextViewForTab(tabIndex); if (v != null) { tabPane.putClientProperty("html", v); } textRect.x = textRect.y = iconRect.x = iconRect.y = 0; ss.getStyle().getGraphicsUtils(ss).layoutText(ss, metrics, title, icon, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.LEADING, SwingUtilities.TRAILING, tabRect, iconRect, textRect, textIconGap); tabPane.putClientProperty("html", null); int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected); int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected); iconRect.x += xNudge; iconRect.y += yNudge; textRect.x += xNudge; textRect.y += yNudge; }
java
protected void layoutLabel(SeaGlassContext ss, int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected) { View v = getTextViewForTab(tabIndex); if (v != null) { tabPane.putClientProperty("html", v); } textRect.x = textRect.y = iconRect.x = iconRect.y = 0; ss.getStyle().getGraphicsUtils(ss).layoutText(ss, metrics, title, icon, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.LEADING, SwingUtilities.TRAILING, tabRect, iconRect, textRect, textIconGap); tabPane.putClientProperty("html", null); int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected); int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected); iconRect.x += xNudge; iconRect.y += yNudge; textRect.x += xNudge; textRect.y += yNudge; }
[ "protected", "void", "layoutLabel", "(", "SeaGlassContext", "ss", ",", "int", "tabPlacement", ",", "FontMetrics", "metrics", ",", "int", "tabIndex", ",", "String", "title", ",", "Icon", "icon", ",", "Rectangle", "tabRect", ",", "Rectangle", "iconRect", ",", "Rectangle", "textRect", ",", "boolean", "isSelected", ")", "{", "View", "v", "=", "getTextViewForTab", "(", "tabIndex", ")", ";", "if", "(", "v", "!=", "null", ")", "{", "tabPane", ".", "putClientProperty", "(", "\"html\"", ",", "v", ")", ";", "}", "textRect", ".", "x", "=", "textRect", ".", "y", "=", "iconRect", ".", "x", "=", "iconRect", ".", "y", "=", "0", ";", "ss", ".", "getStyle", "(", ")", ".", "getGraphicsUtils", "(", "ss", ")", ".", "layoutText", "(", "ss", ",", "metrics", ",", "title", ",", "icon", ",", "SwingUtilities", ".", "CENTER", ",", "SwingUtilities", ".", "CENTER", ",", "SwingUtilities", ".", "LEADING", ",", "SwingUtilities", ".", "TRAILING", ",", "tabRect", ",", "iconRect", ",", "textRect", ",", "textIconGap", ")", ";", "tabPane", ".", "putClientProperty", "(", "\"html\"", ",", "null", ")", ";", "int", "xNudge", "=", "getTabLabelShiftX", "(", "tabPlacement", ",", "tabIndex", ",", "isSelected", ")", ";", "int", "yNudge", "=", "getTabLabelShiftY", "(", "tabPlacement", ",", "tabIndex", ",", "isSelected", ")", ";", "iconRect", ".", "x", "+=", "xNudge", ";", "iconRect", ".", "y", "+=", "yNudge", ";", "textRect", ".", "x", "+=", "xNudge", ";", "textRect", ".", "y", "+=", "yNudge", ";", "}" ]
Layout label text for a tab. @param ss the SynthContext. @param tabPlacement the side the tabs are on. @param metrics the font metrics. @param tabIndex the index of the tab to lay out. @param title the text for the label, if any. @param icon the icon for the label, if any. @param tabRect Rectangle to layout text and icon in. @param iconRect Rectangle to place icon bounds in @param textRect Rectangle to place text in @param isSelected is the tab selected?
[ "Layout", "label", "text", "for", "a", "tab", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L848-L871
697
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintText
protected void paintText(SeaGlassContext ss, Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); View v = getTextViewForTab(tabIndex); if (v != null) { // html v.paint(g, textRect); } else { // plain text int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); FontMetrics fm = SwingUtilities2.getFontMetrics(tabPane, g); title = SwingUtilities2.clipStringIfNecessary(tabPane, fm, title, textRect.width); g.setColor(ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND)); ss.getStyle().getGraphicsUtils(ss).paintText(ss, g, title, textRect, mnemIndex); } }
java
protected void paintText(SeaGlassContext ss, Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); View v = getTextViewForTab(tabIndex); if (v != null) { // html v.paint(g, textRect); } else { // plain text int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); FontMetrics fm = SwingUtilities2.getFontMetrics(tabPane, g); title = SwingUtilities2.clipStringIfNecessary(tabPane, fm, title, textRect.width); g.setColor(ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND)); ss.getStyle().getGraphicsUtils(ss).paintText(ss, g, title, textRect, mnemIndex); } }
[ "protected", "void", "paintText", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "int", "tabPlacement", ",", "Font", "font", ",", "FontMetrics", "metrics", ",", "int", "tabIndex", ",", "String", "title", ",", "Rectangle", "textRect", ",", "boolean", "isSelected", ")", "{", "g", ".", "setFont", "(", "font", ")", ";", "View", "v", "=", "getTextViewForTab", "(", "tabIndex", ")", ";", "if", "(", "v", "!=", "null", ")", "{", "// html", "v", ".", "paint", "(", "g", ",", "textRect", ")", ";", "}", "else", "{", "// plain text", "int", "mnemIndex", "=", "tabPane", ".", "getDisplayedMnemonicIndexAt", "(", "tabIndex", ")", ";", "FontMetrics", "fm", "=", "SwingUtilities2", ".", "getFontMetrics", "(", "tabPane", ",", "g", ")", ";", "title", "=", "SwingUtilities2", ".", "clipStringIfNecessary", "(", "tabPane", ",", "fm", ",", "title", ",", "textRect", ".", "width", ")", ";", "g", ".", "setColor", "(", "ss", ".", "getStyle", "(", ")", ".", "getColor", "(", "ss", ",", "ColorType", ".", "TEXT_FOREGROUND", ")", ")", ";", "ss", ".", "getStyle", "(", ")", ".", "getGraphicsUtils", "(", "ss", ")", ".", "paintText", "(", "ss", ",", "g", ",", "title", ",", "textRect", ",", "mnemIndex", ")", ";", "}", "}" ]
Paint the label text for a tab. @param ss the SynthContext. @param g the Graphics context. @param tabPlacement the side the tabs are on. @param font the font to use. @param metrics the font metrics. @param tabIndex the index of the tab to lay out. @param title the text for the label, if any. @param textRect Rectangle to place text in @param isSelected is the tab selected?
[ "Paint", "the", "label", "text", "for", "a", "tab", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L886-L903
698
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.paintContentBorder
protected void paintContentBorder(SeaGlassContext ss, Graphics g, int tabPlacement, int selectedIndex) { int width = tabPane.getWidth(); int height = tabPane.getHeight(); Insets insets = tabPane.getInsets(); int x = insets.left; int y = insets.top; int w = width - insets.right - insets.left; int h = height - insets.top - insets.bottom; switch (tabPlacement) { case LEFT: x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); w -= (x - insets.left); break; case RIGHT: w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); break; case BOTTOM: h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); break; case TOP: default: y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); h -= (y - insets.top); } SeaGlassLookAndFeel.updateSubregion(ss, g, new Rectangle(x, y, w, h)); ss.getPainter().paintTabbedPaneContentBackground(ss, g, x, y, w, h); ss.getPainter().paintTabbedPaneContentBorder(ss, g, x, y, w, h); }
java
protected void paintContentBorder(SeaGlassContext ss, Graphics g, int tabPlacement, int selectedIndex) { int width = tabPane.getWidth(); int height = tabPane.getHeight(); Insets insets = tabPane.getInsets(); int x = insets.left; int y = insets.top; int w = width - insets.right - insets.left; int h = height - insets.top - insets.bottom; switch (tabPlacement) { case LEFT: x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); w -= (x - insets.left); break; case RIGHT: w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); break; case BOTTOM: h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); break; case TOP: default: y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); h -= (y - insets.top); } SeaGlassLookAndFeel.updateSubregion(ss, g, new Rectangle(x, y, w, h)); ss.getPainter().paintTabbedPaneContentBackground(ss, g, x, y, w, h); ss.getPainter().paintTabbedPaneContentBorder(ss, g, x, y, w, h); }
[ "protected", "void", "paintContentBorder", "(", "SeaGlassContext", "ss", ",", "Graphics", "g", ",", "int", "tabPlacement", ",", "int", "selectedIndex", ")", "{", "int", "width", "=", "tabPane", ".", "getWidth", "(", ")", ";", "int", "height", "=", "tabPane", ".", "getHeight", "(", ")", ";", "Insets", "insets", "=", "tabPane", ".", "getInsets", "(", ")", ";", "int", "x", "=", "insets", ".", "left", ";", "int", "y", "=", "insets", ".", "top", ";", "int", "w", "=", "width", "-", "insets", ".", "right", "-", "insets", ".", "left", ";", "int", "h", "=", "height", "-", "insets", ".", "top", "-", "insets", ".", "bottom", ";", "switch", "(", "tabPlacement", ")", "{", "case", "LEFT", ":", "x", "+=", "calculateTabAreaWidth", "(", "tabPlacement", ",", "runCount", ",", "maxTabWidth", ")", ";", "w", "-=", "(", "x", "-", "insets", ".", "left", ")", ";", "break", ";", "case", "RIGHT", ":", "w", "-=", "calculateTabAreaWidth", "(", "tabPlacement", ",", "runCount", ",", "maxTabWidth", ")", ";", "break", ";", "case", "BOTTOM", ":", "h", "-=", "calculateTabAreaHeight", "(", "tabPlacement", ",", "runCount", ",", "maxTabHeight", ")", ";", "break", ";", "case", "TOP", ":", "default", ":", "y", "+=", "calculateTabAreaHeight", "(", "tabPlacement", ",", "runCount", ",", "maxTabHeight", ")", ";", "h", "-=", "(", "y", "-", "insets", ".", "top", ")", ";", "}", "SeaGlassLookAndFeel", ".", "updateSubregion", "(", "ss", ",", "g", ",", "new", "Rectangle", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "ss", ".", "getPainter", "(", ")", ".", "paintTabbedPaneContentBackground", "(", "ss", ",", "g", ",", "x", ",", "y", ",", "w", ",", "h", ")", ";", "ss", ".", "getPainter", "(", ")", ".", "paintTabbedPaneContentBorder", "(", "ss", ",", "g", ",", "x", ",", "y", ",", "w", ",", "h", ")", ";", "}" ]
Paint the content pane's border. @param ss the SynthContext. @param g the Graphics context. @param tabPlacement the side the tabs are on. @param selectedIndex the current selected tab index.
[ "Paint", "the", "content", "pane", "s", "border", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L913-L947
699
khuxtable/seaglass
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java
SeaGlassTabbedPaneUI.ensureCurrentLayout
private void ensureCurrentLayout() { if (!tabPane.isValid()) { tabPane.validate(); } /* * If tabPane doesn't have a peer yet, the validate() call will silently * fail. We handle that by forcing a layout if tabPane is still invalid. * See bug 4237677. */ if (!tabPane.isValid()) { TabbedPaneLayout layout = (TabbedPaneLayout) tabPane.getLayout(); layout.calculateLayoutInfo(); } }
java
private void ensureCurrentLayout() { if (!tabPane.isValid()) { tabPane.validate(); } /* * If tabPane doesn't have a peer yet, the validate() call will silently * fail. We handle that by forcing a layout if tabPane is still invalid. * See bug 4237677. */ if (!tabPane.isValid()) { TabbedPaneLayout layout = (TabbedPaneLayout) tabPane.getLayout(); layout.calculateLayoutInfo(); } }
[ "private", "void", "ensureCurrentLayout", "(", ")", "{", "if", "(", "!", "tabPane", ".", "isValid", "(", ")", ")", "{", "tabPane", ".", "validate", "(", ")", ";", "}", "/*\n * If tabPane doesn't have a peer yet, the validate() call will silently\n * fail. We handle that by forcing a layout if tabPane is still invalid.\n * See bug 4237677.\n */", "if", "(", "!", "tabPane", ".", "isValid", "(", ")", ")", "{", "TabbedPaneLayout", "layout", "=", "(", "TabbedPaneLayout", ")", "tabPane", ".", "getLayout", "(", ")", ";", "layout", ".", "calculateLayoutInfo", "(", ")", ";", "}", "}" ]
Make sure we have laid out the pane with the current layout.
[ "Make", "sure", "we", "have", "laid", "out", "the", "pane", "with", "the", "current", "layout", "." ]
f25ecba622923d7b29b64cb7d6068dd8005989b3
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTabbedPaneUI.java#L952-L967