code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected BaseTile getBaseTile (int tx, int ty)
{
SceneBlock block = getBlock(tx, ty);
return (block == null) ? null : block.getBaseTile(tx, ty);
} | java |
protected BaseTile getFringeTile (int tx, int ty)
{
SceneBlock block = getBlock(tx, ty);
return (block == null) ? null : block.getFringeTile(tx, ty);
} | java |
protected void notifyListeners (int event)
{
int size = _listeners.size();
for (int ii = 0; ii < size; ii++) {
_listeners.get(ii).modelChanged(event);
}
} | java |
public List<Integer> getComponents (ComponentClass cclass)
{
List<Integer> list = _components.get(cclass);
if (list == null) {
list = Lists.newArrayList();
}
return list;
} | java |
public int[] getSelectedComponents ()
{
int[] values = new int[_selected.size()];
Iterator<Integer> iter = _selected.values().iterator();
for (int ii = 0; iter.hasNext(); ii++) {
values[ii] = iter.next().intValue();
}
return values;
} | java |
public void setSelectedComponent (ComponentClass cclass, int cid)
{
_selected.put(cclass, Integer.valueOf(cid));
notifyListeners(BuilderModelListener.COMPONENT_CHANGED);
} | java |
protected void gatherComponentInfo (ComponentRepository crepo)
{
// get the list of all component classes
Iterators.addAll(_classes, crepo.enumerateComponentClasses());
for (int ii = 0; ii < _classes.size(); ii++) {
// get the list of components available for this class
... | java |
public static long getOldestLastModified (File dir)
{
long oldest = dir.lastModified();
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
oldest = Math.min(oldest, getOldestLastModified(fil... | java |
public Set<Integer> intKeySet() {
return data.keySet().stream()
.map(Any2::getLeft)
.flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty))
.collect(Collectors.toSet());
} | java |
public Set<String> stringKeySet() {
return data.keySet().stream()
.map(Any2::getRight)
.flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty))
.collect(Collectors.toSet());
} | java |
public Map<Any2<Integer, String>, Any3<Boolean, Integer, String>> getRawMap() {
return unmodifiableMap(data);
} | java |
public Map<Any2<Integer, String>, String> getStringMap() {
return data.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mapCombine(Object::toString, Object::toString, Object::toString)));
} | java |
protected void generateSprite ()
{
int components[] = _model.getSelectedComponents();
CharacterDescriptor desc = new CharacterDescriptor(components, null);
CharacterSprite sprite = _charmgr.getCharacter(desc);
setSprite(sprite);
} | java |
protected void setSprite (CharacterSprite sprite)
{
sprite.setActionSequence(StandardActions.STANDING);
sprite.setOrientation(WEST);
_sprite = sprite;
centerSprite();
repaint();
} | java |
protected void centerSprite ()
{
if (_sprite != null) {
Dimension d = getSize();
int shei = _sprite.getHeight();
int x = d.width / 2, y = (d.height + shei) / 2;
_sprite.setLocation(x, y);
}
} | java |
public SimpleMisoSceneModel parseScene (InputStream in)
throws IOException, SAXException
{
_model = null;
_digester.push(this);
_digester.parse(in);
return _model;
} | java |
public void setGain (float gain)
{
_gain = gain;
if (_fadeMode == FadeMode.NONE) {
_source.setGain(_gain);
}
} | java |
public void play ()
{
if (_state == AL10.AL_PLAYING) {
log.warning("Tried to play stream already playing.");
return;
}
if (_state == AL10.AL_INITIAL) {
_qidx = _qlen = 0;
queueBuffers(_buffers.length);
}
_source.play();
... | java |
public void pause ()
{
if (_state != AL10.AL_PLAYING) {
log.warning("Tried to pause stream that wasn't playing.");
return;
}
_source.pause();
_state = AL10.AL_PAUSED;
} | java |
public void stop ()
{
if (_state == AL10.AL_STOPPED) {
log.warning("Tried to stop stream that was already stopped.");
return;
}
_source.stop();
_state = AL10.AL_STOPPED;
} | java |
public void fadeIn (float interval)
{
if (_state != AL10.AL_PLAYING) {
play();
}
_source.setGain(0f);
_fadeMode = FadeMode.IN;
_fadeInterval = interval;
_fadeElapsed = 0f;
} | java |
public void fadeOut (float interval, boolean dispose)
{
_fadeMode = dispose ? FadeMode.OUT_DISPOSE : FadeMode.OUT;
_fadeInterval = interval;
_fadeElapsed = 0f;
} | java |
public void dispose ()
{
// make sure the stream is stopped
if (_state != AL10.AL_STOPPED) {
stop();
}
// delete the source and buffers
_source.delete();
for (Buffer buffer : _buffers) {
buffer.delete();
}
// remove from manag... | java |
protected void updateFade (float time)
{
if (_fadeMode == FadeMode.NONE) {
return;
}
float alpha = Math.min((_fadeElapsed += time) / _fadeInterval, 1f);
_source.setGain(_gain * (_fadeMode == FadeMode.IN ? alpha : (1f - alpha)));
if (alpha == 1f) {
if (... | java |
protected boolean populateBuffer (Buffer buffer)
{
if (_abuf == null) {
_abuf = ByteBuffer.allocateDirect(getBufferSize()).order(ByteOrder.nativeOrder());
}
_abuf.clear();
int read = 0;
try {
read = Math.max(populateBuffer(_abuf), 0);
} catch (... | java |
private Map<MetricName, MetricValue> get_metrics_(DateTime now, Context ctx) {
final Consumer<Alert> alert_manager = ctx.getAlertManager();
final long failed_collections = registry_.getFailedCollections();
final boolean has_config = registry_.hasConfig();
final Optional<Duration> scrape_... | java |
@Override
public void transform(Context<MutableTimeSeriesCollectionPair> ctx) {
DateTime now = ctx.getTSData().getCurrentCollection().getTimestamp();
ctx.getTSData().getCurrentCollection().addMetrics(MONITOR_GROUP, get_metrics_(now, ctx));
ctx.getAlertManager().accept(new Alert(now, MONITO... | java |
private static MetricValue opt_duration_to_metricvalue_(Optional<Duration> duration) {
return duration
.map(MonitorMonitor::duration_to_metricvalue_)
.orElse(MetricValue.EMPTY);
} | java |
private void validate() {
try {
DateTime ts;
ts = current.getTimestamp();
for (TimeSeriesCollection b : backward) {
if (b.getTimestamp().isAfter(ts))
throw new IllegalArgumentException("backwards collection must be before current and be or... | java |
private static Set<GroupName> calculateNames(TimeSeriesCollection current, Collection<TimeSeriesCollection> backward, Collection<TimeSeriesCollection> forward) {
final Set<GroupName> names = backward.stream()
.flatMap(tsc -> tsc.getGroups(x -> true).stream())
.collect(Collectors.... | java |
private TimeSeriesValue interpolateTSV(GroupName name) {
final Map.Entry<DateTime, TimeSeriesValue> backTSV = findName(backward, name),
forwTSV = findName(forward, name);
final long backMillis = max(new Duration(backTSV.getKey(), getTimestamp()).getMillis(), 0),
forwMill... | java |
private static Map.Entry<DateTime, TimeSeriesValue> findName(List<TimeSeriesCollection> c, GroupName name) {
ListIterator<TimeSeriesCollection> iter = c.listIterator();
while (iter.hasNext()) {
final int idx = iter.nextIndex();
final TimeSeriesCollection tsdata = iter.next();
... | java |
protected void createBackBuffer (GraphicsConfiguration gc)
{
// if we have an old image, clear it out
if (_backimg != null) {
_backimg.flush();
_bgfx.dispose();
}
// create the offscreen buffer
int width = _window.getWidth(), height = _window.getHeigh... | java |
public static void trimTileSet (
TileSet source, OutputStream destImage, TrimMetricsReceiver tmr)
throws IOException
{
trimTileSet(source, destImage, tmr, FastImageIO.FILE_SUFFIX);
} | java |
public static void setRegisterWithVM(final boolean registerWithVM) {
if (Converters.registerWithVM != registerWithVM) {
Converters.registerWithVM = registerWithVM;
// register all converters with the VM
if (registerWithVM) {
for (Entry<Class, Converter> entry : REGISTRY.entrySet()) {
... | java |
private static PropertyEditor findEditor(final Type type) {
assert type != null;
Class clazz = toClass(type);
// try to locate this directly from the editor manager first.
PropertyEditor editor = PropertyEditorManager.findEditor(clazz);
// we're outta here if we got one.
if (editor != null) {
... | java |
public static int[] quantizeImage(int pixels[][], int max_colors) {
Cube cube = new Cube(pixels, max_colors);
cube.classification();
cube.reduction();
cube.assignment();
return cube.colormap;
} | java |
public void paint (Graphics2D gfx, int layer, Shape clip)
{
for (int ii = 0, nn = _media.size(); ii < nn; ii++) {
AbstractMedia media = _media.get(ii);
int order = media.getRenderOrder();
try {
if (((layer == ALL) || (layer == FRONT && order >= 0) ||
... | java |
public void fastForward (long timeDelta)
{
if (_tickStamp > 0) {
log.warning("Egads! Asked to fastForward() during a tick.", new Exception());
}
for (int ii = 0, nn = _media.size(); ii < nn; ii++) {
_media.get(ii).fastForward(timeDelta);
}
} | java |
protected boolean insertMedia (AbstractMedia media)
{
if (_media.contains(media)) {
log.warning("Attempt to insert media more than once [media=" + media + "].",
new Exception());
return false;
}
media.init(this);
int ipos = _media.inse... | java |
protected boolean removeMedia (AbstractMedia media)
{
int mpos = _media.indexOf(media);
if (mpos != -1) {
_media.remove(mpos);
media.invalidate();
media.shutdown();
// if we're in the middle of ticking, we need to adjust the _tickpos if necessary
... | java |
public void queueNotification (ObserverList<Object> observers, ObserverOp<Object> event)
{
_notify.add(new Tuple<ObserverList<Object>,ObserverOp<Object>>(observers, event));
} | java |
protected void dispatchNotifications ()
{
for (int ii = 0, nn = _notify.size(); ii < nn; ii++) {
Tuple<ObserverList<Object>,ObserverOp<Object>> tuple = _notify.get(ii);
tuple.left.apply(tuple.right);
}
_notify.clear();
} | java |
public static <T> void addArrayIfNotNull(JSONWriter writer, String field,
Collection<T> items, JsonObjectWriter<T> objWriter)
throws JSONException {
if (items == null)
return;
addCollection(writer, field, items, objWriter);
} | java |
protected void startAnimation (Animation anim, long tickStamp)
{
// account for any view scrolling that happened before this animation
// was actually added to the view
if (_vdx != 0 || _vdy != 0) {
anim.viewLocationDidChange(_vdx, _vdy);
}
_animmgr.registerAnima... | java |
public void setScrollableArea (int x, int y, int width, int height)
{
Rectangle vb = _panel.getViewBounds();
int hmax = x + width, vmax = y + height, value;
if (width > vb.width) {
value = MathUtil.bound(x, _hrange.getValue(), hmax - vb.width);
_hrange.setRangeProper... | java |
public BufferedImage createImage (int width, int height, int transparency)
{
return _icreator.createImage(width, height, transparency);
} | java |
public ImageKey getImageKey (String rset, String path)
{
return getImageKey(getDataProvider(rset), path);
} | java |
public BufferedImage getImage (ImageKey key, Colorization[] zations)
{
CacheRecord crec = null;
synchronized (_ccache) {
crec = _ccache.get(key);
}
if (crec != null) {
// log.info("Cache hit", "key", key, "crec", crec);
return crec.getImage(zations... | java |
public Mirage getMirage (String rsrcPath)
{
return getMirage(getImageKey(_defaultProvider, rsrcPath), null, null);
} | java |
protected ImageDataProvider getDataProvider (final String rset)
{
if (rset == null) {
return _defaultProvider;
}
ImageDataProvider dprov = _providers.get(rset);
if (dprov == null) {
dprov = new ImageDataProvider() {
public BufferedImage loadIm... | java |
protected BufferedImage loadImage (ImageKey key)
{
// if (EventQueue.isDispatchThread()) {
// Log.info("Loading image on AWT thread " + key + ".");
// }
BufferedImage image = null;
try {
log.debug("Loading image " + key + ".");
image = key.daprov.... | java |
public void setPosition (float x, float y, float z)
{
if (_source != null) {
_source.setPosition(x, y, z);
}
_px = x;
_py = y;
_pz = z;
} | java |
public void setVelocity (float x, float y, float z)
{
if (_source != null) {
_source.setVelocity(x, y, z);
}
_vx = x;
_vy = y;
_vz = z;
} | java |
public void setDirection (float x, float y, float z)
{
if (_source != null) {
_source.setDirection(x, y, z);
}
_dx = x;
_dy = y;
_dz = z;
} | java |
public static MediaTimer createTimer ()
{
MediaTimer timer = null;
for (String timerClass : PERF_TIMERS) {
try {
timer = (MediaTimer)Class.forName(timerClass).newInstance();
break;
} catch (Throwable t) {
// try the next one
... | java |
public static FrameManager newInstance (ManagedRoot root, MediaTimer timer)
{
FrameManager fmgr = (root instanceof ManagedJFrame && _useFlip.getValue()) ?
new FlipFrameManager() : new BackFrameManager();
fmgr.init(root, timer);
return fmgr;
} | java |
public void registerFrameParticipant (FrameParticipant participant)
{
Object[] nparts = ListUtil.testAndAddRef(_participants, participant);
if (nparts == null) {
log.warning("Refusing to add duplicate frame participant! " + participant);
} else {
_participants = npart... | java |
public TrailingAverage[] getPerfMetrics ()
{
if (_metrics == null) {
_metrics = new TrailingAverage[] {
new TrailingAverage(150), new TrailingAverage(150), new TrailingAverage(150)
};
}
return _metrics;
} | java |
public static Component getRoot (Component comp, Rectangle rect)
{
for (Component c = comp; c != null; c = c.getParent()) {
if (!c.isVisible() || !c.isDisplayable()) {
return null;
}
if (c instanceof Window || c instanceof Applet) {
return ... | java |
protected void init (ManagedRoot root, MediaTimer timer)
{
_window = root.getWindow();
_root = root;
_root.init(this);
_timer = timer;
// set up our custom repaint manager
_repainter = new ActiveRepaintManager(
(_root instanceof Component) ? (Component)_r... | java |
protected void tick (long tickStamp)
{
long start = 0L, paint = 0L;
if (_perfDebug.getValue()) {
start = paint = _timer.getElapsedMicros();
}
// if our frame is not showing (or is impossibly sized), don't try rendering anything
if (_window.isShowing() && _window.... | java |
protected boolean paint (Graphics2D gfx)
{
// paint our frame participants (which want to be handled specially)
int painted = 0;
for (Object participant : _participants) {
FrameParticipant part = (FrameParticipant)participant;
if (part == null) {
conti... | java |
protected void renderLayer (Graphics2D g, Rectangle bounds, JLayeredPane pane,
boolean[] clipped, Integer layer)
{
// stop now if there are no components in that layer
int ccount = pane.getComponentCountInLayer(layer.intValue());
if (ccount == 0) {
... | java |
public static <T> Iterator<T> distinct(final Iterator<T> iterator) {
requireNonNull(iterator);
return new AbstractIterator<T>() {
private final PeekingIterator<T> peekingIterator = peekingIterator(iterator);
private T curr = null;
@Override
protected T co... | java |
public ActionFrames getFrames (String action, String type)
{
return _frameProvider.getFrames(this, action, type);
} | java |
public String getFramePath (String action, String type, Set<String> existentPaths)
{
return _frameProvider.getFramePath(this, action, type, existentPaths);
} | java |
protected OutputStream nextEntry (OutputStream lastEntry, String path)
throws IOException
{
((JarOutputStream)lastEntry).putNextEntry(new JarEntry(path));
return lastEntry;
} | java |
public QueryBuilder map(String query, String method_name, Object... items) throws Exception {
JSONObject op = new JSONObject();
if (query != null)
op.put(Constants.REQUEST_QUERY, query);
java.util.Map<String, Object> operation = new LinkedHashMap<String, Object>();
operation... | java |
public QueryBuilder instantiate(String query, Object... items) throws Exception {
JSONObject op = new JSONObject();
if (query != null)
op.put(Constants.REQUEST_INSTANTIATE, query);
if (query != null)
queryStringRepresentation += query;
op.put(Constants.REQUEST_A... | java |
private JSONArray buildArgsArray(Object ... items) throws Exception {
JSONArray args = new JSONArray();
for (int i = 0; i < items.length; i++) {
if (items[i] instanceof java.lang.String)
{
args.put((String) items[i]);
}
else if (items[i] i... | java |
private QueryBuilder genericRequest(String type, String value) throws Exception {
JSONObject op = new JSONObject();
op.put(type, value);
JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS);
operations.put(op);
request.remove(Constants.REQUEST_OPERATIONS);... | java |
public JSONArray execute() throws Exception {
try {
JSONArray retVal = Client.getInstance(port).map(toString());
return retVal;
} catch (Exception e) {
throw new Exception(queryStringRepresentation + ": " + e.getMessage());
}
} | java |
protected Object getInstantiatedClass(String query) {
if (query.equals(Constants.UIAUTOMATOR_UIDEVICE)) {
return device;
}
return null;
} | java |
public synchronized void setHistory(CollectHistory history) {
history_ = Optional.of(history);
history_.ifPresent(getApi()::setHistory);
data_.initWithHistoricalData(history, getDecoratorLookBack());
} | java |
@Override
protected synchronized CollectionContext beginCollection(DateTime now) {
data_.startNewCycle(now, getDecoratorLookBack());
return new CollectionContext() {
final Map<GroupName, Alert> alerts = new HashMap<>();
@Override
public Consumer<Alert> alertMana... | java |
private static Alert combine_alert_with_past_(Alert alert, Map<GroupName, Alert> previous) {
Alert result = Optional.ofNullable(previous.get(alert.getName()))
.map((prev) -> prev.extend(alert))
.orElse(alert);
logger.log(Level.FINE, "emitting alert {0} -> {1}", new Object... | java |
public static synchronized PushMetricRegistryInstance create(Supplier<DateTime> now, boolean has_config, EndpointRegistration api) {
return new PushMetricRegistryInstance(now, has_config, api);
} | java |
public static Mirage newNinePatchContaining(NinePatch ninePatch, Rectangle content)
{
Rectangle bounds = ninePatch.getBoundsSurrounding(content);
Mirage mirage = new NinePatchMirage(ninePatch, bounds.width, bounds.height);
return new TransformedMirage(mirage,
AffineTransform.get... | java |
public static boolean isDisjoint(Collection<Range> ranges) {
List<Range> rangesList = new ArrayList<Range>(ranges.size());
rangesList.addAll(ranges);
Collections.sort(rangesList);
for (int i = 0; i < rangesList.size() - 1; i++) {
Range rCurrent = rangesList.get(i);
... | java |
private static EscapeStringResult escapeString(String s, char quote) {
final String[] octal_strings = {
"\\0", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\a",
"\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\016", "\\017",
"\\020", "\\021", "\\022", "\\... | java |
public static StringBuilder quotedString(String s) {
final EscapeStringResult escapeString = escapeString(s, '\"');
final StringBuilder result = escapeString.buffer;
result.insert(0, '\"');
result.append('\"');
return result;
} | java |
public static StringBuilder maybeQuoteIdentifier(String s) {
final EscapeStringResult escapeString = escapeString(s, '\'');
final StringBuilder result = escapeString.buffer;
final boolean need_quotes = s.isEmpty() ||
escapeString.needQuotes ||
KEYWORDS.contains(s... | java |
public static StringBuilder durationConfigString(Duration duration) {
Duration remainder = duration;
long days = remainder.getStandardDays();
remainder = remainder.minus(Duration.standardDays(days));
long hours = remainder.getStandardHours();
remainder = remainder.minus(Duratio... | java |
public <R> R download(String uri,
ContentHandler<BasicHttpResponse, R> handler)
throws RedmineException {
final HttpGet request = new HttpGet(uri);
return errorCheckingCommunicator.sendRequest(request, handler);
} | java |
public String upload(InputStream content) throws RedmineException {
final URI uploadURI = getURIConfigurator().getUploadURI();
final HttpPost request = new HttpPost(uploadURI);
final AbstractHttpEntity entity = new InputStreamEntity(content, -1);
/* Content type required by a Redmine */
entity.setContentType(... | java |
public <T> List<T> getObjectsList(Class<T> objectClass,
Collection<? extends NameValuePair> params) throws RedmineException {
final EntityConfig<T> config = getConfig(objectClass);
final List<T> result = new ArrayList<T>();
final List<NameValuePair> newParams = new ArrayList<NameValuePair>(
params);
ne... | java |
@Nonnull
protected Completer discoverCompleter() {
log.debug("Discovering completer");
// TODO: Could probably use CliProcessorAware to avoid re-creating this
CliProcessor cli = new CliProcessor();
cli.addBean(this);
List<ArgumentDescriptor> argumentDescriptors = cli.getArgumentDescriptors();
... | java |
public static SimpleGraph<String, DefaultEdge> getSimpleGraphFromUser() {
Scanner sc = new Scanner(System.in);
SimpleGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
// input number of vertices
int verticeAmount;
do {
System... | java |
public void getTrimmedBounds (Rectangle tbounds)
{
tbounds.setBounds(_tbounds.x, _tbounds.y, _mirage.getWidth(), _mirage.getHeight());
} | java |
public Rectangle getBoundsSurrounding (Rectangle content)
{
Rectangle bounds = new Rectangle(content);
bounds.width += _leftPad + _rightPad;
bounds.height += _topPad + _bottomPad;
bounds.x -= _leftPad;
bounds.y -= _topPad;
return bounds;
} | java |
protected static Rectangle getRectangle (BufferedImage img, boolean stretch)
{
Rectangle rect = new Rectangle(0, 0, img.getWidth() - 2, img.getHeight() - 2);
for (int xx = 1; xx < rect.width + 1; xx++) {
if (ImageUtil.hitTest(img, xx, stretch ? 0 : img.getHeight() - 1)) {
... | java |
public void appendDirtySprite (Sprite sprite, int tx, int ty)
{
DirtyItem item = getDirtyItem();
item.init(sprite, tx, ty);
_items.add(item);
} | java |
public void appendDirtyObject (SceneObject scobj)
{
DirtyItem item = getDirtyItem();
item.init(scobj, scobj.info.x, scobj.info.y);
_items.add(item);
} | java |
public void paintAndClear (Graphics2D gfx)
{
int icount = _items.size();
for (int ii = 0; ii < icount; ii++) {
DirtyItem item = _items.get(ii);
item.paint(gfx);
item.clear();
_freelist.add(item);
}
_items.clear();
} | java |
public void clear ()
{
for (int icount = _items.size(); icount > 0; icount--) {
DirtyItem item = _items.remove(0);
item.clear();
_freelist.add(item);
}
} | java |
private Intermediate mapAndReduce(Context ctx) {
/* Fetch each metric wildcard and add it to the to-be-processed list. */
final List<Map.Entry<Tags, MetricValue>> matcher_tsvs = matchers_.stream()
.flatMap(m -> m.filter(ctx))
.map(named_entry -> SimpleMapEntry.create(name... | java |
public List<Issue> getIssues(Map<String, String> pParameters) throws RedmineException {
Set<NameValuePair> params = new HashSet<NameValuePair>();
for (final Entry<String, String> param : pParameters.entrySet()) {
params.add(new BasicNameValuePair(param.getKey(), param.getValue()));
... | java |
public void deleteRelation(Integer id) throws RedmineException {
transport.deleteObject(IssueRelation.class, Integer.toString(id));
} | java |
public Attachment uploadAttachment(String fileName, String contentType,
InputStream content) throws RedmineException, IOException {
final InputStream wrapper = new MarkedInputStream(content,
"uploadStream");
final String token;
try {
token = transport.upload(wrapper);
final Attachment result = new At... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.