com.android.resources.ScreenOrientation源码实例Demo

javax.swing.plaf.basic.BasicComboBoxRenderer#com.android.resources.ScreenOrientation源码实例Demo

下面列出了javax.swing.plaf.basic.BasicComboBoxRenderer#com.android.resources.ScreenOrientation 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-n-IDE-for-Android   文件: HardwareConfig.java
public HardwareConfig(
        int screenWidth,
        int screenHeight,
        Density density,
        float xdpi,
        float ydpi,
        ScreenSize screenSize,
        ScreenOrientation orientation,
        boolean softwareButtons) {
    mScreenWidth = screenWidth;
    mScreenHeight = screenHeight;
    mDensity = density;
    mXdpi = xdpi;
    mYdpi = ydpi;
    mScreenSize = screenSize;
    mOrientation = orientation;
    mSoftwareButtons = softwareButtons;
}
 
源代码2 项目: javaide   文件: HardwareConfig.java
public HardwareConfig(
        int screenWidth,
        int screenHeight,
        Density density,
        float xdpi,
        float ydpi,
        ScreenSize screenSize,
        ScreenOrientation orientation,
        ScreenRound screenRoundness,
        boolean softwareButtons) {
    mScreenWidth = screenWidth;
    mScreenHeight = screenHeight;
    mDensity = density;
    mXdpi = xdpi;
    mYdpi = ydpi;
    mScreenSize = screenSize;
    mOrientation = orientation;
    mScreenRound = screenRoundness;
    mSoftwareButtons = softwareButtons;
}
 
源代码3 项目: NBANDROID-V2   文件: LayoutPreviewPanelImpl.java
private ConfigGenerator getCurrentConfig() {

        ConfigGenerator current = new ConfigGenerator()
                .setScreenHeight(imageHeight)
                .setScreenWidth(imageWidth)
                .setXdpi(dpi)
                .setYdpi(dpi)
                .setOrientation(ScreenOrientation.PORTRAIT)
                .setDensity(((Density) density.getSelectedItem()).getDensity())
                .setRatio(ScreenRatio.NOTLONG)
                .setSize(ScreenSize.NORMAL)
                .setKeyboard(Keyboard.NOKEY)
                .setTouchScreen(TouchScreen.FINGER)
                .setKeyboardState(KeyboardState.SOFT)
                .setSoftButtons(true)
                .setNavigation(Navigation.NONAV);
        return current;
    }
 
源代码4 项目: NBANDROID-V2   文件: AvdHwProfile.java
private List<State> generateStates(Hardware hardware) {
    List<State> states = Lists.newArrayListWithExpectedSize(4);

    if (portrait.isSelected()) {
        states.add(createState(ScreenOrientation.PORTRAIT, hardware, false));
    }

    if (landscape.isSelected()) {
        states.add(createState(ScreenOrientation.LANDSCAPE, hardware, false));
    }

    if (hwKeyb.isSelected()) {
        if (portrait.isSelected()) {
            states.add(createState(ScreenOrientation.PORTRAIT, hardware, true));
        }

        if (landscape.isSelected()) {
            states.add(createState(ScreenOrientation.LANDSCAPE, hardware, true));
        }
    }

    // We've added states in the order of most common to least common, so let's mark the first one as default
    states.get(0).setDefaultState(true);
    return states;
}
 
源代码5 项目: java-n-IDE-for-Android   文件: Device.java
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations
@Nullable
public Dimension getScreenSize(@NonNull ScreenOrientation orientation) {
    Screen screen = getDefaultHardware().getScreen();
    if (screen == null) {
        return null;
    }

    // compute width and height to take orientation into account.
    int x = screen.getXDimension();
    int y = screen.getYDimension();
    int screenWidth, screenHeight;

    if (x > y) {
        if (orientation == ScreenOrientation.LANDSCAPE) {
            screenWidth = x;
            screenHeight = y;
        } else {
            screenWidth = y;
            screenHeight = x;
        }
    } else {
        if (orientation == ScreenOrientation.LANDSCAPE) {
            screenWidth = y;
            screenHeight = x;
        } else {
            screenWidth = x;
            screenHeight = y;
        }
    }

    return new Dimension(screenWidth, screenHeight);
}
 
@Override
public boolean checkAndSet(String value, FolderConfiguration config) {
    ScreenOrientation orientation = ScreenOrientation.getEnum(value);
    if (orientation != null) {
        ScreenOrientationQualifier qualifier = new ScreenOrientationQualifier(orientation);
        config.setScreenOrientationQualifier(qualifier);
        return true;
    }

    return false;
}
 
源代码7 项目: javaide   文件: Device.java
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations
@Nullable
public Point getScreenSize(@NonNull ScreenOrientation orientation) {
    Screen screen = getDefaultHardware().getScreen();
    if (screen == null) {
        return null;
    }

    // compute width and height to take orientation into account.
    int x = screen.getXDimension();
    int y = screen.getYDimension();
    int screenWidth, screenHeight;

    if (x > y) {
        if (orientation == ScreenOrientation.LANDSCAPE) {
            screenWidth = x;
            screenHeight = y;
        } else {
            screenWidth = y;
            screenHeight = x;
        }
    } else {
        if (orientation == ScreenOrientation.LANDSCAPE) {
            screenWidth = y;
            screenHeight = x;
        } else {
            screenWidth = x;
            screenHeight = y;
        }
    }

    return new Point(screenWidth, screenHeight);
}
 
源代码8 项目: javaide   文件: RenderService.java
private void figureSomeValuesOut() {
    int size1 = mConfig.getScreenDimensionQualifier().getValue1();
    int size2 = mConfig.getScreenDimensionQualifier().getValue2();
    ScreenOrientation orientation = mConfig.getScreenOrientationQualifier().getValue();
    switch (orientation) {
        case LANDSCAPE:
            mWidth = size1 < size2 ? size2 : size1;
            mHeight = size1 < size2 ? size1 : size2;
            break;
        case PORTRAIT:
            mWidth = size1 < size2 ? size1 : size2;
            mHeight = size1 < size2 ? size2 : size1;
            break;
        case SQUARE:
            mWidth = mHeight = size1;
            break;
    }

    if (mMinSdkVersion == -1) {
        mMinSdkVersion = mConfig.getVersionQualifier().getVersion();
    }

    if (mTargetSdkVersion == -1) {
        mTargetSdkVersion = mConfig.getVersionQualifier().getVersion();
    }

    if (mXdpi == -1) {
        mXdpi = mConfig.getDensityQualifier().getValue().getDpiValue();
    }

    if (mYdpi == -1) {
        mYdpi = mConfig.getDensityQualifier().getValue().getDpiValue();
    }
}
 
源代码9 项目: javaide   文件: ScreenOrientationQualifier.java
@Override
public boolean checkAndSet(String value, FolderConfiguration config) {
    ScreenOrientation orientation = ScreenOrientation.getEnum(value);
    if (orientation != null) {
        ScreenOrientationQualifier qualifier = new ScreenOrientationQualifier(orientation);
        config.setScreenOrientationQualifier(qualifier);
        return true;
    }

    return false;
}
 
源代码10 项目: java-n-IDE-for-Android   文件: State.java
public ScreenOrientation getOrientation() {
    return mOrientation;
}
 
源代码11 项目: java-n-IDE-for-Android   文件: State.java
public void setOrientation(ScreenOrientation orientation) {
    mOrientation = orientation;
}
 
源代码12 项目: java-n-IDE-for-Android   文件: HardwareConfig.java
public ScreenOrientation getOrientation() {
    return mOrientation;
}
 
/**
 * Updates the {@link SmallestScreenWidthQualifier}, {@link ScreenWidthQualifier}, and
 * {@link ScreenHeightQualifier} based on the (required) values of
 * {@link ScreenDimensionQualifier} {@link DensityQualifier}, and
 * {@link ScreenOrientationQualifier}.
 *
 * Also the density cannot be {@link Density#NODPI} as it's not valid on a device.
 */
public void updateScreenWidthAndHeight() {

    ResourceQualifier sizeQ = mQualifiers[INDEX_SCREEN_DIMENSION];
    ResourceQualifier densityQ = mQualifiers[INDEX_PIXEL_DENSITY];
    ResourceQualifier orientQ = mQualifiers[INDEX_SCREEN_ORIENTATION];

    if (sizeQ != null && densityQ != null && orientQ != null) {
        Density density = ((DensityQualifier) densityQ).getValue();
        if (density == Density.NODPI) {
            return;
        }

        ScreenOrientation orientation = ((ScreenOrientationQualifier) orientQ).getValue();

        int size1 = ((ScreenDimensionQualifier) sizeQ).getValue1();
        int size2 = ((ScreenDimensionQualifier) sizeQ).getValue2();

        // make sure size1 is the biggest (should be the case, but make sure)
        if (size1 < size2) {
            int a = size1;
            size1 = size2;
            size2 = a;
        }

        // compute the dp. round them up since we want -w480dp to match a 480.5dp screen
        int dp1 = (int) Math.ceil(size1 * Density.DEFAULT_DENSITY / density.getDpiValue());
        int dp2 = (int) Math.ceil(size2 * Density.DEFAULT_DENSITY / density.getDpiValue());

        setSmallestScreenWidthQualifier(new SmallestScreenWidthQualifier(dp2));

        switch (orientation) {
            case PORTRAIT:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp2));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp1));
                break;
            case LANDSCAPE:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp1));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp2));
                break;
            case SQUARE:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp2));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp2));
                break;
        }
    }
}
 
public ScreenOrientationQualifier(ScreenOrientation value) {
    mValue = value;
}
 
public ScreenOrientation getValue() {
    return mValue;
}
 
源代码16 项目: javaide   文件: State.java
public ScreenOrientation getOrientation() {
    return mOrientation;
}
 
源代码17 项目: javaide   文件: State.java
public void setOrientation(ScreenOrientation orientation) {
    mOrientation = orientation;
}
 
源代码18 项目: javaide   文件: RenderServiceFactory.java
/**
 * Creates a config. This must be a valid config like a device would return. This is to
 * prevent issues where some resources don't exist in all cases and not in the default
 * (for instance only available in hdpi and mdpi but not in default).
 *
 * @param size1
 * @param size2
 * @param screenSize
 * @param screenRatio
 * @param orientation
 * @param density
 * @param touchScreen
 * @param keyboardState
 * @param keyboard
 * @param navigationState
 * @param navigation
 * @param apiLevel
 * @return
 */
public static FolderConfiguration createConfig(
        int size1,
        int size2,
        ScreenSize screenSize,
        ScreenRatio screenRatio,
        ScreenOrientation orientation,
        Density density,
        TouchScreen touchScreen,
        KeyboardState keyboardState,
        Keyboard keyboard,
        NavigationState navigationState,
        Navigation navigation,
        int apiLevel) {
    FolderConfiguration config = new FolderConfiguration();

    int width = size1, height = size2;
    switch (orientation) {
        case LANDSCAPE:
            width = size1 < size2 ? size2 : size1;
            height = size1 < size2 ? size1 : size2;
            break;
        case PORTRAIT:
            width = size1 < size2 ? size1 : size2;
            height = size1 < size2 ? size2 : size1;
            break;
        case SQUARE:
            width = height = size1;
            break;
    }

    int wdp = (width * Density.DEFAULT_DENSITY) / density.getDpiValue();
    int hdp = (height * Density.DEFAULT_DENSITY) / density.getDpiValue();

    config.addQualifier(new SmallestScreenWidthQualifier(wdp < hdp ? wdp : hdp));
    config.addQualifier(new ScreenWidthQualifier(wdp));
    config.addQualifier(new ScreenHeightQualifier(hdp));

    config.addQualifier(new ScreenSizeQualifier(screenSize));
    config.addQualifier(new ScreenRatioQualifier(screenRatio));
    config.addQualifier(new ScreenOrientationQualifier(orientation));
    config.addQualifier(new DensityQualifier(density));
    config.addQualifier(new TouchScreenQualifier(touchScreen));
    config.addQualifier(new KeyboardStateQualifier(keyboardState));
    config.addQualifier(new TextInputMethodQualifier(keyboard));
    config.addQualifier(new NavigationStateQualifier(navigationState));
    config.addQualifier(new NavigationMethodQualifier(navigation));
    config.addQualifier(width > height ? new ScreenDimensionQualifier(width, height) :
        new ScreenDimensionQualifier(height, width));
    config.addQualifier(new VersionQualifier(apiLevel));

    config.updateScreenWidthAndHeight();

    return config;
}
 
源代码19 项目: javaide   文件: HardwareConfig.java
public ScreenOrientation getOrientation() {
    return mOrientation;
}
 
源代码20 项目: javaide   文件: HardwareConfigHelper.java
/**
 * Sets the orientation of the config.
 * @param screenOrientation the orientation.
 * @return this (such that chains of setters can be stringed together)
 */
@NonNull
public HardwareConfigHelper setOrientation(@NonNull ScreenOrientation screenOrientation) {
    mScreenOrientation = screenOrientation;
    return this;
}
 
源代码21 项目: javaide   文件: HardwareConfigHelper.java
/**
 * Creates and returns the HardwareConfig object.
 * @return the config
 */
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations
@NonNull
public HardwareConfig getConfig() {
    Screen screen = mDevice.getDefaultHardware().getScreen();

    // compute width and height to take orientation into account.
    int x = screen.getXDimension();
    int y = screen.getYDimension();
    int width, height;

    if (x > y) {
        if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
            width = x;
            height = y;
        } else {
            width = y;
            height = x;
        }
    } else {
        if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
            width = y;
            height = x;
        } else {
            width = x;
            height = y;
        }
    }

    if (mOverrideRenderHeight != -1) {
        width = mOverrideRenderWidth;
    }

    if (mOverrideRenderHeight != -1) {
        height = mOverrideRenderHeight;
    }

    if (mMaxRenderWidth != -1) {
        width = mMaxRenderWidth;
    }

    if (mMaxRenderHeight != -1) {
        height = mMaxRenderHeight;
    }

    return new HardwareConfig(
            width,
            height,
            screen.getPixelDensity(),
            (float) screen.getXdpi(),
            (float) screen.getYdpi(),
            screen.getSize(),
            mScreenOrientation,
            mDevice.getDefaultHardware().getScreen().getScreenRound(),
            mDevice.getDefaultHardware().getButtonType() == ButtonType.SOFT);
}
 
源代码22 项目: javaide   文件: FolderConfiguration.java
/**
 * Updates the {@link SmallestScreenWidthQualifier}, {@link ScreenWidthQualifier}, and
 * {@link ScreenHeightQualifier} based on the (required) values of
 * {@link ScreenDimensionQualifier} {@link DensityQualifier}, and
 * {@link ScreenOrientationQualifier}.
 *
 * Also the density cannot be {@link Density#NODPI} as it's not valid on a device.
 */
public void updateScreenWidthAndHeight() {

    ResourceQualifier sizeQ = mQualifiers[INDEX_SCREEN_DIMENSION];
    ResourceQualifier densityQ = mQualifiers[INDEX_PIXEL_DENSITY];
    ResourceQualifier orientQ = mQualifiers[INDEX_SCREEN_ORIENTATION];

    if (sizeQ != null && densityQ != null && orientQ != null) {
        Density density = ((DensityQualifier) densityQ).getValue();
        if (density == Density.NODPI || density == Density.ANYDPI) {
            return;
        }

        ScreenOrientation orientation = ((ScreenOrientationQualifier) orientQ).getValue();

        int size1 = ((ScreenDimensionQualifier) sizeQ).getValue1();
        int size2 = ((ScreenDimensionQualifier) sizeQ).getValue2();

        // make sure size1 is the biggest (should be the case, but make sure)
        if (size1 < size2) {
            int a = size1;
            size1 = size2;
            size2 = a;
        }

        // compute the dp. round them up since we want -w480dp to match a 480.5dp screen
        int dp1 = (int) Math.ceil(size1 * Density.DEFAULT_DENSITY / density.getDpiValue());
        int dp2 = (int) Math.ceil(size2 * Density.DEFAULT_DENSITY / density.getDpiValue());

        setSmallestScreenWidthQualifier(new SmallestScreenWidthQualifier(dp2));

        switch (orientation) {
            case PORTRAIT:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp2));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp1));
                break;
            case LANDSCAPE:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp1));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp2));
                break;
            case SQUARE:
                setScreenWidthQualifier(new ScreenWidthQualifier(dp2));
                setScreenHeightQualifier(new ScreenHeightQualifier(dp2));
                break;
        }
    }
}
 
源代码23 项目: javaide   文件: ScreenOrientationQualifier.java
public ScreenOrientationQualifier(ScreenOrientation value) {
    mValue = value;
}
 
源代码24 项目: javaide   文件: ScreenOrientationQualifier.java
public ScreenOrientation getValue() {
    return mValue;
}
 
源代码25 项目: NBANDROID-V2   文件: AvdHwProfile.java
/**
 * Creates new form AvdHwProfile
 */
public AvdHwProfile(Device device, DeviceManager deviceManager,boolean edit) {
    this.deviceManager = deviceManager;
    this.edit=edit;
    initComponents();
    deviceType.setModel(new DefaultComboBoxModel<>(DeviceType.values()));
    if (device != null) {
         String tagId = device.getTagId();
        initBootProperties(device);
        if (tagId == null) {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        } else if (DeviceType.TV.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (DeviceType.WEAR.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        }
        if (edit) {
            deviceName.setText(device.getDisplayName());
            deviceName.setEditable(false);
        }else{
            deviceName.setText(String.format("%s (Edited)", device.getDisplayName()));
        }
        if (CreateAvdVisualPanel1.isTv(device)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (HardwareConfigHelper.isWear(device)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        } else {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        }
        screenSize.setValue(device.getDefaultHardware().getScreen().getDiagonalLength());
        Dimension dimension = device.getScreenSize(device.getDefaultState().getOrientation());
        resolutionX.setValue(dimension.width);
        resolutionY.setValue(dimension.height);
        round.setSelected(device.isScreenRound());
        ram.setValue(device.getDefaultHardware().getRam().getSizeAsUnit(Storage.Unit.MiB));
        hwButt.setSelected(device.getDefaultHardware().getButtonType() == ButtonType.HARD);
        hwKeyb.setSelected(device.getDefaultHardware().getKeyboard() != Keyboard.NOKEY);
        List<State> states = device.getAllStates();
        portrait.setSelected(false);
        landscape.setSelected(false);
        for (State state : states) {
            if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) {
                portrait.setSelected(true);
            }
            if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) {
                landscape.setSelected(true);
            }
        }
        Navigation nav = device.getDefaultHardware().getNav();
        switch (nav) {
            case NONAV:
                navigationStyle.setSelectedIndex(0);
                break;
            case DPAD:
                navigationStyle.setSelectedIndex(1);
                break;
            case TRACKBALL:
                navigationStyle.setSelectedIndex(2);
                break;
            case WHEEL:
                navigationStyle.setSelectedIndex(3);
                break;
        }
        cameraFront.setSelected(device.getDefaultHardware().getCamera(CameraLocation.FRONT) != null);
        cameraBack.setSelected(device.getDefaultHardware().getCamera(CameraLocation.BACK) != null);
        accelerometer.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.ACCELEROMETER));
        gyroscope.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GYROSCOPE));
        gps.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GPS));
        proximity.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.PROXIMITY_SENSOR));
        File skinFile = device.getDefaultHardware().getSkinFile();
        AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk();
        if (defaultSdk != null) {
            String skinPath = defaultSdk.getSdkPath() + File.separator + "skins";
            skin.setModel(new SkinsComboboxModel(new File(skinPath)));
        }
        skin.setSelectedItem(skinFile);
        playstore.setSelected(device.hasPlayStore());
    } else {
        deviceType.setSelectedItem(DeviceType.MOBILE);
        navigationStyle.setSelectedIndex(0);
        deviceName.setText(getUniqueId(null));
    }
    skin.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
}
 
源代码26 项目: NBANDROID-V2   文件: ConfigGenerator.java
public ConfigGenerator setOrientation(ScreenOrientation orientation) {
    mOrientation = orientation;
    return this;
}