public void processCookieHeader(String header) { String[] parts = header.substring("set-cookie:".length()).split(";"); boolean httpOnly = false; boolean secure = false; String name = ""; int count = 0; for (String part : parts) { String[] pair = part.split("="); String key = pair[0].trim().toUpperCase(); switch (key) { case "HTTPONLY": httpOnly = true; break; case "SECURE": secure = true; break; default: // pass } if (count == 0) { name = pair[0].trim(); } count += 1; } if (!name.isEmpty()) { CookieStatistics cs; if (cookieStatistics.get(name) != null) { cs = cookieStatistics.get(name); } else { cs = new CookieStatistics(name); cookieStatistics.put(name, cs); } cs.addCookieValues(httpOnly, secure); } }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // Get the renderer component from parent class JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); // Get icon to use for the list item value Character character = (Character) value; Config.ConfigEntry ce = config.get(character.getName()); Icon icon = null; if (ce == null) { icon = icons.get(NOTOK); label.setToolTipText( "Double-click to enter configuration information for this character, right-click for more options"); } else { if (ce.isOk()) { icon = icons.get(OK); ui.exportAllButton.setEnabled(true); } else { icon = icons.get(NOTOK); } } // Set icon to display for value label.setIcon(icon); return label; }
public UpdateOrStatusOptionsDialog(Project project, Map<Configurable, AbstractVcs> confs) { super(project); setTitle(getRealTitle()); myProject = project; if (confs.size() == 1) { myMainPanel = new JPanel(new BorderLayout()); final Configurable configurable = confs.keySet().iterator().next(); addComponent(confs.get(configurable), configurable, BorderLayout.CENTER); myMainPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); } else { myMainPanel = new JBTabbedPane(); final ArrayList<AbstractVcs> vcses = new ArrayList<>(confs.values()); Collections.sort( vcses, new Comparator<AbstractVcs>() { public int compare(final AbstractVcs o1, final AbstractVcs o2) { return o1.getDisplayName().compareTo(o2.getDisplayName()); } }); Map<AbstractVcs, Configurable> vcsToConfigurable = revertMap(confs); for (AbstractVcs vcs : vcses) { addComponent(vcs, vcsToConfigurable.get(vcs), vcs.getDisplayName()); } } init(); }
// Note: this comparator imposes orderings that are inconsistent with equals. public int compare(String a, String b) { if (base.get(a) >= base.get(b)) { return -1; } else { return 1; } // returning 0 would merge keys }
private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args) throws DebuggerException { if (bndlPrefix != null) { if (connector.transport().name().equals("dt_shmem")) { Argument a = (Argument) args.get("name"); if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_shmem")) .format(new Object[] {a.value()}), ERR_OUT); } else if (connector.transport().name().equals("dt_socket")) { Argument name = (Argument) args.get("hostname"); Argument port = (Argument) args.get("port"); if ((name == null) || (port == null)) println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_socket")) .format(new Object[] {name.value(), port.value()}), ERR_OUT); } else println(bundle.getString(bndlPrefix), ERR_OUT); } // launch VM try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N return connector.attach(args); } catch (Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee")) .format(new Object[] {e.toString()}), e); } }
@Nullable public HighlightSeverity getSeverity(@NotNull String name) { final HighlightInfoType type = STANDARD_SEVERITIES.get(name); if (type != null) return type.getSeverity(null); final SeverityBasedTextAttributes attributes = myMap.get(name); if (attributes != null) return attributes.getSeverity(); return null; }
private void reloadSdk(@NotNull Sdk currentSdk) { /* PythonSdkUpdater.update invalidates the modificator so we need to create a new one for further changes */ if (PythonSdkUpdater.update(currentSdk, myModificators.get(currentSdk), myProject, null)) { myModifiedModificators.remove(myModificators.get(currentSdk)); myModificators.put(currentSdk, currentSdk.getSdkModificator()); } }
/** highlight a route (maybe to show it's in use...) */ public void highlightRoute(String src, String dst) { Iterator i = rows.iterator(); while (i.hasNext()) { Map temp = (Map) i.next(); if (temp.get("Address").equals(dst) && temp.get("Pivot").equals(src)) { temp.put("Active", Boolean.TRUE); } } }
public void showTask(String sTaskClass) { m_appview.waitCursorBegin(); if (m_appuser.hasPermission(sTaskClass)) { JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass); // cierro la antigua if (m_jLastView == null || (m_jMyView != m_jLastView && m_jLastView.deactivate())) { // Construct the new view if (m_jMyView == null) { // Is the view prepared m_jMyView = m_aPreparedViews.get(sTaskClass); if (m_jMyView == null) { // The view is not prepared. Try to get as a Bean... try { m_jMyView = (JPanelView) m_appview.getBean(sTaskClass); } catch (BeanFactoryException e) { m_jMyView = new JPanelNull(m_appview, e); } } m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass); m_aCreatedViews.put(sTaskClass, m_jMyView); } // ejecuto la tarea try { m_jMyView.activate(); } catch (BasicException e) { JMessageDialog.showMessage( this, new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e)); } // se tiene que mostrar el panel m_jLastView = m_jMyView; showView(sTaskClass); // Y ahora que he cerrado la antigua me abro yo String sTitle = m_jMyView.getTitle(); m_jPanelTitle.setVisible(sTitle != null); m_jTitle.setText(sTitle); } } else { // No hay permisos para ejecutar la accion... JMessageDialog.showMessage( this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions"))); } m_appview.waitCursorEnd(); }
/** * 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); }
@Override public GridCellImpl getCellFor(final Content content) { // check if the content is already in some cell GridCellImpl current = myContent2Cell.get(content); if (current != null) return current; // view may be shared between several contents with the same ID in different cells // (temporary contents like "Dump Stack" or "Console Result") View view = getStateFor(content); final GridCellImpl cell = myPlaceInGrid2Cell.get(view.getPlaceInGrid()); assert cell != null : "Unknown place in grid: " + view.getPlaceInGrid().name(); return cell; }
private void configChanged(String activeConfig) { DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(""); SortedSet<String> alphaConfigs = new TreeSet<String>( new Comparator<String>() { Collator coll = Collator.getInstance(); public int compare(String s1, String s2) { return coll.compare(label(s1), label(s2)); } private String label(String c) { Map<String, String> m = configs.get(c); String label = m.get("$label"); // NOI18N return label != null ? label : c; } }); for (Map.Entry<String, Map<String, String>> entry : configs.entrySet()) { String config = entry.getKey(); if (config != null && entry.getValue() != null) { alphaConfigs.add(config); } } for (String c : alphaConfigs) { model.addElement(c); } configCombo.setModel(model); configCombo.setSelectedItem(activeConfig != null ? activeConfig : ""); Map<String, String> m = configs.get(activeConfig); Map<String, String> def = configs.get(null); if (m != null) { // BEGIN Deprecated if (compProviderDeprecated != null) { compProviderDeprecated.configUpdated(m); } // END Deprecated for (J2SECategoryExtensionProvider compProvider : compProviders) { compProvider.configUpdated(m); } for (int i = 0; i < data.length; i++) { String v = m.get(keys[i]); if (v == null) { // display default value v = def.get(keys[i]); } data[i].setText(v); } } // else ?? configDel.setEnabled(activeConfig != null); }
/** Draws the game */ @Override protected void paintComponent(Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; /** Draw all the non-falling blocks on the board. Non-OUTSIDE blocks have rounded corners. */ for (int row = 0; row < board.getHeight(); row++) { for (int column = 0; column < board.getWidth(); column++) { if (board.getSquareType(row, column) != SquareType.OUTSIDE) { Shape tetrominoBlock = new RoundRectangle2D.Double( column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT, 5, 5); g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column))); g2.fill(tetrominoBlock); g2.draw(tetrominoBlock); } else { Shape tetrominoBlock = new Rectangle2D.Double( column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT); g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column))); g2.fill(tetrominoBlock); g2.draw(tetrominoBlock); } } } Poly tempPoly = board.getFalling(); if (tempPoly != null) { for (int row = 0; row < tempPoly.getSize(); row++) { for (int column = 0; column < tempPoly.getSize(); column++) { if (tempPoly.getSquareType(row, column) != SquareType.EMPTY) { Shape tetrominoBlock = new RoundRectangle2D.Double( (column + board.getFallingPosX()) * SQUARE_WIDTH, (row + board.getFallingPosY()) * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT, 5, 5); g2.setColor(SQUARE_COLOR.get(tempPoly.getSquareType(row, column))); g2.fill(tetrominoBlock); g2.draw(tetrominoBlock); } } } } }
@Override public void writeExternal(Element element) throws WriteExternalException { List<HighlightSeverity> list = getOrderAsList(getOrderMap()); for (HighlightSeverity severity : list) { Element info = new Element(INFO_TAG); String severityName = severity.getName(); final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity); if (infoType != null) { infoType.writeExternal(info); final Color color = myRendererColors.get(severityName); if (color != null) { info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16)); } element.addContent(info); } } if (myReadOrder != null && !myReadOrder.isEmpty()) { myReadOrder.writeExternal(element); } else if (!getDefaultOrder().equals(list)) { final JDOMExternalizableStringList ext = new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), "")); getOrderMap() .forEachEntry( new TObjectIntProcedure<HighlightSeverity>() { @Override public boolean execute(HighlightSeverity orderSeverity, int oIdx) { ext.set(oIdx, orderSeverity.getName()); return true; } }); ext.writeExternal(element); } }
@NotNull public synchronized List<Breakpoint> getBreakpoints() { if (myBreakpointsListForIteration == null) { myBreakpointsListForIteration = new ArrayList<Breakpoint>(myBreakpoints.size()); XBreakpoint<?>[] xBreakpoints = ApplicationManager.getApplication() .runReadAction( new Computable<XBreakpoint<?>[]>() { public XBreakpoint<?>[] compute() { return getXBreakpointManager().getAllBreakpoints(); } }); for (XBreakpoint<?> xBreakpoint : xBreakpoints) { if (isJavaType(xBreakpoint)) { Breakpoint breakpoint = myBreakpoints.get(xBreakpoint); if (breakpoint == null) { breakpoint = createJavaBreakpoint(xBreakpoint); myBreakpoints.put(xBreakpoint, breakpoint); } } } myBreakpointsListForIteration.addAll(myBreakpoints.values()); } return myBreakpointsListForIteration; }
@Nullable public Breakpoint findMasterBreakpoint(@NotNull Breakpoint dependentBreakpoint) { XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl) getXBreakpointManager()).getDependentBreakpointManager(); return myBreakpoints.get( dependentBreakpointManager.getMasterBreakpoint(dependentBreakpoint.myXBreakpoint)); }
private static void patchGtkDefaults(UIDefaults defaults) { if (!UIUtil.isUnderGTKLookAndFeel()) return; Map<String, Icon> map = ContainerUtil.newHashMap( Arrays.asList( "OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"), Arrays.asList( AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog)); // GTK+ L&F keeps icons hidden in style SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON); for (String key : map.keySet()) { if (defaults.get(key) != null) continue; Object icon = style == null ? null : style.get(null, key); defaults.put(key, icon instanceof Icon ? icon : map.get(key)); } Color fg = defaults.getColor("Label.foreground"); Color bg = defaults.getColor("Label.background"); if (fg != null && bg != null) { defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5)); } }
@NotNull private InspectionTreeNode getToolParentNode( @NotNull String groupName, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) { if (groupName.isEmpty()) { return getRelativeRootNode(groupedBySeverity, errorLevel); } ConcurrentMap<String, InspectionGroupNode> map = myGroups.get(errorLevel); if (map == null) { map = ConcurrencyUtil.cacheOrGet( myGroups, errorLevel, ContainerUtil.<String, InspectionGroupNode>newConcurrentMap()); } InspectionGroupNode group; if (groupedBySeverity) { group = map.get(groupName); } else { group = null; for (Map<String, InspectionGroupNode> groupMap : myGroups.values()) { if ((group = groupMap.get(groupName)) != null) break; } } if (group == null) { group = ConcurrencyUtil.cacheOrGet(map, groupName, new InspectionGroupNode(groupName)); addChildNodeInEDT(getRelativeRootNode(groupedBySeverity, errorLevel), group); } return group; }
/** * Set the object to be edited. * * @param value The object to be edited. */ public void setObject(Object value) { if (!(_type.isInstance(value))) { throw new IllegalArgumentException(value.getClass() + " is not of type " + _type); } _value = value; // Disable event generation. _squelchChangeEvents = true; // Iterate over each property, doing a lookup on the associated editor // and setting the editor's value to the value of the property. Iterator it = _prop2Editor.keySet().iterator(); while (it.hasNext()) { PropertyDescriptor desc = (PropertyDescriptor) it.next(); PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc); Method reader = desc.getReadMethod(); if (reader != null) { try { Object val = reader.invoke(_value, null); editor.setValue(val); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { ex.getTargetException().printStackTrace(); } } } // Enable event generation. _squelchChangeEvents = false; }
void install() { Vector components = new Vector(); Vector indicies = new Vector(); int size = 0; JPanel comp = selectComponents.comp; Vector ids = selectComponents.filesets; for (int i = 0; i < comp.getComponentCount(); i++) { if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) { size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size"); components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset")); indicies.addElement(new Integer(i)); } } String installDir = chooseDirectory.installDir.getText(); Map osTaskDirs = chooseDirectory.osTaskDirs; Iterator keys = osTaskDirs.keySet().iterator(); while (keys.hasNext()) { OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next(); String dir = ((JTextField) osTaskDirs.get(osTask)).getText(); if (dir != null && dir.length() != 0) { osTask.setEnabled(true); osTask.setDirectory(dir); } else osTask.setEnabled(false); } InstallThread thread = new InstallThread(installer, progress, installDir, osTasks, size, components, indicies); progress.setThread(thread); thread.start(); }
public void selectBreakpoint(Breakpoint breakpoint) { final CheckedTreeNode node = myDescriptorToNodeMap.get(new BreakpointDescriptor(breakpoint)); if (node == null) { return; } TreeUtil.selectNode(this, node); }
@Nullable public RunContentDescriptor getSelectedContent() { for (String activeWindow : myToolwindowIdZbuffer) { final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(activeWindow); if (contentManager == null) { continue; } final Content selectedContent = contentManager.getSelectedContent(); if (selectedContent == null) { if (contentManager.getContentCount() == 0) { // continue to the next window if the content manager is empty continue; } else { // stop iteration over windows because there is some content in the window and the window // is the last used one break; } } // here we have selected content return getRunContentDescriptorByContent(selectedContent); } return null; }
private void resetFromFile(@NotNull VirtualFile file, @NotNull Project project) { final Module moduleForFile = ModuleUtilCore.findModuleForFile(file, project); if (moduleForFile == null) { return; } final VirtualFile parent = file.getParent(); if (parent == null) { return; } if (myModule == null) { final Object prev = myModuleCombo.getSelectedItem(); myModuleCombo.setSelectedItem(moduleForFile); if (!moduleForFile.equals(myModuleCombo.getSelectedItem())) { myModuleCombo.setSelectedItem(prev); return; } } else if (!myModule.equals(moduleForFile)) { return; } final JCheckBox checkBox = myCheckBoxes.get(parent.getName()); if (checkBox == null) { return; } for (JCheckBox checkBox1 : myCheckBoxes.values()) { checkBox1.setSelected(false); } checkBox.setSelected(true); myFileNameCombo.getEditor().setItem(file.getName()); }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #93658: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N String config = (String) value; String label; if (config == null) { // uninitialized? label = null; } else if (config.length() > 0) { Map<String, String> m = configs.get(config); label = m != null ? m.get("$label") : /* temporary? */ null; // NOI18N if (label == null) { label = config; } } else { label = NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle") .getString("J2SEConfigurationProvider.default.label"); // NOI18N } setText(label); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
private void initCabins() { for (CabinType t : CabinType.values()) { Cabin cabin = new Cabin(t.toString()); cabin.setPosition(floors.get(FloorType.TENTH).getPosition()); cabins.put(t, cabin); } }
public void setMetricsResults(MetricDisplaySpecification displaySpecification, MetricsRun run) { final MetricCategory[] categories = MetricCategory.values(); for (final MetricCategory category : categories) { final JTable table = tables.get(category); final String type = MetricsCategoryNameUtil.getShortNameForCategory(category); final MetricTableSpecification tableSpecification = displaySpecification.getSpecification(category); final MetricsResult results = run.getResultsForCategory(category); final MetricTableModel model = new MetricTableModel(results, type, tableSpecification); table.setModel(model); final Container tab = table.getParent().getParent(); if (model.getRowCount() == 0) { tabbedPane.remove(tab); continue; } final String longName = MetricsCategoryNameUtil.getLongNameForCategory(category); tabbedPane.add(tab, longName); final MyColumnListener columnListener = new MyColumnListener(tableSpecification, table); final TableColumnModel columnModel = table.getColumnModel(); columnModel.addColumnModelListener(columnListener); final int columnCount = columnModel.getColumnCount(); for (int i = 0; i < columnCount; i++) { final TableColumn column = columnModel.getColumn(i); column.addPropertyChangeListener(columnListener); } setRenderers(table, type); setColumnWidths(table, tableSpecification); } }
void finish(BddtHistoryItem hi) { GraphBlock gb = in_blocks.get(hi.getThread()); if (gb != null) { gb.finish(hi.getTime()); in_blocks.remove(hi.getThread()); } }
/** * Arena consturctor. * * @param parent The component where the arena will be displayed in. */ public Arena(Component parent) { super(); this.parent = parent; this.isVisible = false; if (parent == null) { this.isVisible = false; } else { parent.addKeyListener(this); } FrictionBuffer get = frictionBufferCache.get(this.svgFileName); if (get == null) { // if not in cache, create new instance and frictionBuffer = new FrictionBuffer(this); frictionBufferCache.put(this.svgFileName, frictionBuffer); if (DEBUG_FRICTION_CACHE) { System.out.println( "Cached friction buffer not found, I have created new instance and cached it."); } } else { frictionBuffer = get; if (DEBUG_FRICTION_CACHE) { System.out.println("Cached friction buffer found."); } } }
/** * @param type * @param min * @param createDef * @param manager - must not be null if min is not null * @param scope - must not be null if min is not null */ private GrTypeComboBox( @Nullable PsiType type, @Nullable PsiType min, boolean createDef, @Nullable PsiManager manager, @Nullable GlobalSearchScope scope) { LOG.assertTrue(min == null || manager != null); LOG.assertTrue(min == null || scope != null); if (type instanceof PsiDisjunctionType) type = ((PsiDisjunctionType) type).getLeastUpperBound(); Map<String, PsiType> types = Collections.emptyMap(); if (type != null) { types = getCompatibleTypeNames(type, min, manager, scope); } if (createDef || types.isEmpty()) { addItem(new PsiTypeItem(null)); } for (String typeName : types.keySet()) { addItem(new PsiTypeItem(types.get(typeName))); } if (createDef && getItemCount() > 1) { setSelectedIndex(1); } }
private Color getThreadBlockColor(BumpThread bt) { if (bt == null) return Color.BLACK; synchronized (thread_colors) { Color c = thread_colors.get(bt); if (c == null) { double v; int ct = thread_colors.size(); if (ct == 0) v = 0; else if (ct == 1) v = 1; else { v = 0.5; int p0 = ct - 1; int p1 = 1; for (int p = p0; p > 1; p /= 2) { v /= 2.0; p0 -= p1; p1 *= 2; } if ((p0 & 1) == 0) p0 = 2 * p1 - p0 + 1; v = v * p0; } float h = (float) (v * 0.8); float s = 0.7f; float b = 1.0f; int rgb = Color.HSBtoRGB(h, s, b); rgb |= 0xc0000000; c = new Color(rgb, true); thread_colors.put(bt, c); } return c; } }