Java 8 ORB - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ORB class.

This code example shows how to use the following methods:resolve_initial_references, run
        //not created 
    } 
     
     
    static int run(ORB orb, String[] args) throws UserException {
        // 
        // Resolve Root POA 
        // 
        POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
 
        // 
        // Get a reference to the POA manager 
        // 
        POAManager manager = poa.the_POAManager();
 
        // 
        // Create implementation object 
        // 
        BankImpl bankImpl = new BankImpl(poa);
 

6
CodeRank
This code example shows how to use the following methods:create_interface_tc, create_output_stream, string_to_object
     
    @Test
    public void testWriteObject() throws IOException {
        URL refUrl = getClass().getResource("/references/account.ref");
        String oRef = IOUtils.toString(refUrl.openStream()).trim();
        org.omg.CORBA.Object objRef = 
            orb.string_to_object(oRef);
        assertNotNull(objRef);
         
        // create a test object 
        org.apache.cxf.binding.corba.wsdl.Object objectType = 
            new org.apache.cxf.binding.corba.wsdl.Object(); 
        objectType.setRepositoryID("IDL:Account:1.0");
        objectType.setBinding(new QName("AccountCORBABinding"));
         
        QName objectName = new QName("TestObject");
        QName objectIdlType = new QName("corbaatm:TestObject");
        TypeCode objectTC = orb.create_interface_tc("IDL:Account:1.0", "TestObject");
         
        CorbaObjectReferenceHandler obj = new CorbaObjectReferenceHandler(objectName, objectIdlType, 

5
CodeRank
This code example shows how to use the following methods:create_interface_tc, create_output_stream, string_to_object
        assertTrue(obj.getValue().equals(new java.math.BigDecimal("12345.67")));
    } 
     
    @Test
    public void testReadObjectReference() throws IOException {
        OutputStream oStream = orb.create_output_stream();
         
        URL refUrl = getClass().getResource("/references/account.ref");
        String oRef = IOUtils.toString(refUrl.openStream()).trim();
        org.omg.CORBA.Object objRef = 
            orb.string_to_object(oRef);
         
        assertNotNull(objRef);
        oStream.write_Object(objRef);
        // we need an ORBinstance to handle reading objects so use the input stream  
        InputStream iStream = oStream.create_input_stream();
         
        CorbaObjectReader reader = new CorbaObjectReader(iStream);
         
        // create a test object 

5
CodeRank
This code example shows how to use the following methods:setDuration, setFillAfter, setFillEnabled, setInterpolator
			if(olddegree == 0 && newdegree == 270){
				newdegree = -90;
			} else if(olddegree == 270 && newdegree == 0){
				newdegree = 360;
			} 
			retval = new RotateAnimation(olddegree,
					newdegree,
					Animation.RELATIVE_TO_SELF,
					0.5f, 
					Animation.RELATIVE_TO_SELF,
					0.5f); 
 
			retval.setDuration(500);
			retval.setFillEnabled(true);
			retval.setFillAfter(true);
			retval.setInterpolator(new DecelerateInterpolator());
		} 
 
		return retval;
	} 
	 
8
CodeRank
This code example shows how to use the following methods:setDuration, setFillAfter, setInterpolator, setStartOffset
This code example shows how to use the following methods:
	 
	@Test 
	public void testAnimationList() { 
		Animation alpha = new AlphaAnimation(1f, 2f);
		Animation translate =  new TranslateAnimation(1f, 2f, 3f, 4f);
		Animation rotate = new RotateAnimation(1f, 2f);
		set.addAnimation(alpha);
		set.addAnimation(translate);
		set.addAnimation(rotate);
		 
		List<Animation> list = shadow.getAnimations();
        assertThat(list.size()).isEqualTo(3);
        assertThat(list.get(0)).isSameAs(alpha);
        assertThat(list.get(1)).isSameAs(translate);
        assertThat(list.get(2)).isSameAs(rotate);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:centerX
        ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams();
        param.leftMargin = getArrowLeftMargin(arrow);
    } 
     
    protected int getArrowLeftMargin(View arrow) {
    	return mRect.centerX() - (arrow.getMeasuredWidth()) / 2;    	
    } 
 
    private void prepareAnimationStyle() { 
 
        final int screenWidth = mScreenWidth;
        final boolean onTop = mIsOnTop;
        final int arrowPointX = mRect.centerX();
 
        if (arrowPointX <= screenWidth / 4) {
            setAnimationStyle(onTop ? R.style.GreenDroid_Animation_PopUp_Left
                    : R.style.GreenDroid_Animation_PopDown_Left); 
        } else if (arrowPointX >= 3 * screenWidth / 4) {
            setAnimationStyle(onTop ? R.style.GreenDroid_Animation_PopUp_Right
                    : R.style.GreenDroid_Animation_PopDown_Right); 
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, width
    /** 
     * Returns center x-coordinate of this arc shape. 
     * @return center x-coordinate of this arc shape 
     */ 
    public float getCenterX() { 
        return mOval.centerX();
    } 
     
    /** 
     * Returns center y-coordinate of this arc shape. 
     * @return center y-coordinate of this arc shape 
     */ 
    public float getCenterY() { 
        return mOval.centerY();
    } 
     
    /** 
     * Returns start angle of the arc in degrees. 
     * @return The start angle of the arc in degrees 
     */ 

7
CodeRank
This code example shows how to use the following methods:getMatrix, restore, rotateX, rotateY, rotateZ
        final float rX = mRotationX;
        final float rY = mRotationY;
        final float rZ = mRotationZ;
        if ((rX != 0) || (rY != 0) || (rZ != 0)) {
            final Camera camera = mCamera;
            camera.save();
            camera.rotateX(rX);
            camera.rotateY(rY);
            camera.rotateZ(-rZ);
            camera.getMatrix(m);
            camera.restore();
            m.preTranslate(-pX, -pY);
            m.postTranslate(pX, pY);
        } 
 
        final float sX = mScaleX;
        final float sY = mScaleY;
        if ((sX != 1.0f) || (sY != 1.0f)) {
            m.postScale(sX, sY);
            final float sPX = -(pX / w) * ((sX * w) - w);
9
CodeRank
This code example shows how to use the following methods:getA, getB, getField
       EllipticCurve curve, 
       byte[] encoded)
    { 
        ECCurve c = null;
         
        if (curve.getField() instanceof ECFieldFp)
        { 
            c = new ECCurve.Fp(
                    ((ECFieldFp)curve.getField()).getP(), curve.getA(), curve.getB());
        } 
        else 
        { 
            int k[] = ((ECFieldF2m)curve.getField()).getMidTermsOfReductionPolynomial();
             
            if (k.length == 3)
            { 
                c = new ECCurve.F2m(
                        ((ECFieldF2m)curve.getField()).getM(), k[2], k[1], k[0], curve.getA(), curve.getB());
            } 
            else 

7
CodeRank
This code example shows how to use the following methods:addTestListener
        } 
    } 
 
	/** you can subclass and override this if you want to use a different TestRunner */ 
	protected AndroidTestRunner makeAndroidTestRunner() {
		return new AndroidTestRunner();
	} 
	 
    @Override 
    protected AndroidTestRunner getAndroidTestRunner() {
        AndroidTestRunner runner = makeAndroidTestRunner();
        mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
        runner.addTestListener(mListener);
        return runner;
    } 
 
    @Override 
    public void finish(int resultCode, Bundle results) {
        if (mListener != null) {
            mListener.close();
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, contains
        Rect r = computeLayout();
        final float hysteresis = 20F;
        int retval = GROW_NONE;
 
        if (mCircle) {
            float distX = x - r.centerX();
            float distY = y - r.centerY();
            int distanceFromCenter =
                    (int) Math.sqrt(distX * distX + distY * distY);
            int radius  = mDrawRect.width() / 2;
            int delta = distanceFromCenter - radius;
            if (Math.abs(delta) <= hysteresis) {
                if (Math.abs(distY) > Math.abs(distX)) {
                    if (distY < 0) {
                        retval = GROW_TOP_EDGE;
                    } else { 
                        retval = GROW_BOTTOM_EDGE;
                    } 
                } else { 
                    if (distX < 0) {

7
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, width
    } 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        BitmapDrawable bmDrawable = (BitmapDrawable) getDrawable();
        Rect rect = new Rect();
        getDrawingRect(rect);
        Bitmap product = Bitmap.createBitmap(rect.width(), rect.height(), Bitmap.Config.ARGB_8888);
 
        if (bmDrawable != null && bmDrawable.getBitmap() != null) {
            product.setDensity(bmDrawable.getBitmap().getDensity());
            Canvas c = new Canvas(product);
            c.setDensity(canvas.getDensity());
            c.drawColor(mFillColor);
            super.onDraw(c);
            if (maskDrawable != null) {
                Paint p = new Paint();
                p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
                c.drawBitmap(maskDrawable.getBitmap(), null, rect, p);
            } else if (maskDrawableNine != null) {

8
CodeRank
This code example shows how to use the following methods:getA, getB, getField
    } 
 
    public static ECCurve convertCurve( 
        EllipticCurve ec)
    { 
        ECField field = ec.getField();
        BigInteger a = ec.getA();
        BigInteger b = ec.getB();
 
        if (field instanceof ECFieldFp)
        { 
            ECCurve.Fp curve = new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
 
            if (customCurves.containsKey(curve))
            { 
                return (ECCurve)customCurves.get(curve);
            } 
 
            return curve;
        } 
7
CodeRank
This code example shows how to use the following methods:centerX, centerY
	 *  
	 * @see android.graphics.drawable.Drawable#draw(android.graphics.Canvas) 
	 */ 
	@Override 
	public void draw( final Canvas canvas ) {
		final RectF rect = new RectF( getBounds() );
		canvas.drawCircle( rect.centerX(), rect.centerY(), mRadius, mPaint );
	} 
 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see android.graphics.drawable.Drawable#getOpacity() 
	 */ 
	@Override 
	public int getOpacity() { 
		return PixelFormat.OPAQUE;
	} 
 
	/* 
7
CodeRank
This code example shows how to use the following methods:request
	 
	private void postToFacebook(String review) {	
		mProgress.setMessage("Posting ...");
		mProgress.show();
		 
		AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
		 
		Bundle params = new Bundle();
    		 
		params.putString("message", review );
		params.putString("name", "Ruboto");
		params.putString("caption", "ruboto.org");
		params.putString("link", "http://ruboto.org/");
		params.putString("description", "Ruboto, sharing your jruby scripts is fun");
		params.putString("picture", "http://ruboto.org/ruboto.png");
		 
		mAsyncFbRunner.request("me/feed", params, "POST", new WallPostListener());
	} 
 
	private final class WallPostListener extends BaseRequestListener { 

7
CodeRank
This code example shows how to use the following methods:release, getBand, getBandFreqRange, getCenterFreq
    public void test1_1BandFrequency() throws Exception { 
        boolean result = false;
        String msg = "test1_1BandFrequency()";
        getEqualizer(0); 
        try { 
            short band = mEqualizer.getBand(TEST_FREQUENCY_MILLIHERTZ);
            assertTrue(msg + ": getBand failed", band >= 0);
            int[] freqRange = mEqualizer.getBandFreqRange(band);
            assertTrue(msg + ": getBandFreqRange failed",
                    (freqRange[0] <= TEST_FREQUENCY_MILLIHERTZ) &&
                    (freqRange[1] >= TEST_FREQUENCY_MILLIHERTZ));
            int freq = mEqualizer.getCenterFreq(band);
            assertTrue(msg + ": getCenterFreq failed",
                    (freqRange[0] <= freq) && (freqRange[1] >= freq));
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");

8
CodeRank
This code example shows how to use the following methods:getCenterX, getCenterY
     * @param rectangle  the rectangle (<code>null</code> not permitted). 
     *  
     * @return The anchor point (never <code>null</code>).  
     */ 
    public Point2D getAnchorPoint(Rectangle2D rectangle) {
        ParamChecks.nullNotPermitted(rectangle, "rectangle");
        Point2D result = new Point2D.Double();
        if (this == RectangleAnchor.CENTER) {
            result.setLocation(rectangle.getCenterX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.TOP) {
            result.setLocation(rectangle.getCenterX(), rectangle.getMinY());
        } else if (this == RectangleAnchor.BOTTOM) {
            result.setLocation(rectangle.getCenterX(), rectangle.getMaxY());
        } else if (this == RectangleAnchor.LEFT) {
            result.setLocation(rectangle.getMinX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.RIGHT) {
            result.setLocation(rectangle.getMaxX(), rectangle.getCenterY());
        } else if (this == RectangleAnchor.TOP_LEFT) {
            result.setLocation(rectangle.getMinX(), rectangle.getMinY());
        } else if (this == RectangleAnchor.TOP_RIGHT) {

7
CodeRank
This code example shows how to use the following methods:setAccessible, get
 
	private static int getImageViewFieldValue(Object object, String fieldName) {
		int value = 0;
		try { 
			Field field = ImageView.class.getDeclaredField(fieldName);
			field.setAccessible(true);
			int fieldValue = (Integer) field.get(object);
			if (fieldValue > 0 && fieldValue < Integer.MAX_VALUE) {
				value = fieldValue;
			} 
		} catch (Exception e) {
			L.e(e);
		} 
		return value;
	} 
 
	@Override 
	public boolean setImageDrawable(Drawable drawable) {
		ImageView imageView = imageViewRef.get();
		if (imageView != null) {
10
CodeRank
This code example shows how to use the following methods:centerX, centerY, contains
        Rect r = computeLayout();
        final float hysteresis = 20F;
        int retval = GROW_NONE;
 
        if (mCircle) {
            float distX = x - r.centerX();
            float distY = y - r.centerY();
            int distanceFromCenter = (int) Math.sqrt(distX * distX + distY * distY);
            int radius = mDrawRect.width() / 2;
            int delta = distanceFromCenter - radius;
            if (Math.abs(delta) <= hysteresis) {
                if (Math.abs(distY) > Math.abs(distX)) {
                    if (distY < 0) {
                        retval = GROW_TOP_EDGE;
                    } else { 
                        retval = GROW_BOTTOM_EDGE;
                    } 
                } else { 
                    if (distX < 0) {
                        retval = GROW_LEFT_EDGE;

7
CodeRank
This code example shows how to use the following methods:setDuration, setInterpolator, setRepeatCount
			return; 
		} 
		float centerX = m_icon.getWidth()/2.0f;
		float centerY = m_icon.getHeight()/2.0f;
 
		RotateAnimation ra = new RotateAnimation(0, 360, centerX, centerY);
		ra.setDuration(1000);
		ra.setRepeatCount(-1);
		ra.setInterpolator(new LinearInterpolator());
		this.m_icon.startAnimation(ra);
	} 
	 
	public void endRefresh() { 
		this.m_icon.clearAnimation();
	} 
	 
	public boolean isRefreshing() { 
		Animation a = this.m_icon.getAnimation();
		return (a != null)?!a.hasEnded():false;
	} 
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, width
7
CodeRank
This code example shows how to use the following methods:get
            return read() == null; 
    } 
 
    public Object read() {
        try { 
            return field.get(target);
        } catch (Exception e) {
            throw new MockitoException("Cannot read state from field: " + field + ", on instance: " + target);
        } 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:centerX, centerY
This code example shows how to use the following methods:getDeclaringClass, getName, getType
 
            try { 
 
                final Resources resources = application.getResources();
                final int id = getId(resources,annotation);
                final Class<?> t = field.getType();
 
                if (String.class.isAssignableFrom(t)) {
                    value = resources.getString(id);
                } else if (boolean.class.isAssignableFrom(t) || Boolean.class.isAssignableFrom(t)) {
                    value = resources.getBoolean(id);
                } else if (ColorStateList.class.isAssignableFrom(t)  ) {
                    value = resources.getColorStateList(id);
                } else if (int.class.isAssignableFrom(t) || Integer.class.isAssignableFrom(t)) {
                    value = resources.getInteger(id);
                } else if (Drawable.class.isAssignableFrom(t)) {
                    value = resources.getDrawable(id);
                } else if (String[].class.isAssignableFrom(t)) {
                    value = resources.getStringArray(id);
                } else if (int[].class.isAssignableFrom(t) || Integer[].class.isAssignableFrom(t)) {

8
CodeRank
This code example shows how to use the following methods:getCenterX, getCenterY, getMaxX, getMaxY, getMinX
    public static void fitViewToBounds(Display display, Rectangle2D bounds,
            Point2D center, long duration)
    { 
        // init variables 
        double w = display.getWidth(), h = display.getHeight();
        double cx = (center==null? bounds.getCenterX() : center.getX());
        double cy = (center==null? bounds.getCenterY() : center.getY());
         
        // compute half-widths of final bounding box around 
        // the desired center point 
        double wb = Math.max(cx-bounds.getMinX(),
                             bounds.getMaxX()-cx);
        double hb = Math.max(cy-bounds.getMinY(),
                             bounds.getMaxY()-cy);
         
        // compute scale factor 
        //  - figure out if z or y dimension takes priority 
        //  - then balance against the current scale factor 
        double scale = Math.min(w/(2*wb),h/(2*hb)) / display.getScale();
 
8
CodeRank
This code example shows how to use the following methods:setDuration, setFillAfter
	 * @param durationMillis 
	 *            �D���� 
	 */ 
	public static Animation getRotateAnimation(float fromDegrees,
			float toDegrees, int durationMillis) {
		RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f); 
		rotate.setDuration(durationMillis);
		rotate.setFillAfter(true);
		return rotate;
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:setAccessible
		} 
 
		try { 
			cdBackgroundStateColorField = cdBackgroundStateField.getType()
					.getDeclaredField(COLOR_DRAWABLE_USE_COLOR_VAR);
			cdBackgroundStateColorField.setAccessible(true);
		} catch (Exception e) {
			Log.e(TAG,
					"Reflection failed while trying to determine background color of view.", 
					e);
			cdBackgroundStateColorField = null;
			return; 
		} 
 
	} 
 
	private int getColorFromColorDrawable(ColorDrawable colorDrawable)
	{ 
		if (IS_HONEYCOMB_OR_GREATER) {
			return getColorFromColorDrawableHC(colorDrawable);
9
CodeRank
This code example shows how to use the following methods:centerX, centerY, contains
		Rect r = computeLayout();
		final float hysteresis = 20F;
		int retval = GROW_NONE;
 
		if (mCircle) {
			float distX = x - r.centerX();
			float distY = y - r.centerY();
			int distanceFromCenter = (int) android.util.FloatMath.sqrt(distX
					* distX + distY * distY);
			int radius = mDrawRect.width() / 2;
			int delta = distanceFromCenter - radius;
			if (Math.abs(delta) <= hysteresis) {
				if (Math.abs(distY) > Math.abs(distX)) {
					if (distY < 0) {
						retval = GROW_TOP_EDGE;
					} else { 
						retval = GROW_BOTTOM_EDGE;
					} 
				} else { 
					if (distX < 0) {

7
CodeRank
This code example shows how to use the following methods:drawRGB, drawRect, restore, rotate, save
            mPaint.setAntiAlias(true);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            canvas.save();
            canvas.translate(dipToPx(getContext(), 400), dipToPx(getContext(), 200));
            canvas.rotate(45.0f);
            canvas.drawRGB(255, 255, 255);
            mPaint.setColor(0xffff0000);
            canvas.drawRect(-80.0f, -80.0f, 80.0f, 80.0f, mPaint);
            canvas.drawRect(0.0f, 0.0f, 220.0f, 220.0f, mPaint);            
            canvas.restore();
        } 
    } 
} 
9
CodeRank
See Code Examples for Java 8 ORB Methods: