Example #1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
  /**
   * getting the image representing a resource given the id of a resource
   *
   * @param svgHandle a svg handle
   * @param resourceId the id of the resource from which the image has been created
   * @param useSmallImage whether the returned image should be small or large
   * @return the image representing the resource
   */
  public Image getImage(SVGHandle svgHandle, String resourceId, boolean useSmallImage) {

    Image image = null;

    if (svgHandle != null && resourceId != null && !resourceId.equals("")) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap.containsKey(resourceId)) {

          ImageRepresentation imageRepresentation = idToImageMap.get(resourceId);

          if (imageRepresentation != null) {

            if (useSmallImage) {

              image = imageRepresentation.getSmallImage();

            } else {

              image = imageRepresentation.getLargeImage();
            }
          }
        }
      }
    }

    return image;
  }
 public static boolean hasNewerVersion(PluginId descr) {
   return !wasUpdated(descr)
       && (NewVersions2Plugins.containsKey(descr)
           || PluginManagerUISettings.getInstance()
               .myOutdatedPlugins
               .contains(descr.getIdString()));
 }
  @Override
  public void saveAllDocuments() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myMultiCaster.beforeAllDocumentsSaving();
    if (myUnsavedDocuments.isEmpty()) return;

    final Map<Document, IOException> failedToSave = new HashMap<Document, IOException>();
    final Set<Document> vetoed = new HashSet<Document>();
    while (true) {
      int count = 0;

      for (Document document : myUnsavedDocuments) {
        if (failedToSave.containsKey(document)) continue;
        if (vetoed.contains(document)) continue;
        try {
          doSaveDocument(document);
        } catch (IOException e) {
          //noinspection ThrowableResultOfMethodCallIgnored
          failedToSave.put(document, e);
        } catch (SaveVetoException e) {
          vetoed.add(document);
        }
        count++;
      }

      if (count == 0) break;
    }

    if (!failedToSave.isEmpty()) {
      handleErrorsOnSave(failedToSave);
    }
  }
  /**
   * Asks current editor to refresh its state in accordance with the arrangement rule shown at the
   * given row.
   *
   * @param row row index of the rule which match condition should be edited (if defined); <code>
   *     '-1'</code> as an indication that no settings should be active
   */
  public void reset(int row) {
    // Reset state.
    myRow = row;
    myFocusRequestor = myDefaultFocusRequestor;
    mySkipStateChange = true;
    try {
      for (ArrangementUiComponent component : myComponents.values()) {
        component.reset();
      }
    } finally {
      mySkipStateChange = false;
    }

    ArrangementMatchingRulesModel model = myControl.getModel();
    if (row < 0 || row >= model.getSize()) {
      myRow = -1;
      return;
    }

    Object element = model.getElementAt(row);
    ArrangementSettingsToken orderType =
        element instanceof ArrangementMatchRule
            ? ((ArrangementMatchRule) element).getOrderType()
            : null;
    final ArrangementMatchCondition condition;
    final Map<ArrangementSettingsToken, Object> conditionTokens;

    if (element instanceof EmptyArrangementRuleComponent) {
      // We need to disable conditions which are not applicable for empty rules (e.g. we don't want
      // to enable 'volatile' condition
      // for java rearranger if no 'field' condition is selected.
      condition = null;
      conditionTokens = ContainerUtilRt.newHashMap();
    } else if (!(element instanceof StdArrangementMatchRule)) {
      return;
    } else {
      condition = ((StdArrangementMatchRule) element).getMatcher().getCondition();
      conditionTokens = ArrangementUtil.extractTokens(condition);
    }

    mySkipStateChange = true;
    try {
      for (ArrangementUiComponent component : myComponents.values()) {
        ArrangementSettingsToken token = component.getToken();
        if (token != null
            && (token.equals(orderType) || mySettingsManager.isEnabled(token, condition))) {
          component.setEnabled(true);
          component.setSelected(conditionTokens.containsKey(token));
          Object value = conditionTokens.get(token);
          if (value != null) {
            component.setData(value);
          }
        }
      }

      refreshConditions();
    } finally {
      mySkipStateChange = false;
    }
  }
  private void removeSdk() {
    final Sdk currentSdk = getSelectedSdk();
    if (currentSdk != null) {
      final Sdk sdk = myProjectSdksModel.findSdk(currentSdk);
      final PySdkService sdkService = PySdkService.getInstance();
      sdkService.removeSdk(currentSdk);
      DumbService.allowStartingDumbModeInside(
          DumbModePermission.MAY_START_MODAL, () -> SdkConfigurationUtil.removeSdk(sdk));

      myProjectSdksModel.removeSdk(sdk);
      myProjectSdksModel.removeSdk(currentSdk);

      if (myModificators.containsKey(currentSdk)) {
        SdkModificator modificator = myModificators.get(currentSdk);
        myModifiedModificators.remove(modificator);
        myModificators.remove(currentSdk);
      }
      refreshSdkList();
      mySdkListChanged = true;
      // TODO select initially selected SDK
      if (mySdkList.getSelectedIndex() < 0) {
        mySdkList.setSelectedIndex(0);
      }
    }
  }
  private void removeProgress(@NotNull InlineProgressIndicator progress) {
    synchronized (myOriginals) {
      if (!myInline2Original.containsKey(progress)) return;

      final boolean last = myOriginals.size() == 1;
      final boolean beforeLast = myOriginals.size() == 2;

      myPopup.removeIndicator(progress);

      final ProgressIndicatorEx original = removeFromMaps(progress);
      if (myOriginals.contains(original)) return;

      if (last) {
        restoreEmptyStatus();
        if (myShouldClosePopupAndOnProcessFinish) {
          hideProcessPopup();
        }
      } else {
        if (myPopup.isShowing() || myOriginals.size() > 1) {
          buildInProcessCount();
        } else if (beforeLast) {
          buildInInlineIndicator(createInlineDelegate(myInfos.get(0), myOriginals.get(0), true));
        } else {
          restoreEmptyStatus();
        }
      }

      runQuery();
    }
  }
 boolean registruotiAuto(String autoNr) {
   if (regAuto.containsKey(autoNr)) return false;
   Automobilis a = neregAuto.poll();
   if (a == null) return false; // kai neregistruotų jau nėra
   regAuto.put(autoNr, a);
   return true;
 }
Example #9
0
  /** By Dingding */
  private Set<Line.Segment> getRemovableLineSegments(
      Map<Position, Piece> pieceMap, PieceColor pieceColor) {
    Set<Line.Segment> removableLines = new HashSet<>();
    Set<Line> linesOnTheBoard =
        Line.getLinesOnTheBoard(
            this); // Get all the possible lines on the board. Positions don't need to be occupied.

    for (Line line : linesOnTheBoard) {
      Position currentPosition = line.getStartPosition();
      Position startOfSegment = null;
      Position endOfSegment = null;
      Direction direction = line.getDirection();
      int consecutivePieces =
          0; // We start at a dot position, so we can assume that we don't start in a set of
             // consecutive pieces
      boolean isInLineSegment = false;

      // Break the for-loop if an endOfSegment has been found (because the largest lines only have 7
      // positions on the board, there
      // can't be more than one set of four pieces of the same color (requiring at least 9
      // positions) on the board.
      for (;
          endOfSegment == null && isPositionOnPlayAreaOrOuterDots(currentPosition);
          currentPosition = currentPosition.next(direction)) {
        PieceColor currentPieceColor =
            pieceMap.containsKey(currentPosition)
                ? pieceMap.get(currentPosition).getPieceColor()
                : null;

        // Update the consecutivePieces
        if (currentPieceColor == pieceColor) consecutivePieces++;
        if (consecutivePieces == 4) isInLineSegment = true;
        if (currentPieceColor != pieceColor) consecutivePieces = 0;

        if (isInLineSegment) {
          if (isDotPosition(currentPosition) || currentPieceColor == null) {
            endOfSegment = currentPosition.previous(direction);
          }
        }

        // Update the startOfSegment if necessary
        if (startOfSegment == null) {
          if (currentPieceColor != null) {
            startOfSegment = currentPosition;
          }
        }
        if (currentPieceColor == null && endOfSegment == null) {
          startOfSegment = null;
        }

        // Add a line segment to the list if we have found one
        if (endOfSegment != null) {
          removableLines.add(new Line.Segment(this, startOfSegment, endOfSegment, direction));
        }
      }
    }

    return removableLines;
  }
 public static NamedCache getCache(String s) {
   if (!cache.containsKey(s)) {
     CacheFactory.ensureCluster();
     NamedCache c = CacheFactory.getCache(s);
     cache.put(s, c);
   }
   return (cache.get(s));
 }
Example #11
0
 void initialize(Map m) {
   System.out.println("Initializing");
   if (m.containsKey("wordList")) {
     System.out.println("SettingWordList");
     setWordList((Properties) m.get("wordList"));
   } else {
     setWordList(new Properties());
   }
 }
Example #12
0
  void doubleClicked(JComponent src) {
    if (src == lstEntities) {
      DustEntity sel = ((LabEntity) lstEntities.getSelectedValue()).entity;

      if (!mapEntityFrames.containsKey(sel)) {
        selectEntityFrame(sel, true);
      }
    }
  }
Example #13
0
  static void removeFromLayers(Shape shape) {
    if (!layerOf.containsKey(shape)) return;

    int oldLayer = layerOf.get(shape);
    layerContents.get(oldLayer).remove(shape);
    if (layerContents.get(oldLayer).isEmpty()) {
      layerContents.remove(oldLayer);
      layers.remove((Integer) oldLayer);
    }
    layerOf.remove(shape);
  }
Example #14
0
  /**
   * Loads the list of enabled and disabled encryption protocols with their priority.
   *
   * @param enabledEncryptionProtocols The list of enabled encryption protocol available for this
   *     account.
   * @param disabledEncryptionProtocols The list of disabled encryption protocol available for this
   *     account.
   */
  private void loadEncryptionProtocols(
      Map<String, Integer> encryptionProtocols, Map<String, Boolean> encryptionProtocolStatus) {
    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    // Load stored values.
    int prefixeLength = ProtocolProviderFactory.ENCRYPTION_PROTOCOL.length() + 1;
    String encryptionProtocolPropertyName;
    String name;
    int index;
    boolean enabled;
    Iterator<String> encryptionProtocolNames = encryptionProtocols.keySet().iterator();
    while (encryptionProtocolNames.hasNext()) {
      encryptionProtocolPropertyName = encryptionProtocolNames.next();
      index = encryptionProtocols.get(encryptionProtocolPropertyName);
      // If the property is set.
      if (index != -1) {
        name = encryptionProtocolPropertyName.substring(prefixeLength);
        if (isExistingEncryptionProtocol(name)) {
          enabled =
              encryptionProtocolStatus.get(
                  ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + "." + name);
          encryptions[index] = name;
          selectedEncryptions[index] = enabled;
        }
      }
    }

    // Load default values.
    String encryptionProtocol;
    boolean set;
    int j = 0;
    for (int i = 0; i < ENCRYPTION_PROTOCOLS.length; ++i) {
      encryptionProtocol = ENCRYPTION_PROTOCOLS[i];
      // Specify a default value only if there is no specific value set.
      if (!encryptionProtocols.containsKey(
          ProtocolProviderFactory.ENCRYPTION_PROTOCOL + "." + encryptionProtocol)) {
        set = false;
        // Search for the first empty element.
        while (j < encryptions.length && !set) {
          if (encryptions[j] == null) {
            encryptions[j] = encryptionProtocol;
            // By default only ZRTP is set to true.
            selectedEncryptions[j] = encryptionProtocol.equals("ZRTP");
            set = true;
          }
          ++j;
        }
      }
    }

    this.encryptionConfigurationTableModel.init(encryptions, selectedEncryptions);
  }
Example #15
0
 @NotNull
 private static <K, V> Map<V, K> invertMap(@NotNull Map<K, V> map) {
   final Map<V, K> inverted = new HashMap<V, K>();
   for (Map.Entry<K, V> entry : map.entrySet()) {
     final V value = entry.getValue();
     if (!inverted.containsKey(value)) {
       inverted.put(value, entry.getKey());
     }
   }
   return inverted;
 }
Example #16
0
  private void movePiece(Map<Position, Piece> pieceMap, Position currentPosition, int deltaPos)
      throws InvalidMoveException {
    Position nextPosition = new Position(currentPosition.posId + deltaPos);

    if (!isOnInnerBoard(nextPosition)) {
      throw new InvalidMoveException();
    } else {
      try {
        if (pieceMap.containsKey(nextPosition)) {
          movePiece(pieceMap, nextPosition, deltaPos);
        }

        // Don't copy over null values, instead remove the value from the hashmap
        if (pieceMap.containsKey(currentPosition)) {
          pieceMap.put(nextPosition, pieceMap.remove(currentPosition));
        }
      } catch (InvalidMoveException e) {
        throw new InvalidMoveException();
      }
    }
  }
Example #17
0
 private boolean showCustomOptions(@NotNull ModuleBuilder builder) {
   String card = builder.getBuilderId();
   if (!myCustomSteps.containsKey(card)) {
     ModuleWizardStep step = builder.getCustomOptionsStep(myContext, this);
     if (step == null) return false;
     step.updateStep();
     myCustomSteps.put(card, step);
     myOptionsPanel.add(step.getComponent(), card);
   }
   showCard(card);
   return true;
 }
 private void loadAdditionalIndentOptions() {
   synchronized (myAdditionalIndentOptions) {
     myLoadedAdditionalIndentOptions = true;
     final FileTypeIndentOptionsProvider[] providers =
         Extensions.getExtensions(FileTypeIndentOptionsProvider.EP_NAME);
     for (final FileTypeIndentOptionsProvider provider : providers) {
       if (!myAdditionalIndentOptions.containsKey(provider.getFileType())) {
         registerAdditionalIndentOptions(
             provider.getFileType(), getFileTypeIndentOptions(provider));
       }
     }
   }
 }
 @Nullable
 private FrameworkSupportNode createNode(
     final FrameworkSupportInModuleProvider provider,
     final Map<String, FrameworkSupportNode> nodes,
     final Map<FrameworkGroup<?>, FrameworkGroupNode> groupNodes,
     List<FrameworkSupportNodeBase> roots,
     List<FrameworkSupportInModuleProvider> providers,
     Set<String> associated,
     Map<String, FrameworkSupportNodeBase> associatedNodes) {
   String id = provider.getFrameworkType().getId();
   FrameworkSupportNode node = nodes.get(id);
   if (node != null || associatedNodes.containsKey(id)) {
     return node;
   }
   String underlyingTypeId = provider.getFrameworkType().getUnderlyingFrameworkTypeId();
   FrameworkSupportNodeBase parentNode = null;
   final FrameworkGroup<?> group = provider.getFrameworkType().getParentGroup();
   if (underlyingTypeId != null) {
     FrameworkSupportInModuleProvider parentProvider =
         FrameworkSupportUtil.findProvider(underlyingTypeId, providers);
     if (parentProvider == null) {
       LOG.info("Cannot find id = " + underlyingTypeId);
       return null;
     }
     parentNode =
         createNode(
             parentProvider, nodes, groupNodes, roots, providers, associated, associatedNodes);
   } else if (group != null) {
     parentNode = groupNodes.get(group);
     if (parentNode == null) {
       FrameworkGroupNode groupNode = new FrameworkGroupNode(group, null);
       if (associated.contains(groupNode.getId())) {
         associatedNodes.put(groupNode.getId(), groupNode);
       } else {
         groupNodes.put(group, groupNode);
         parentNode = groupNode;
         roots.add(groupNode);
       }
     }
   }
   node = new FrameworkSupportNode(provider, parentNode, myModel, this);
   if (associated.contains(id)) {
     associatedNodes.put(id, node);
   } else {
     nodes.put(id, node);
     if (parentNode == null) {
       roots.add(node);
     }
   }
   return node;
 }
 public JPanel getDOTItemDefinitionPanel() {
   DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
   final PrimitiveForm primitiveForm =
       dotPoint.getPrimitiveForm(_dotDefinitionDialogFrame.getSelectedPrimitiveForm());
   final DOTProperty property = _dotDefinitionDialogFrame.getSelectedProperty();
   if ((primitiveForm == null) || (property == null)) {
     return null;
   }
   PrimitiveFormPropertyPair pfpPair =
       new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
   final boolean isStatic = _dotDefinitionDialogFrame.getStaticCheckBoxState();
   if (isStatic) {
     if (!_staticPanels.containsKey(pfpPair)) {
       _staticPanels.put(pfpPair, createStaticCenterPanel(primitiveForm, property));
     }
     return _staticPanels.get(pfpPair);
   } else {
     if (!_dynamicPanels.containsKey(pfpPair)) {
       _dynamicPanels.put(pfpPair, createDynamicCenterPanel(primitiveForm, property));
     }
     return _dynamicPanels.get(pfpPair);
   }
 }
 private boolean isDuplicateSdkName(String s, Sdk sdk) {
   for (Sdk existingSdk : myProjectSdksModel.getSdks()) {
     if (existingSdk == sdk) {
       continue;
     }
     String existingName;
     if (myModificators.containsKey(existingSdk)) {
       existingName = myModificators.get(existingSdk).getName();
     } else {
       existingName = existingSdk.getName();
     }
     if (existingName.equals(s)) {
       return true;
     }
   }
   return false;
 }
 private void copyOldIndentOptions(@NonNls final String extension, final IndentOptions options) {
   final FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(extension);
   if (fileType != FileTypes.UNKNOWN
       && fileType != FileTypes.PLAIN_TEXT
       && !myAdditionalIndentOptions.containsKey(fileType)
       && !fileType.getDefaultExtension().isEmpty()) {
     registerAdditionalIndentOptions(fileType, options);
     //
     // Upgrade to version 11
     //
     if (fileType instanceof LanguageFileType) {
       Language lang = ((LanguageFileType) fileType).getLanguage();
       CommonCodeStyleSettings langSettings = myCommonSettingsManager.getCommonSettings(lang);
       if (langSettings != this && langSettings.getIndentOptions() != null) {
         langSettings.importOldIndentOptions(this);
       }
     }
   }
 }
  /**
   * getting the image representing a resource given the id of a resource
   *
   * @param svgHandle a svg handle
   * @param resourceId the id of the resource from which the image has been created
   * @return the image representation object representing the resource
   */
  public ImageRepresentation getResourceImage(SVGHandle svgHandle, String resourceId) {

    ImageRepresentation imageRepresentation = null;

    if (svgHandle != null && resourceId != null && !resourceId.equals("")) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap.containsKey(resourceId)) {

          imageRepresentation = idToImageMap.get(resourceId);
        }
      }
    }

    return imageRepresentation;
  }
Example #24
0
  public void prefixIdentifiedNames(String prefix, Map<String, String> special, boolean keepID) {
    if (special == null) {
      special = new HashMap<String, String>();
    }

    for (Map.Entry<String, XMLModelIdentifiable> stringXMLModelIdentifiableEntry :
        identifiedElements.entrySet()) {
      String newName;
      if (special.containsKey(stringXMLModelIdentifiableEntry.getKey())) { // assign a special name
        newName = special.get(stringXMLModelIdentifiableEntry.getKey());
        if (keepID) {
          stringXMLModelIdentifiableEntry.getValue().restoreDefinition();
        } else {
          stringXMLModelIdentifiableEntry.getValue().removeDefinition();
        }
      } else {
        newName = prefix + stringXMLModelIdentifiableEntry.getKey();
      }
      stringXMLModelIdentifiableEntry.getValue().rename(newName);
    }
  }
Example #25
0
  public static Color getColor(String value) {
    value = value.trim().toLowerCase();

    if (value.equals("none")) {
      return null;
    } else if (value.equals("currentColor")) {
      // indicates that painting shall be done using the color specified by the 'color' property.
      return CURRENT_COLOR;
    } else if (value.equals("inherit")) {
      // Each property may also have a specified value of 'inherit', which
      // means that, for a given element, the property takes the same
      // computed value as the property for the element's parent
      return INHERIT_COLOR;
    } else if (SVG_COLORS.containsKey(value)) {
      return SVG_COLORS.get(value);
    } else if (value.startsWith("#") && value.length() == 7) {
      return new Color(Integer.decode(value));
    } else if (value.startsWith("#") && value.length() == 4) {
      // Three digits hex value
      int th = Integer.decode(value);
      return new Color(
          (th & 0xf)
              | ((th & 0xf) << 4)
              | ((th & 0xf0) << 4)
              | ((th & 0xf0) << 8)
              | ((th & 0xf00) << 8)
              | ((th & 0xf00) << 12));
    } else if (value.startsWith("rgb")) {
      StringTokenizer tt = new StringTokenizer(value, "() ,");
      tt.nextToken();
      Color c =
          new Color(
              Integer.decode(tt.nextToken()),
              Integer.decode(tt.nextToken()),
              Integer.decode(tt.nextToken()));
      return c;
    } else {
      return null;
    }
  }
  private void showProductPanel(String id) {
    ProductInfoExt product = m_productsset.get(id);
    if (product == null) {
      if (m_productsset.containsKey(id)) {
      } else {
        try {
          java.util.List<ProductInfoExt> products = m_dlSales.getProductComments(id);

          if (products.isEmpty()) {
            m_productsset.put(id, null);
          } else {
            product = m_dlSales.getProductInfo(id);
            m_productsset.put(id, product);

            JCatalogTab jcurrTab = new JCatalogTab();
            jcurrTab.applyComponentOrientation(getComponentOrientation());
            m_jProducts.add(jcurrTab, "PRODUCT." + id);

            // Add products
            for (ProductInfoExt prod : products) {
              jcurrTab.addButton(
                  new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), getProductLabel(prod))),
                  new SelectedAction(prod),
                  prod.getTextTip(),
                  "");
            }
            CardLayout cl = (CardLayout) (m_jProducts.getLayout());
            cl.show(m_jProducts, "PRODUCT." + id);
          }
        } catch (BasicException eb) {
          m_productsset.put(id, null);
        }
      }
    } else {

      CardLayout cl = (CardLayout) (m_jProducts.getLayout());
      cl.show(m_jProducts, "PRODUCT." + id);
    }
  }
  @Override
  public void loadState(final Element element) {
    String className = null;
    Element lafElement = element.getChild(ELEMENT_LAF);
    if (lafElement != null) {
      className = lafElement.getAttributeValue(ATTRIBUTE_CLASS_NAME);
      if (className != null && ourLafClassesAliases.containsKey(className)) {
        className = ourLafClassesAliases.get(className);
      }
    }

    UIManager.LookAndFeelInfo laf = findLaf(className);
    // If LAF is undefined (wrong class name or something else) we have set default LAF anyway.
    if (laf == null) {
      laf = getDefaultLaf();
    }

    if (myCurrentLaf != null && !laf.getClassName().equals(myCurrentLaf.getClassName())) {
      setCurrentLookAndFeel(laf);
      updateUI();
    }

    myCurrentLaf = laf;
  }
  /**
   * checks if the map associating an id to an image is consistent
   *
   * @param svgHandle a svg handle
   */
  protected void checkResourceRepresentationsConsistency(SVGHandle svgHandle) {

    if (svgHandle != null) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap != null) {

          // getting the map associating the id of a resource to the
          // resource node
          LinkedList<String> resourceNames = new LinkedList<String>();
          resourceNames.add("linearGradient");
          resourceNames.add("radialGradient");
          resourceNames.add("pattern");
          resourceNames.add("marker");

          Map<String, Element> resources =
              svgHandle
                  .getSvgResourcesManager()
                  .getResourcesFromDefs(svgHandle.getCanvas().getDocument(), resourceNames);

          for (String id : new LinkedList<String>(idToImageMap.keySet())) {

            if (id != null && !id.equals("") && !resources.containsKey(id)) {

              idToImageMap.remove(id);
            }
          }
        }
      }
    }
  }
Example #29
0
 public boolean isDefaultSeverity(@NotNull HighlightSeverity severity) {
   return STANDARD_SEVERITIES.containsKey(severity.myName);
 }
Example #30
0
  public static void main(String[] args) {

    String lettersAndDigits = "abcdefghijklmnopqrstuvwxyz1234567890";

    BiMap<Character, Double> rate =
        HashBiMap.create(
            new HashMap<Character, Double>() {

              {
                put('a', 8.167);
                put('b', 1.492);
                put('c', 2.782);
                put('d', 4.253);
                put('e', 12.702);
                put('f', 2.228);
                put('g', 2.015);
                put('h', 6.094);
                put('i', 6.966);
                put('j', 0.153);
                put('k', 0.772);
                put('l', 4.025);
                put('m', 2.406);
                put('n', 6.749);
                put('o', 7.507);
                put('p', 1.929);
                put('q', 0.095);
                put('r', 5.987);
                put('s', 6.327);
                put('t', 9.056);
                put('u', 2.758);
                put('v', 0.978);
                put('w', 2.360);
                put('x', 0.150);
                put('y', 1.974);
                put('z', 0.074);
              }
            });

    Map sortedFreq = MapUtils.sortByValue(rate);

    BiMap<Double, Character> inverseRate = rate.inverse();
    Map<Double, Character> sortedInverseRate = MapUtils.sortByValue(inverseRate);

    MapUtils.printMap(sortedInverseRate);
    System.out.println("=================================================");

    final String message =
        "nci3 y 2p7, h2p g2b 24pc m37xz njbs5bz 7pbz i4vscl d4cy43o3jbme "
            + "y mpyc4uc66p 6sc635p7xz d3426c5py, 5pri3 1bu5b n4puc6x.;";

    final Map<Character, Double> messageRate = new HashMap<Character, Double>();
    for (int i = 0; i < message.length(); i++) {
      Character character = message.charAt(i);
      if (lettersAndDigits.contains(character.toString())) {
        // only letters and digits
        if (messageRate.containsKey(character))
          messageRate.put(character, messageRate.get(character) + 1);
        else messageRate.put(character, 1d);
      }
    }

    Double length = new Double(message.length());
    for (Character key : messageRate.keySet()) {
      messageRate.put(key, messageRate.get(key) / length * 100);
    }

    System.out.println("==========Message Characters Rate, %==================");

    MapUtils.printMap(messageRate);

    final Map<Character, Double> sortedMessageRate = MapUtils.sortByValue(messageRate);

    System.out.println("=======================Sorted===================");
    MapUtils.printMap(sortedMessageRate);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            JFrame jFrame = new JFrame();
            jFrame.setLayout(new BorderLayout());
            JTable jTable = new JTable();

            final JTextArea jTextArea = new JTextArea();
            jTextArea.append(message);
            jTextArea.setPreferredSize(new Dimension(600, 50));
            jFrame.add(jTextArea, BorderLayout.NORTH);

            final JTextArea jTextArea2 = new JTextArea();

            jTextArea2.setPreferredSize(new Dimension(600, 50));
            jFrame.add(jTextArea2, BorderLayout.SOUTH);

            JButton jButton = new JButton("replace");
            jButton.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    jTextArea2.setText("");
                    jTextArea2.setText(replace());
                  }

                  private String replace() {
                    StringBuilder sb = new StringBuilder();
                    String src = jTextArea.getText();
                    for (int i = 0; i < src.length(); i++) {
                      Character character = src.charAt(i);
                    }
                    return "new value";
                  }
                });
            jFrame.add(jButton, BorderLayout.WEST);

            DefaultTableModel defaultTableModel = new DefaultTableModel();
            jTable.setModel(defaultTableModel);
            defaultTableModel.setRowCount(messageRate.size());
            defaultTableModel.setColumnCount(3);
            TableColumn column = jTable.getColumnModel().getColumn(2);
            Character[] values =
                new Character[] {
                  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
                  'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
                };
            column.setCellRenderer(new MyComboBoxCellRenderer(values));
            column.setCellEditor(new MyComboBoxEditor(values));
            jFrame.add(jTable, BorderLayout.EAST);

            int i = 0;
            for (Character character : sortedMessageRate.keySet()) {
              defaultTableModel.setValueAt(character.toString(), i, 0);
              defaultTableModel.setValueAt(sortedMessageRate.get(character).toString(), i, 1);
              JComboBox jComboBox = new JComboBox<Character>(new DefaultComboBoxModel<Character>());
              defaultTableModel.setValueAt(jComboBox, i++, 2);
            }

            jFrame.setVisible(true);
          }
        });

    Set<Double> usedSet = new HashSet<Double>();

    StringBuilder newMessage = new StringBuilder();
    for (int i = 0; i < message.length(); i++) {
      Character character = message.charAt(i);
      if (lettersAndDigits.contains(character.toString())) {
        Double charFreq = sortedMessageRate.get(character);
        Double minDelta = 100d;
        Character minValue;
        boolean moreThanOne = false;
        for (Double otherFreq : inverseRate.keySet()) {
          Double d = charFreq - otherFreq;
          if (usedSet.contains(otherFreq)) {}

          if (d < minDelta && !usedSet.contains(otherFreq)) {
            minDelta = d;
            minValue = inverseRate.get(minDelta);
            usedSet.add(otherFreq);
          }
          if (minDelta == d) {
            moreThanOne = true;
            return;
          }
        }

        if (!moreThanOne) {
          // newMessage.append()
        }
      }
    }
  }