/**
   * Action method invoked when an event triggers this action.
   *
   * <p>The {@link #_compartment} instance variable defines the action to take, and the {@link
   * #_display} instance variable whether it should set visibility or note.
   *
   * <p><em>Note</em>. The {@link #_display} instance variable is really redundant. Its value is
   * implied by the operation.
   *
   * @param ae The event that triggered us.
   */
  public void actionPerformed(ActionEvent ae) {

    // Only do anything if we have a single item selected (surely this
    // should work for multiple selections as well?).

    Vector sels = Globals.curEditor().getSelectionManager().selections();

    if (sels.size() == 1) {
      Selection sel = (Selection) sels.firstElement();
      Fig f = sel.getContent();

      // Perform the action

      if (_compartment.equals("Show Attribute Compartment")) {
        ((FigClass) f).setAttributeVisible(_display);
      } else if (_compartment.equals("Hide Attribute Compartment")) {
        ((FigClass) f).setAttributeVisible(_display);
      } else if (_compartment.equals("Show Operation Compartment")
          || _compartment.equals("Hide Operation Compartment")) {
        if (f instanceof FigClass) ((FigClass) f).setOperationVisible(_display);
        if (f instanceof FigInterface) ((FigInterface) f).setOperationVisible(_display);
      } else if (_compartment.equals("Show Extension Point Compartment")) {
        ((FigUseCase) f).setExtensionPointVisible(_display);
      } else if (_compartment.equals("Hide Extension Point Compartment")) {
        ((FigUseCase) f).setExtensionPointVisible(_display);
      } else if (_compartment.equals("Show All Compartments")) {
        ((FigClass) f).setAttributeVisible(_display);
        ((FigClass) f).setOperationVisible(_display);
      } else {
        ((FigClass) f).setAttributeVisible(_display);
        ((FigClass) f).setOperationVisible(_display);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Loads the jamm.properties file and uses it to initalize the Globals object.
   *
   * @see jamm.webapp.Globals
   * @param config The configuration from the servlet container.
   * @throws ServletException when their is an IOException loading the properties file
   */
  private void loadProperties(ServletConfig config) throws ServletException {
    String path;
    Properties properties;

    try {
      path = config.getServletContext().getRealPath("WEB-INF/" + "jamm.properties");
      properties = new Properties();
      properties.load(new FileInputStream(path));

      Globals.setLdapHost(getStringProperty(properties, "ldap.host", "localhost"));
      Globals.setLdapPort(getIntProperty(properties, "ldap.port", 389));
      Globals.setLdapSearchBase(getStringProperty(properties, "ldap.search_base", ""));
      LdapPassword.setRandomClass(
          getStringProperty(properties, "random_class", "java.security.SecureRandom"));

      // Strip out leading and trailing quotes (common problem)
      String rootDn = getStringProperty(properties, "ldap.root_dn", "");
      if (rootDn.startsWith("\"") && rootDn.endsWith("\"")) {
        rootDn = StringUtils.substring(rootDn, 1, -1);
      }
      Globals.setRootDn(rootDn);
      Globals.setRootLogin(getStringProperty(properties, "ldap.root_login", "root"));
      MailManagerOptions.setUsePasswordExOp(getBooleanProperty(properties, "password.exop", true));
      MailManagerOptions.setVmailHomedir(
          getStringProperty(properties, "vmail.homedir", "/home/vmail/domains"));
    } catch (IOException e) {
      throw new ServletException(e);
    }
  }
Exemplo n.º 3
0
 @Override
 public String getShortDescription() {
   StringBuilder sb = new StringBuilder();
   sb.append("<b>");
   if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_DYNAMIC)) {
     sb.append("<i>").append(StringUtil.quoteForHTML(getName())).append("</i>");
   } else {
     sb.append(StringUtil.quoteForHTML(getName()));
   }
   sb.append("</b> - ");
   sb.append(Globals.lang("dynamic group"));
   sb.append("<b>");
   sb.append(searchField);
   sb.append("</b>");
   sb.append(Globals.lang("contains"));
   sb.append(" <b>");
   sb.append(StringUtil.quoteForHTML(searchExpression));
   sb.append("</b>)");
   switch (getHierarchicalContext()) {
     case INCLUDING:
       sb.append(", ").append(Globals.lang("includes subgroups"));
       break;
     case REFINING:
       sb.append(", ").append(Globals.lang("refines supergroup"));
       break;
     default:
       break;
   }
   return sb.toString();
 }
Exemplo n.º 4
0
 /** Updates the membrane voltage given an input current */
 public void updateMem(int time, float current) {
   if (time > tlast + glob.getTref()) // Refractory period
   {
     vmem = (float) (vmem * Math.exp((clast - time) / glob.getTau()) + current);
     clast = time;
   }
 }
Exemplo n.º 5
0
 /**
  * Add the bonus to the character's feat pool that is granted by the class. NB: LEVELSPERFEAT is
  * now handled via PLayerCHaracter.getNumFeatsFromLevels() rather than bonuses. Only the standard
  * feat progression for the gamemode is handled here.
  *
  * @param aPC The character to bonus.
  */
 void addFeatPoolBonus(final PlayerCharacter aPC) {
   Integer mLevPerFeat = get(IntegerKey.LEVELS_PER_FEAT);
   int startLevel;
   int rangeLevel;
   int divisor;
   if (mLevPerFeat == null) {
     String aString = Globals.getBonusFeatString();
     StringTokenizer aTok = new StringTokenizer(aString, "|", false);
     startLevel = Integer.parseInt(aTok.nextToken());
     rangeLevel = Integer.parseInt(aTok.nextToken());
     divisor = rangeLevel;
     if (divisor > 0) {
       StringBuilder aBuf = new StringBuilder("FEAT|PCPOOL|").append("max(CL");
       // Make sure we only take off the startlevel value once
       if (this == aPC.getClassKeyed(aPC.getLevelInfoClassKeyName(0))) {
         aBuf.append("-").append(startLevel);
         aBuf.append("+").append(rangeLevel);
       }
       aBuf.append(",0)/").append(divisor);
       //						Logging.debugPrint("Feat bonus for " + this + " is "
       //							+ aBuf.toString());
       BonusObj bon = Bonus.newBonus(Globals.getContext(), aBuf.toString());
       aPC.addBonus(bon, this);
     }
   }
 }
  private void typeDeletion(String name) {
    BibtexEntryType type = BibtexEntryType.getType(name);

    if (type instanceof CustomEntryType) {
      if (BibtexEntryType.getStandardType(name) == null) {
        int reply =
            JOptionPane.showConfirmDialog(
                frame,
                Globals.lang(
                    "All entries of this " + "type will be declared " + "typeless. Continue?"),
                Globals.lang("Delete custom format") + " '" + StringUtil.nCase(name) + '\'',
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (reply != JOptionPane.YES_OPTION) {
          return;
        }
      }
      BibtexEntryType.removeType(name);
      updateTypesForEntries(StringUtil.nCase(name));
      changed.remove(name);
      reqLists.remove(name);
      optLists.remove(name);
      if (biblatexMode) {
        opt2Lists.remove(name);
      }
    }
    // messageLabel.setText("'"+type.getName()+"' "+
    //        Globals.lang("is a standard type."));

  }
Exemplo n.º 7
0
  // ##########################################
  //  usage:
  //  isDuplicate=checkForDuplicateKeyAndAdd( null, b.getKey() , issueDuplicateWarning);
  // ############################################
  // if the newkey already exists and is not the same as oldkey it will give a warning
  // else it will add the newkey to the to set and remove the oldkey
  public boolean checkForDuplicateKeyAndAdd(String oldKey, String newKey, boolean issueWarning) {
    // Globals.logger(" checkForDuplicateKeyAndAdd [oldKey = " + oldKey + "] [newKey = " + newKey +
    // "]");

    boolean duplicate = false;
    if (oldKey == null) { // this is a new entry so don't bother removing oldKey
      duplicate = addKeyToSet(newKey);
    } else {
      if (oldKey.equals(newKey)) { // were OK because the user did not change keys
        duplicate = false;
      } else { // user changed the key

        // removed the oldkey
        // But what if more than two have the same key?
        // this means that user can add another key and would not get a warning!
        // consider this: i add a key xxx, then i add another key xxx . I get a warning. I delete
        // the key xxx. JBM
        // removes this key from the allKey. then I add another key xxx. I don't get a warning!
        // i need a way to count the number of keys of each type
        // hashmap=>int (increment each time)

        removeKeyFromSet(oldKey);
        duplicate = addKeyToSet(newKey);
      }
    }
    if (duplicate && issueWarning) {
      JOptionPane.showMessageDialog(
          null,
          Globals.lang("Warning there is a duplicate key") + ":" + newKey,
          Globals.lang("Duplicate Key Warning"),
          JOptionPane.WARNING_MESSAGE); // , options);
    }
    return duplicate;
  }
  public void heliPass(View v) {
    g.setFlagStopSong(true);
    stopM();
    String aPath = "/sdcard/media/audio/raw/helicopterPass.wav";
    play(aPath);
    long time = g.getTimerCountdown() / 1000;
    new CountDownTimer(time, 100) {
      @Override
      public void onTick(long millisUntilFinished) {
        long timer = g.getTimerCountdown() / 1000;
        int x = 0;
        if (millisUntilFinished < g.getTimerCountdown() / 1000) {
          x = 90;
        } else {
          x = 270;
        }

        int r = (int) Math.abs((timer / 2 - millisUntilFinished) * 100 / timer / 2);

        String message = " custHelitwo" + String.valueOf(x) + "%" + String.valueOf(r);
        ;
        sendData(message);
      }

      public void onFinish() {}
    }.start();
  }
Exemplo n.º 9
0
  public static void main(String[] args) throws Exception {
    Globals.set("Sim_RandomSeed", 0L);
    Globals.set("Net_RandomSeed", 1L);

    Globals.set("Net_Euclidean_NodeRadius", 6.0);
    Globals.set("Net_Euclidean_MinimumNodeDistance", 20.0);

    new Main().init().start();
  }
Exemplo n.º 10
0
 /** force the search button to be large enough for the longer of the two texts */
 private void setSearchButtonSizes() {
   search.setText(Globals.lang("Search specified field(s)"));
   Dimension size1 = search.getPreferredSize();
   search.setText(Globals.lang("Search all fields"));
   Dimension size2 = search.getPreferredSize();
   size2.width = Math.max(size1.width, size2.width);
   search.setMinimumSize(size2);
   search.setPreferredSize(size2);
 }
 /**
  * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences, but
  * adapted for Mac users, with the Command key preferred instead of Control.
  */
 private KeyStroke getKeyForMac(KeyStroke ks) {
   if (ks == null) return null;
   int keyCode = ks.getKeyCode();
   if ((ks.getModifiers() & KeyEvent.CTRL_MASK) == 0) {
     return ks;
   } else {
     if ((ks.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
       return KeyStroke.getKeyStroke(keyCode, Globals.getShortcutMask() + KeyEvent.SHIFT_MASK);
     }
     return KeyStroke.getKeyStroke(keyCode, Globals.getShortcutMask());
   }
 }
Exemplo n.º 12
0
 /**
  * Find out how many hits were found.
  *
  * @param page
  */
 private int getNumberOfHits(String page, String marker, Pattern pattern) throws IOException {
   int ind = page.indexOf(marker);
   if (ind < 0) {
     System.out.println(page);
     throw new IOException(Globals.lang("Could not parse number of hits"));
   }
   String substring = page.substring(ind, page.length());
   Matcher m = pattern.matcher(substring);
   if (m.find()) {
     return Integer.parseInt(m.group(1));
   } else {
     throw new IOException(Globals.lang("Could not parse number of hits"));
   }
 }
Exemplo n.º 13
0
  private static void globalMain() {
    try {
      Globals.init(null);
    } catch (ServletException e) {
      log.error(e);
    }

    try {
      Thread.sleep(1000 * 10800); // 3 Stunden
    } catch (InterruptedException e) {
      log.error(e);
    }

    Globals.destroy();
  }
  /**
   * @param owner the parent Window (Dialog or Frame)
   * @param frame the JabRef Frame
   * @param panel the currently selected BasePanel
   * @param modal should this dialog be modal?
   * @param metaData The metadata of the current database
   * @param fieldName the field this selector is initialized for. May be null.
   */
  public ContentSelectorDialog2(
      Window owner,
      JabRefFrame frame,
      BasePanel panel,
      boolean modal,
      MetaData metaData,
      String fieldName) {
    super(owner, Globals.lang("Setup selectors"));
    this.setModal(modal);
    this.metaData = metaData;
    this.frame = frame;
    this.panel = panel;
    this.currentField = fieldName;

    // help = new JButton(Globals.lang("Help"));
    // help.addActionListener(new HelpAction(frame.helpDiag, GUIGlobals.contentSelectorHelp,
    // "Help"));
    // help = new HelpAction(frame.helpDiag, GUIGlobals.contentSelectorHelp, "Help");
    initLayout();
    //  wordSelector.addItem(WORD_EMPTY_TEXT);

    setupFieldSelector();
    setupWordSelector();
    setupActions();
    Util.bindCloseDialogKeyToCancelAction(this.rootPane, cancel.getAction());
    int fieldInd = fieldListModel.indexOf(currentField);
    if (fieldInd >= 0) fieldList.setSelectedIndex(fieldInd);

    pack();
  }
Exemplo n.º 15
0
 public void setHistoryTaskPaneVisible(boolean visible) {
   if (!historyPane.hasWindow() && visible) {
     Globals.getThisAddin()
         .createTaskPaneWindowAsync(historyPane, "Issue History", inspector, null);
   }
   historyPane.setVisible(visible);
 }
Exemplo n.º 16
0
  private void saveFeatures() throws IOException, ClassNotFoundException {
    File file = new File(getExternalFilesDir(null), _exerciseName + ".txt");
    if (!file.exists()) {
      file.createNewFile();
    }
    ObjectOutputStream oostream = new ObjectOutputStream(new FileOutputStream(file));
    for (int i = 1; i <= _reps; i++) {
      File readingFile = new File(_directory, i + ".txt");
      FileInputStream fistream = new FileInputStream(readingFile);
      ObjectInputStream oistream = new ObjectInputStream(fistream);
      ArrayList<SensorReading> reading = new ArrayList<>();
      while (fistream.available() > 0) { // Check if the file stream is at the end
        reading.add((SensorReading) oistream.readObject());
      }
      // TODO: Get feature object here
      // Create ExerciseData object from the readings
      ExerciseData exerciseData = new ExerciseData(reading);
      Feature feature = new Feature();
      Log.d("reading_size", reading.size() + "");
      feature._features = exerciseData.getFeatureVector();
      feature._time = exerciseData.getTime();
      feature._classLabel = Globals._numExercises + 1;
      oostream.writeObject(feature);
    }
    if (Globals._exerciseLabels == null) {
      Globals._exerciseLabels = new HashMap<>();
    }
    Globals._exerciseLabels.put(_exerciseName, Globals._numExercises + 1);
    Globals._numExercises++;
    Globals.saveExerciseLabels(this);

    Classifier.trainModel(this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInstance = this;

    Globals.checkLocale(this);

    currentPlugin = "(none)";

    String filename = MenuActivity.mupen64plus_cfg.get("UI-Console", "AudioPlugin");
    if (filename == null
        || filename.length() < 1
        || filename.equals("\"\"")
        || filename.equals("\"dummy\""))
      filename = MenuActivity.gui_cfg.get("AUDIO_PLUGIN", "last_choice");
    if (filename != null) {
      MenuActivity.gui_cfg.put("AUDIO_PLUGIN", "last_choice", filename);
      filename = filename.replace("\"", "");
      int x = filename.lastIndexOf("/");
      if (x > -1 && x < (filename.length() - 1)) {
        currentPlugin = filename.substring(x + 1, filename.length());
        if (currentPlugin == null || currentPlugin.length() < 1) currentPlugin = "(none)";
      }
    }

    // Load preferences from XML
    addPreferencesFromResource(R.layout.preferences_audio);

    final Preference settingsAudioChange = findPreference("menuSettingsAudioChange");
    settingsAudioChange.setSummary(currentPlugin);
    settingsAudioChange.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(mInstance, MenuSettingsAudioChangeActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
            return true;
          }
        });

    // Enable Plugin setting
    final CheckBoxPreference settingsEnableAudio =
        (CheckBoxPreference) findPreference("menuSettingsAudioEnabled");
    settingsEnableAudio.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {
            MenuActivity.gui_cfg.put(
                "AUDIO_PLUGIN", "enabled", (settingsEnableAudio.isChecked() ? "1" : "0"));
            MenuActivity.mupen64plus_cfg.put(
                "UI-Console",
                "AudioPlugin",
                (settingsEnableAudio.isChecked()
                    ? MenuActivity.gui_cfg.get("AUDIO_PLUGIN", "last_choice")
                    : "\"dummy\""));
            return true;
          }
        });
  }
Exemplo n.º 18
0
  public void testFindEquipmentByBaseKey() {
    TestHelper.makeSizeAdjustments();
    Equipment towel = new Equipment();
    towel.setName("Towel");
    Equipment backpackMed = new Equipment();
    backpackMed.setName("Backpack");
    final Equipment backpackSml = backpackMed.clone();
    backpackSml.put(ObjectKey.BASE_ITEM, CDOMDirectSingleRef.getRef(backpackMed));
    SizeAdjustment small = Globals.getContext().ref.getAbbreviatedObject(SizeAdjustment.class, "S");
    final String newName = backpackSml.createNameForAutoResize(small);
    backpackSml.setName(newName);
    backpackSml.setKeyName(backpackSml.createKeyForAutoResize(small));

    List<Equipment> eqList = new ArrayList<Equipment>();
    eqList.add(towel);
    eqList.add(backpackSml);
    assertEquals(
        "Expected to find backpack",
        backpackSml,
        EquipmentUtilities.findEquipmentByBaseKey(eqList, "backpack"));
    assertEquals(
        "Expected not to find torch",
        null,
        EquipmentUtilities.findEquipmentByBaseKey(eqList, "torch"));
    assertEquals(
        "Expected to find towel",
        towel,
        EquipmentUtilities.findEquipmentByBaseKey(eqList, "ToWeL"));
  }
Exemplo n.º 19
0
 public void setIssueTaskPaneVisible(boolean visible) {
   if (!issuePane.hasWindow() && visible) {
     String title = Globals.getResourceBundle().getString("IssueTaskPane.title");
     Globals.getThisAddin()
         .createTaskPaneWindowAsync(
             issuePane,
             title,
             inspector,
             (succ, ex) -> {
               if (ex != null) {
                 MessageBox.show(inspector, "Error", ex.getMessage(), null);
               }
             });
   }
   issuePane.setVisible(visible);
 }
Exemplo n.º 20
0
 public static void trainModel(ActionBarActivity obj) throws IOException, ClassNotFoundException {
   ArrayList<Feature> features = Globals.getAllFeatures(obj);
   ArrayList<ArrayList<Double>> train = new ArrayList<ArrayList<Double>>();
   ArrayList<Double> temp;
   for (Feature f : features) {
     temp = new ArrayList<>();
     temp.add((double) f._classLabel);
     temp.addAll(f._features);
     train.add(temp);
   }
   for (Feature f : features) {
     temp = new ArrayList<>();
     temp.add((double) f._classLabel);
     temp.addAll(f._features);
     train.add(temp);
   }
   for (Feature f : features) {
     temp = new ArrayList<>();
     temp.add((double) f._classLabel);
     temp.addAll(f._features);
     train.add(temp);
   }
   for (Feature f : features) {
     temp = new ArrayList<>();
     temp.add((double) f._classLabel);
     temp.addAll(f._features);
     train.add(temp);
   }
   long seed = System.nanoTime();
   Collections.shuffle(train, new Random(seed));
   svmTrain(train);
   // Printing labels to check
   printModelLabels();
   writeModeltoFile(obj);
 }
Exemplo n.º 21
0
  @Override
  public AbstractUndoableEdit remove(BibtexEntry[] entries) {
    if (!supportsRemove()) {
      return null;
    }

    if (entries != null && entries.length > 0) {
      NamedCompound ce = new NamedCompound(Globals.lang("remove from group"));
      boolean modified = false;
      for (BibtexEntry entry : entries) {
        if (getSearchRule().applyRule(SearchRule.NULL_QUERY, entry)) {
          String oldContent = entry.getField(searchField);
          removeMatches(entry);
          // Store undo information.
          ce.addEdit(
              new UndoableFieldChange(entry, searchField, oldContent, entry.getField(searchField)));
          modified = true;
        }
      }
      if (modified) {
        ce.end();
      }

      return modified ? ce : null;
    }

    return null;
  }
Exemplo n.º 22
0
 public void stopAll() {
   try {
     stopAllInner();
   } catch (Throwable t) {
     Globals.onException(t);
   }
 }
Exemplo n.º 23
0
  @Override
  public AbstractUndoableEdit add(BibtexEntry[] entries) {
    if (!supportsAdd()) {
      return null;
    }
    if (entries != null && entries.length > 0) {
      NamedCompound ce = new NamedCompound(Globals.lang("add entries to group"));
      boolean modified = false;
      for (BibtexEntry entry : entries) {
        if (!getSearchRule().applyRule(SearchRule.NULL_QUERY, entry)) {
          String oldContent = entry.getField(searchField);
          String pre = Globals.prefs.get(JabRefPreferences.GROUP_KEYWORD_SEPARATOR);
          String newContent = (oldContent == null ? "" : oldContent + pre) + searchExpression;
          entry.setField(searchField, newContent);

          // Store undo information.
          ce.addEdit(new UndoableFieldChange(entry, searchField, oldContent, newContent));
          modified = true;
        }
      }
      if (modified) {
        ce.end();
      }

      return modified ? ce : null;
    }

    return null;
  }
Exemplo n.º 24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInstance = this;
    // fullscreen mode
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    if (Globals.InhibitSuspend)
      getWindow()
          .setFlags(
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Globals.checkLocale(this);

    _layout = new LinearLayout(this);
    _layout.setOrientation(LinearLayout.VERTICAL);
    _layout.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    _layout2 = new LinearLayout(this);
    _layout2.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    _layout.addView(_layout2);
    _img = new ImageView(this);
    _img.setScaleType(ImageView.ScaleType.FIT_CENTER); // FIT_XY
    try {
      _img.setImageDrawable(Drawable.createFromStream(getAssets().open("logo.png"), "logo.png"));
    } catch (Exception e) {
      _img.setImageResource(R.drawable.publisherlogo);
    }
    _img.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    _layout.addView(_img);
    _videoLayout = new FrameLayout(this);
    _videoLayout.addView(_layout);
    setContentView(_videoLayout);

    class Callback implements Runnable {
      MainActivity p;

      Callback(MainActivity _p) {
        p = _p;
      }

      public void run() {
        p.startDownloader();
      }
    };

    Thread downloaderThread = null;
    downloaderThread = new Thread(new Callback(this));
    downloaderThread.start();
  }
Exemplo n.º 25
0
  public void update() {
    if (!goOn) return;

    panel.output(
        Globals.lang(
            "Finished writing XMP for %0 file (%1 skipped, %2 errors).",
            String.valueOf(entriesChanged), String.valueOf(skipped), String.valueOf(errors)));
  }
Exemplo n.º 26
0
  /**
   * Get the unarmed Damage for this class at the given level.
   *
   * @param aLevel the given level.
   * @param aPC the PC with the level.
   * @param adjustForPCSize whether to adjust the result for the PC's size.
   * @return the unarmed damage string
   */
  String getUDamForEffLevel(int aLevel, final PlayerCharacter aPC, boolean adjustForPCSize) {
    int pcSize = adjustForPCSize ? aPC.sizeInt() : aPC.getDisplay().racialSizeInt();

    //
    // Check "Unarmed Strike", then default to "1d3"
    //
    String aDamage;

    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    final Equipment eq =
        ref.silentlyGetConstructedCDOMObject(Equipment.class, "KEY_Unarmed Strike");

    if (eq != null) {
      aDamage = eq.getDamage(aPC);
    } else {
      aDamage = "1d3";
    }

    // resize the damage as if it were a weapon
    if (adjustForPCSize) {
      int defSize = SizeUtilities.getDefaultSizeAdjustment().get(IntegerKey.SIZEORDER);
      aDamage = Globals.adjustDamage(aDamage, defSize, pcSize);
    }

    //
    // Check the UDAM list for monk-like damage
    //
    List<CDOMObject> classObjects = new ArrayList<>();
    // Negative increment to start at highest level until an UDAM is found
    for (int i = aLevel; i >= 1; i--) {
      classObjects.add(aPC.getActiveClassLevel(this, i));
    }
    classObjects.add(this);
    for (CDOMObject cdo : classObjects) {
      List<String> udam = cdo.getListFor(ListKey.UNARMED_DAMAGE);
      if (udam != null) {
        if (udam.size() == 1) {
          aDamage = udam.get(0);
        } else {
          aDamage = udam.get(pcSize);
        }
        break;
      }
    }
    return aDamage;
  }
Exemplo n.º 27
0
  @Override
  public boolean qualifies(PlayerCharacter aPC, Object owner) {
    if (Globals.checkRule(RuleConstants.CLASSPRE)) {
      return true;
    }

    return super.qualifies(aPC, owner);
  }
Exemplo n.º 28
0
 @Override
 public CompiledScript compile(Reader script) throws ScriptException {
   try {
     InputStream is = new Utf8Encoder(script);
     try {
       final Globals g = context.globals;
       final LuaFunction f = g.load(script, "script").checkfunction();
       return new LuajCompiledScript(f, g);
     } catch (LuaError lee) {
       throw new ScriptException(lee.getMessage());
     } finally {
       is.close();
     }
   } catch (Exception e) {
     throw new ScriptException("eval threw " + e.toString());
   }
 }
Exemplo n.º 29
0
  public void init() {

    // Get entries and check if it makes sense to perform this operation
    entries = panel.getSelectedEntries();

    if (entries.length == 0) {

      database = panel.getDatabase();
      entries = database.getEntries().toArray(new BibtexEntry[] {});

      if (entries.length == 0) {

        JOptionPane.showMessageDialog(
            panel,
            Globals.lang("This operation requires at least one entry."),
            Globals.lang("Write XMP-metadata"),
            JOptionPane.ERROR_MESSAGE);
        goOn = false;
        return;

      } else {

        int response =
            JOptionPane.showConfirmDialog(
                panel,
                Globals.lang("Write XMP-metadata for all PDFs in current database?"),
                Globals.lang("Write XMP-metadata"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if (response != JOptionPane.YES_OPTION) {
          goOn = false;
          return;
        }
      }
    }

    errors = entriesChanged = skipped = 0;

    if (optDiag == null) {
      optDiag = new OptionsDialog(panel.frame().getFrame());
    }
    optDiag.open();

    panel.output(Globals.lang("Writing XMP metadata..."));
  }
        @Override
        public void onStop(String result) {

          simpleListFragment.songDuration.setText("0:00");
          simpleListFragment.sk1.setProgress(0);
          simpleListFragment.playPauseButton.setBackgroundResource(R.drawable.ic_action_play);
          // TODO Auto-generated method stub
          if (result == "finished") {
            if (g.getPlayerStateRepeat() == 1) {
              nextM();
            } else if (g.getPlayerStateRepeat() == 2) {
              playM();
            } else {
              return;
            }
          }
        }