Example #1
0
  /**
   * Returns the color space specified by the given color space constant.
   *
   * <p>For standard Java color spaces, the built-in instance is returned. Otherwise, color spaces
   * are looked up from cache and created on demand.
   *
   * @param colorSpace the color space constant.
   * @return the {@link ColorSpace} specified by the color space constant.
   * @throws IllegalArgumentException if {@code colorSpace} is not one of the defined color spaces
   *     ({@code CS_*}).
   * @see ColorSpace
   * @see ColorSpaces#CS_ADOBE_RGB_1998
   * @see ColorSpaces#CS_GENERIC_CMYK
   */
  public static ColorSpace getColorSpace(int colorSpace) {
    ICC_Profile profile;

    switch (colorSpace) {
      case CS_ADOBE_RGB_1998:
        synchronized (ColorSpaces.class) {
          profile = adobeRGB1998.get();

          if (profile == null) {
            // Try to get system default or user-defined profile
            profile = readProfileFromPath(Profiles.getPath("ADOBE_RGB_1998"));

            if (profile == null) {
              // Fall back to the bundled ClayRGB1998 public domain Adobe RGB 1998 compatible
              // profile,
              // which is identical for all practical purposes
              profile = readProfileFromClasspathResource("/profiles/ClayRGB1998.icc");

              if (profile == null) {
                // Should never happen given we now bundle fallback profile...
                throw new IllegalStateException("Could not read AdobeRGB1998 profile");
              }
            }

            adobeRGB1998 = new WeakReference<ICC_Profile>(profile);
          }
        }

        return createColorSpace(profile);

      case CS_GENERIC_CMYK:
        synchronized (ColorSpaces.class) {
          profile = genericCMYK.get();

          if (profile == null) {
            // Try to get system default or user-defined profile
            profile = readProfileFromPath(Profiles.getPath("GENERIC_CMYK"));

            if (profile == null) {
              if (DEBUG) {
                System.out.println("Using fallback profile");
              }

              // Fall back to generic CMYK ColorSpace, which is *insanely slow* using
              // ColorConvertOp... :-P
              return CMYKColorSpace.getInstance();
            }

            genericCMYK = new WeakReference<ICC_Profile>(profile);
          }
        }

        return createColorSpace(profile);

      default:
        // Default cases for convenience
        return ColorSpace.getInstance(colorSpace);
    }
  }
Example #2
0
  public static void main(String[] args) throws Exception {
    // 设定Spring的profile
    Profiles.setProfileAsSystemProperty(Profiles.DEV);

    // 启动Jetty
    Server server = JettyFactory.createServerInSource(PORT, CONTEXT);
    JettyFactory.setTldJarNames(server, TLD_JAR_NAMES);

    try {
      server.start();

      System.out.println("[INFO] Server running at http://localhost:" + PORT + CONTEXT);
      System.out.println("[HINT] Hit Enter to reload the application quickly");

      // 等待用户输入回车重载应用.
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          JettyFactory.reloadContext(server);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }
  /** Test the Private Key setting. */
  @Test
  public void testCertificatePrivateKeyMissing() throws ProfileException {
    Profile profile = profiles.get(3);

    boolean result = profile.usePrivateKeyEscrow();

    assertFalse(result);
  }
  /**
   * Test the Private Key setting.
   *
   * <p><Keys>Store Private Keys</Keys>
   */
  @Test
  public void testCertificatePrivateKeyValid() throws ProfileException {
    Profile profile = profiles.get(1);

    boolean result = profile.usePrivateKeyEscrow();

    assertTrue(result);
  }
  @Override
  protected void onResume() {
    super.onResume();
    Bundle b = getIntent().getExtras();
    int profileId = b.getInt("fac.userdelroot.droidprofiles.Notify", -1);

    pNotify =
        Profiles.getNotifyByProfileId(
            getContentResolver(), profileId, Notify.Columns.NOTIFY_TYPE_SMS);

    if (pNotify == null) pNotify = new Notify();

    loadDefaultValues();
  }