code
stringlengths
73
34.1k
label
stringclasses
1 value
public InputStream getSound (String bundle, String path) throws IOException { InputStream rsrc; try { rsrc = _rmgr.getResource(bundle, path); } catch (FileNotFoundException notFound) { // try from the classpath try { rsrc = _rmgr.ge...
java
protected Config getConfig (String packagePath) { Config c = _configs.get(packagePath); if (c == null) { Properties props = new Properties(); String propFilename = packagePath + Sounds.PROP_NAME + ".properties"; try { props = ConfigUtil.loadInherit...
java
protected byte[] loadClipData (String bundle, String path) throws IOException { InputStream clipin = null; try { clipin = getSound(bundle, path); } catch (FileNotFoundException fnfe) { // only play the default sound if we have verbose sound debugging turned on...
java
protected void init (long milliDivider, long microDivider) { _milliDivider = milliDivider; _microDivider = microDivider; reset(); log.info("Using " + getClass() + " timer", "mfreq", _milliDivider, "ufreq", _microDivider, "start", _startStamp); }
java
protected void calibrate () { long currentTimer = current(); long currentMillis = System.currentTimeMillis(); long elapsedTimer = currentTimer - _driftTimerStamp; float elapsedMillis = currentMillis - _driftMilliStamp; float drift = elapsedMillis / (elapsedTimer / _milliDivid...
java
@Override public void addRuleInstances (Digester digester) { // this creates the appropriate instance when we encounter a // <class> tag digester.addObjectCreate(_prefix + CLASS_PATH, ComponentClass.class.getName()); // grab the attributes from t...
java
public boolean insert (ObjectInfo info) { // bail if it's already in the set int ipos = indexOf(info); if (ipos >= 0) { // log a warning because the caller shouldn't be doing this log.warning("Requested to add an object to a set that already " + ...
java
public boolean remove (ObjectInfo info) { int opos = indexOf(info); if (opos >= 0) { remove(opos); return true; } else { return false; } }
java
public ObjectInfo[] toArray () { ObjectInfo[] info = new ObjectInfo[_size]; System.arraycopy(_objs, 0, info, 0, _size); return info; }
java
public BaseTile getBaseTile (int tx, int ty) { BaseTile tile = _base[index(tx, ty)]; if (tile == null && _defset != null) { tile = (BaseTile)_defset.getTile( TileUtil.getTileHash(tx, ty) % _defset.getTileCount()); } return tile; }
java
public void updateBaseTile (int fqTileId, int tx, int ty) { String errmsg = null; int tidx = index(tx, ty); // this is a bit magical: we pass the fully qualified tile id to // the tile manager which loads up from the configured tileset // repository the appropriate tileset (...
java
public void updateFringe (int tx, int ty) { int tidx = index(tx, ty); if (_base[tidx] != null) { _fringe[tidx] = computeFringeTile(tx, ty); } }
java
public void computeMemoryUsage (Map<Tile.Key,BaseTile> bases, Set<BaseTile> fringes, Map<Tile.Key,ObjectTile> objects, long[] usage) { // account for our base tiles for (int yy = 0; yy < _bounds.height; yy++) { for (int xx = 0; xx < _bounds.width; xx++...
java
protected final int index (int tx, int ty) { // if (!_bounds.contains(tx, ty)) { // String errmsg = "Coordinates out of bounds: +" + tx + "+" + ty + // " not in " + StringUtil.toString(_bounds); // throw new IllegalArgumentException(errmsg); // } retur...
java
protected void update (Map<Integer, SceneBlock> blocks) { boolean recover = false; // link up to our neighbors for (int ii = 0; ii < DX.length; ii++) { SceneBlock neigh = blocks.get(neighborKey(DX[ii], DY[ii])); if (neigh != _neighbors[ii]) { _neighbo...
java
protected final int neighborKey (int dx, int dy) { int nx = MathUtil.floorDiv(_bounds.x, _bounds.width)+dx; int ny = MathUtil.floorDiv(_bounds.y, _bounds.height)+dy; return MisoScenePanel.compose(nx, ny); }
java
protected final int blockKey (int tx, int ty) { int bx = MathUtil.floorDiv(tx, _bounds.width); int by = MathUtil.floorDiv(ty, _bounds.height); return MisoScenePanel.compose(bx, by); }
java
protected void setCovered (Map<Integer, SceneBlock> blocks, SceneObject scobj) { int endx = scobj.info.x - scobj.tile.getBaseWidth() + 1; int endy = scobj.info.y - scobj.tile.getBaseHeight() + 1; for (int xx = scobj.info.x; xx >= endx; xx--) { for (int yy = scobj.info.y; yy >= e...
java
public static void clearEditText(String editText) throws Exception{ Client.getInstance().map(Constants.ROBOTIUM_SOLO, "clearEditText", editText); }
java
public static int[] getLocationOnScreen(String view) throws Exception { int[] location = new int[2]; JSONArray results = Client.getInstance().map(Constants.ROBOTIUM_SOLO, "getLocationOnScreen", view); location[0] = results.getInt(0); location[1] = results.getInt(1); ret...
java
public void applyToTiles (Rectangle region, TileOp op) { // determine which tiles intersect this region: this is going to // be nearly incomprehensible without some sort of diagram; i'll // do what i can to comment it, but you'll want to print out a // scene diagram (docs/miso/scene....
java
public static final Tag findAncestorWithClass(Tag from, Class klass) { boolean isInterface = false; if (from == null || klass == null || (!Tag.class.isAssignableFrom(klass) && !(isInterface = klass.isInterface()))) { return null; } for (;;) { Tag tag = from.getParent(); if (tag == ...
java
public void release() { parent = null; id = null; if( values != null ) { values.clear(); } values = null; }
java
public void setValue(String k, Object o) { if (values == null) { values = new Hashtable<String, Object>(); } values.put(k, o); }
java
public Object getValue(String k) { if (values == null) { return null; } else { return values.get(k); } }
java
public static int getDirection ( MisoSceneMetrics metrics, int ax, int ay, int bx, int by) { Point afpos = new Point(), bfpos = new Point(); // convert screen coordinates to full coordinates to get both // tile coordinates and fine coordinates screenToFull(metrics, ax, ay, a...
java
public static int getProjectedIsoDirection (int ax, int ay, int bx, int by) { return toIsoDirection(DirectionUtil.getDirection(ax, ay, bx, by)); }
java
public static Point screenToTile ( MisoSceneMetrics metrics, int sx, int sy, Point tpos) { // determine the upper-left of the quadrant that contains our point int zx = (int)Math.floor((float)sx / metrics.tilewid); int zy = (int)Math.floor((float)sy / metrics.tilehei); // the...
java
public static Point tileToScreen ( MisoSceneMetrics metrics, int x, int y, Point spos) { spos.x = (x - y - 1) * metrics.tilehwid; spos.y = (x + y) * metrics.tilehhei; return spos; }
java
public static void fineToPixel ( MisoSceneMetrics metrics, int x, int y, Point ppos) { ppos.x = metrics.tilehwid + ((x - y) * metrics.finehwid); ppos.y = (x + y) * metrics.finehhei; }
java
public static void pixelToFine ( MisoSceneMetrics metrics, int x, int y, Point fpos) { // calculate line parallel to the y-axis (from the given // x/y-pos to the x-axis) float bY = y - (metrics.fineSlopeY * x); // determine intersection of x- and y-axis lines int cro...
java
public static Point screenToFull ( MisoSceneMetrics metrics, int sx, int sy, Point fpos) { // get the tile coordinates Point tpos = new Point(); screenToTile(metrics, sx, sy, tpos); // get the screen coordinates for the containing tile Point spos = tileToScreen(metri...
java
public static Point fullToScreen ( MisoSceneMetrics metrics, int x, int y, Point spos) { // get the tile screen position int tx = fullToTile(x), ty = fullToTile(y); Point tspos = tileToScreen(metrics, tx, ty, new Point()); // get the pixel position of the fine coords within ...
java
public static Polygon getTilePolygon ( MisoSceneMetrics metrics, int x, int y) { return getFootprintPolygon(metrics, x, y, 1, 1); }
java
public static Polygon getMultiTilePolygon (MisoSceneMetrics metrics, Point sp1, Point sp2) { int x = Math.min(sp1.x, sp2.x), y = Math.min(sp1.y, sp2.y); int width = Math.abs(sp1.x-sp2.x)+1, height = Math.abs(sp1.y-sp2.y)+1; return getFootprintPo...
java
public static Polygon getFootprintPolygon ( MisoSceneMetrics metrics, int x, int y, int width, int height) { SmartPolygon footprint = new SmartPolygon(); Point tpos = MisoUtil.tileToScreen(metrics, x, y, new Point()); // start with top-center point int rx = tpos.x + metrics....
java
public static Point tilePlusFineToFull (MisoSceneMetrics metrics, int tileX, int tileY, int fineX, int fineY, Point full) { int dtx = fineX / metrics.finegran; int dty ...
java
public static Client getInstance() { if(instance == null) { instance = new Client(); } instance.API_PORT = PortSingleton.getInstance().getPort(); return instance; }
java
protected void clearBubbles (boolean all) { for (Iterator<BubbleGlyph> iter = _bubbles.iterator(); iter.hasNext();) { ChatGlyph rec = iter.next(); if (all || isPlaceOrientedType(rec.getType())) { _target.abortAnimation(rec); iter.remove(); ...
java
protected String splitNear (String text, int pos) { if (pos >= text.length()) { return text; } int forward = text.indexOf(' ', pos); int backward = text.lastIndexOf(' ', pos); int newpos = (Math.abs(pos - forward) < Math.abs(pos - backward)) ? forward : backward...
java
protected Point adjustLabel (int type, Point labelpos) { switch (ChatLogic.modeOf(type)) { case ChatLogic.SHOUT: case ChatLogic.EMOTE: case ChatLogic.THINK: labelpos.translate(PAD * 2, PAD * 2); break; default: labelpos.translate(PAD, PAD)...
java
protected Rectangle getRectWithOlds (Rectangle r, List<BubbleGlyph> oldbubs) { int n = oldbubs.size(); // if no old bubs, just return the new one. if (n == 0) { return r; } // otherwise, encompass all the oldies Rectangle bigR = null; for (int ii=...
java
protected Shape getTail (int type, Rectangle r, Point speaker) { // emotes don't actually have tails if (ChatLogic.modeOf(type) == ChatLogic.EMOTE) { return new Area(); // empty shape } int midx = r.x + (r.width / 2); int midy = r.y + (r.height / 2); // ...
java
protected List<BubbleGlyph> getAndExpireBubbles (Name speaker) { int num = _bubbles.size(); // first, get all the old bubbles belonging to the user List<BubbleGlyph> oldbubs = Lists.newArrayList(); if (speaker != null) { for (int ii=0; ii < num; ii++) { B...
java
protected Label layoutText (Graphics2D gfx, Font font, String text) { Label label = _logic.createLabel(text); label.setFont(font); // layout in one line Rectangle vbounds = _target.getViewBounds(); label.setTargetWidth(vbounds.width - PAD * 2); label.layout(gfx); ...
java
protected List<Shape> getAvoidList (Name speaker) { List<Shape> avoid = Lists.newArrayList(); if (_provider == null) { return avoid; } // for now we don't accept low-priority avoids _provider.getAvoidables(speaker, avoid, null); // add the existing chatb...
java
public void queueFile (File file, boolean loop) { try { queueURL(file.toURI().toURL(), loop); } catch (MalformedURLException e) { log.warning("Invalid file url.", "file", file, e); } }
java
public ActionFrames getActionFrames ( CharacterDescriptor descrip, String action) throws NoSuchComponentException { Tuple<CharacterDescriptor, String> key = new Tuple<CharacterDescriptor, String>(descrip, action); ActionFrames frames = _actionFrames.get(key); if (frames == nu...
java
public void resolveActionSequence (CharacterDescriptor desc, String action) { try { if (getActionFrames(desc, action) == null) { log.warning("Failed to resolve action sequence " + "[desc=" + desc + ", action=" + action + "]."); } }...
java
protected long getEstimatedCacheMemoryUsage () { long size = 0; Iterator<CompositedMultiFrameImage> iter = _frameCache.values().iterator(); while (iter.hasNext()) { size += iter.next().getEstimatedMemoryUsage(); } return size; }
java
@Override public void processAuthorize(WebSocketChannel channel, String authorizeToken) { LOG.entering(CLASS_NAME, "processAuthorize"); WebSocketNativeChannel nativeChannel = (WebSocketNativeChannel)channel; Proxy proxy = nativeChannel.getProxy(); proxy.processEvent(XoaEventKind.AUT...
java
public static int byteArrayToInt(byte[] b, int offset) { int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i + offset] & 0x000000FF) << shift; } return value; }
java
public void setZations (byte primary, byte secondary, byte tertiary, byte quaternary) { zations = (primary | (secondary << 16) | (tertiary << 24) | (quaternary << 8)); }
java
public <T extends View> ArrayList<T> getFilteredViews(Class<T> classToFilterBy) { ArrayList<T> filteredViews = new ArrayList<T>(); List<View> allViews = this.getViews(); for(View view : allViews){ if (view != null && classToFilterBy.isAssignableFrom(view.getClass())) { filteredViews.add(classToFilterBy.cas...
java
public ArrayList<String> getVisibleText() { ArrayList<TextView> textViews = getFilteredViews(TextView.class); ArrayList<String> allStrings = new ArrayList<String>(); for(TextView v: textViews) { if(v.getVisibility() == View.VISIBLE) { String s...
java
public View getView(int id, int timeout) { View v = null; int RETRY_PERIOD = 250; int retryNum = timeout / RETRY_PERIOD; for (int i = 0; i < retryNum; i++) { try { v = super.getView(id); } catch (Exception e) {} if (v != null) { ...
java
public <T> boolean waitForResource(int res, int timeout) { int RETRY_PERIOD = 250; int retryNum = timeout / RETRY_PERIOD; for (int i = 0; i < retryNum; i++) { T View = (T) this.getView(res); if (View != null) { break; } if (i == ret...
java
public ArrayList<View> getCustomViews(String viewName) { ArrayList<View> returnViews = new ArrayList<View>(); for(View v: this.getViews()) { if(v.getClass().getSimpleName().equals(viewName)) returnViews.add(v); } return returnViews; }
java
public void waitForHintText(String hintText, int timeout) throws Exception { int RETRY_PERIOD = 250; int retryNum = timeout / RETRY_PERIOD; for(int i=0; i < retryNum; i++) { ArrayList<View> imageViews = getCustomViews("EditText"); for(View v: imageViews) ...
java
public void enterTextAndWait(int fieldResource, String value) { EditText textBox = (EditText) this.getView(fieldResource); this.enterText(textBox, value); this.waitForText(value); }
java
public String getLocalizedResource(String namespace, String resourceId) throws Exception { String resourceValue = ""; Class r = Class.forName(namespace + "$string"); Field f = r.getField(resourceId); resourceValue = getCurrentActivity().getResources().getString(f.getInt(f)); re...
java
public String[] getLocalizedResourceArray(String namespace, String resourceId) throws Exception { Class r = Class.forName(namespace + "$string"); Field f = r.getField(resourceId); return getCurrentActivity().getResources().getStringArray(f.getInt(f)); }
java
public void setPosition (float x, float y, float z) { if (_px != x || _py != y || _pz != z) { AL10.alListener3f(AL10.AL_POSITION, _px = x, _py = y, _pz = z); } }
java
public void setVelocity (float x, float y, float z) { if (_vx != x || _vy != y || _vz != z) { AL10.alListener3f(AL10.AL_VELOCITY, _vx = x, _vy = y, _vz = z); } }
java
public void setGain (float gain) { if (_gain != gain) { AL10.alListenerf(AL10.AL_GAIN, _gain = gain); } }
java
public boolean matches (float[] hsv, int[] fhsv) { // check to see that this color is sufficiently "close" to the // root color based on the supplied distance parameters if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) > range[0] * Short.MAX_VALUE) { return false; } ...
java
public static int[] toFixedHSV (float[] hsv, int[] fhsv) { if (fhsv == null) { fhsv = new int[hsv.length]; } for (int ii = 0; ii < hsv.length; ii++) { // fhsv[i] = (int)(hsv[i]*Integer.MAX_VALUE); fhsv[ii] = (int)(hsv[ii]*Short.MAX_VALUE); } ...
java
public static int distance (int a, int b, int N) { return (a > b) ? Math.min(a-b, b+N-a) : Math.min(b-a, a+N-b); }
java
public void setSceneModel (MisoSceneModel model) { _model = model; // clear out old blocks and objects clearScene(); centerOnTile(0, 0); if (isShowing()) { rethink(); _remgr.invalidateRegion(_vbounds); } }
java
protected void clearScene () { _blocks.clear(); _vizobjs.clear(); _fringes.clear(); _masks.clear(); if (_dpanel != null) { _dpanel.newScene(); } }
java
public void centerOnTile (int tx, int ty) { Rectangle trect = MisoUtil.getTilePolygon(_metrics, tx, ty).getBounds(); int nx = trect.x + trect.width/2 - _vbounds.width/2; int ny = trect.y + trect.height/2 - _vbounds.height/2; // Log.info("Centering on t:" + StringUtil.coordsToString(t...
java
protected void showFlagsDidChange (int oldflags) { if ((oldflags & SHOW_TIPS) != (_showFlags & SHOW_TIPS)) { for (SceneObjectIndicator indic : _indicators.values()) { dirtyIndicator(indic); } } }
java
public SceneBlock getBlock (int tx, int ty) { int bx = MathUtil.floorDiv(tx, _metrics.blockwid); int by = MathUtil.floorDiv(ty, _metrics.blockhei); return _blocks.get(compose(bx, by)); }
java
public Path getPath (Sprite sprite, int x, int y, boolean loose) { // sanity check if (sprite == null) { throw new IllegalArgumentException( "Can't get path for null sprite [x=" + x + ", y=" + y + "."); } // get the destination tile coordinates Po...
java
public Point getScreenCoords (int x, int y) { return MisoUtil.fullToScreen(_metrics, x, y, new Point()); }
java
public Point getFullCoords (int x, int y) { return MisoUtil.screenToFull(_metrics, x, y, new Point()); }
java
public Point getTileCoords (int x, int y) { return MisoUtil.screenToTile(_metrics, x, y, new Point()); }
java
public void reportMemoryUsage () { Map<Tile.Key,BaseTile> base = Maps.newHashMap(); Set<BaseTile> fringe = Sets.newHashSet(); Map<Tile.Key,ObjectTile> object = Maps.newHashMap(); long[] usage = new long[3]; for (SceneBlock block : _blocks.values()) { block.compute...
java
protected void handleObjectPressed (final SceneObject scobj, int mx, int my) { String action = scobj.info.action; final ObjectActionHandler handler = ObjectActionHandler.lookup(action); // if there's no handler, just fire the action immediately if (handler == null) { fir...
java
protected void fireObjectAction ( ObjectActionHandler handler, SceneObject scobj, ActionEvent event) { if (handler == null) { Controller.postAction(event); } else { handler.handleAction(scobj, event); } }
java
protected void appendDirtySprite (DirtyItemList list, Sprite sprite) { MisoUtil.screenToTile(_metrics, sprite.getX(), sprite.getY(), _tcoords); list.appendDirtySprite(sprite, _tcoords.x, _tcoords.y); }
java
protected void blockAbandoned (SceneBlock block) { if (_dpanel != null) { _dpanel.blockCleared(block); } blockFinished(block); }
java
protected void blockResolved (SceneBlock block) { if (_dpanel != null) { _dpanel.resolvedBlock(block); } Rectangle sbounds = block.getScreenBounds(); if (!_delayRepaint && sbounds != null && sbounds.intersects(_vbounds)) { // warnVisible(block, sbounds); ...
java
protected void blockFinished (SceneBlock block) { --_pendingBlocks; // once all the visible pending blocks have completed their // resolution, recompute our visible object set and show ourselves if (_visiBlocks.remove(block) && _visiBlocks.size() == 0) { allBlocksFinishe...
java
protected void allBlocksFinished () { recomputeVisible(); log.info("Restoring repaint... ", "left", _pendingBlocks, "view", StringUtil.toString(_vbounds)); _delayRepaint = false; // Need to restore visibility as it may have been turned of as a result of the delay ...
java
protected void warnVisible (SceneBlock block, Rectangle sbounds) { log.warning("Block visible during resolution " + block + " sbounds:" + StringUtil.toString(sbounds) + " vbounds:" + StringUtil.toString(_vbounds) + "."); }
java
protected void recomputeVisible () { // flush our visible object set which we'll recreate later _vizobjs.clear(); Rectangle vbounds = new Rectangle( _vbounds.x-_metrics.tilewid, _vbounds.y-_metrics.tilehei, _vbounds.width+2*_metrics.tilewid, _vbounds.heig...
java
public void computeIndicators () { Map<SceneObject, SceneObjectIndicator> _unupdated = Maps.newHashMap(_indicators); for (int ii = 0, nn = _vizobjs.size(); ii < nn; ii++) { SceneObject scobj = _vizobjs.get(ii); String action = scobj.info.action; // if the object ...
java
protected String getTipText (SceneObject scobj, String action) { ObjectActionHandler oah = ObjectActionHandler.lookup(action); return (oah == null) ? action : oah.getTipText(action); }
java
protected Icon getTipIcon (SceneObject scobj, String action) { ObjectActionHandler oah = ObjectActionHandler.lookup(action); return (oah == null) ? null : oah.getTipIcon(action); }
java
protected void dirtyIndicator (SceneObjectIndicator indic) { if (indic != null) { Rectangle r = indic.getBounds(); if (r != null) { _remgr.invalidateRegion(r); } } }
java
protected void changeHoverObject (Object newHover) { if (newHover == _hobject) { return; } Object oldHover = _hobject; _hobject = newHover; hoverObjectChanged(oldHover, newHover); }
java
protected void hoverObjectChanged (Object oldHover, Object newHover) { // deal with objects that care about being hovered over if (oldHover instanceof SceneObject) { SceneObject oldhov = (SceneObject)oldHover; if (oldhov.setHovered(false)) { _remgr.invalidateR...
java
protected void getHitObjects (DirtyItemList list, int x, int y) { for (SceneObject scobj : _vizobjs) { Rectangle pbounds = scobj.bounds; if (!pbounds.contains(x, y)) { continue; } // see if we should skip it if (skipHitObject(scobj...
java
@Override protected void paintBits (Graphics2D gfx, int layer, Rectangle dirty) { _animmgr.paint(gfx, layer, dirty); }
java
protected void paintDirtyItems (Graphics2D gfx, Rectangle clip) { // add any sprites impacted by the dirty rectangle _dirtySprites.clear(); _spritemgr.getIntersectingSprites(_dirtySprites, clip); int size = _dirtySprites.size(); for (int ii = 0; ii < size; ii++) { ...
java
protected void paintIndicators (Graphics2D gfx, Rectangle clip) { // make sure the indicators are ready if (!_indicatorsLaidOut) { for (Map.Entry<SceneObject, SceneObjectIndicator> entry : _indicators.entrySet()) { SceneObjectIndicator indic = entry.getValue(); ...
java
protected void paintIndicator (Graphics2D gfx, Rectangle clip, SceneObjectIndicator tip) { if (clip.intersects(tip.getBounds())) { tip.paint(gfx); } }
java
protected void paintTiles (Graphics2D gfx, Rectangle clip) { // go through rendering our tiles _paintOp.setGraphics(gfx); _applicator.applyToTiles(clip, _paintOp); _paintOp.setGraphics(null); }
java
protected void fillTile ( Graphics2D gfx, int tx, int ty, Color color) { Composite ocomp = gfx.getComposite(); gfx.setComposite(ALPHA_FILL_TILE); Polygon poly = MisoUtil.getTilePolygon(_metrics, tx, ty); gfx.setColor(color); gfx.fill(poly); gfx.setComposite(oc...
java