List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:com.att.aro.ui.view.diagnostictab.plot.GpsPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { if (analysis == null) { logger.info("analysis data is null"); return;/*from w w w . j a v a 2 s . c om*/ } gpsData.removeAllSeries(); locationData.removeAllSeries(); TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType(); if (resultType.equals(TraceResultType.TRACE_FILE)) { logger.info("didn't get analysis trace data!"); } else { try { image = ImageIO.read(GpsPlot.class.getResourceAsStream("/images/location.png")); image = ImageHelper.resize(image, 12, 12); } catch (IOException e) { e.printStackTrace(); } // create the GPS dataset... Map<GpsState, XYIntervalSeries> seriesMap = new EnumMap<GpsState, XYIntervalSeries>(GpsState.class); for (GpsState eventType : GpsState.values()) { XYIntervalSeries series = new XYIntervalSeries(eventType); seriesMap.put(eventType, series); gpsData.addSeries(series); } series = new XYSeries("location"); TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult(); listLocationEvent = (ArrayList<LocationEvent>) traceresult.getLocationEventInfos(); for (int idx = 0; idx < listLocationEvent.size(); idx++) { series.add(listLocationEvent.get(idx).getTimeRecorded(), 0.5); } locationData.addSeries(series); Iterator<GpsInfo> iter = analysis.getAnalyzerResult().getTraceresult().getGpsInfos().iterator(); if (iter.hasNext()) { while (iter.hasNext()) { GpsInfo gpsEvent = iter.next(); if (gpsEvent.getGpsState() != GpsState.GPS_DISABLED) { seriesMap.get(gpsEvent.getGpsState()).add(gpsEvent.getBeginTimeStamp(), gpsEvent.getBeginTimeStamp(), gpsEvent.getEndTimeStamp(), 0.5, 0, 1); } } } XYItemRenderer renderer = plot.getRenderer(0); // 0 - is the default renderer from XYItem renderer. // Looks like renderer is using the index descending order, so setting the index of the GPS background as 2 & location information index as 1. if (renderer == null) { renderer = plot.getRenderer(2); } renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_STANDBY), Color.YELLOW); renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_ACTIVE), new Color(34, 177, 76)); // Assign ToolTip to renderer renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { GpsState eventType = (GpsState) gpsData.getSeries(series).getKey(); return MessageFormat.format(ResourceBundleHelper.getMessageString("gps.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(eventType)); } }); plot.setRenderer(2, renderer); // Assign ToolTip to renderer LocationImageRenderer renderer_loc = new LocationImageRenderer(); plot.setRenderer(1, renderer_loc); renderer_loc.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { // Update tooltip of location data LocationEvent event = listLocationEvent.get(item); StringBuffer displayInfo = new StringBuffer( ResourceBundleHelper.getMessageString("location.tooltip.prefix")); displayInfo.append( MessageFormat.format(ResourceBundleHelper.getMessageString("location.tooltip.content"), event.getTimeRecorded(), event.getLatitude(), event.getLongitude(), event.getProvider(), event.getLocality())); displayInfo.append(ResourceBundleHelper.getMessageString("location.tooltip.suffix")); return displayInfo.toString(); } }); } plot.setDataset(2, gpsData); plot.setDataset(1, locationData); }
From source file:com.googlecode.osde.internal.editors.basic.FeaturesPart.java
public FeaturesPart(ModulePrefsPage page) { this.page = page; buttonMap = new EnumMap<FeatureName, Button>(FeatureName.class); }
From source file:musite.prediction.feature.disorder.DisorderTest.java
@Test public void extractMean() throws IOException { // String xml = "testData/musite-test.xml"; String xml = "data/Uniprot/uniprot_sprot.201009.ptm.musite.with.disorder.xml"; ProteinsXMLReader reader = DisorderUtil.getDisorderXMLReader(); Proteins proteins = MusiteIOUtil.read(reader, xml); TTest ttest = new TTestImpl(); StandardDeviation std = new StandardDeviation(); Map<AminoAcid, double[]> mapAAScores = new EnumMap<AminoAcid, double[]>(AminoAcid.class); for (AminoAcid aa : AminoAcid.values()) { List<Double> scores = new ArrayList<Double>(); Iterator<Protein> it = proteins.proteinIterator(); while (it.hasNext()) { Protein protein = it.next(); List<Double> dis = DisorderUtil.extractDisorder(protein, aa); if (dis != null) scores.addAll(dis);/*from w w w .j a v a 2 s . com*/ } mapAAScores.put(aa, list2array(scores)); // System.out.print(aa.toString()+":"); // System.out.println(""+average(scores)+"("+scores.size()+")"); } Map<String, AminoAcid> mapKeyAA = getMapKeywordAminoAcid(); for (PTM ptm : PTM.values()) { Set<String> keywords = ptm.getUniprotKeywords(); for (String keyword : keywords) { AnnotationFilter filter = ResidueAnnotationUtil.createAnnotationFilter("keyword", Collections.singleton(keyword), true); double[] scores; { List<Double> list = new ArrayList<Double>(); Iterator<Protein> it = proteins.proteinIterator(); while (it.hasNext()) { Protein protein = it.next(); List<Double> dis = DisorderUtil.extractDisorder(protein, ptm, filter); if (dis != null) list.addAll(dis); } scores = list2array(list); } System.out.print(ptm.toString()); System.out.print("\t" + keyword); if (scores.length == 0) System.out.println("\tno_site"); else { System.out.print("\t" + scores.length); double mean = StatUtils.mean(scores); System.out.print("\t" + mean); System.out.print("\t" + std.evaluate(scores, mean)); AminoAcid aa = mapKeyAA.get(keyword); double[] bg = mapAAScores.get(aa); System.out.print("\t" + aa.toString()); System.out.print("\t" + bg.length); mean = StatUtils.mean(bg); System.out.print("\t" + mean); System.out.print("\t" + std.evaluate(bg, mean)); double pvalue = -1.0; try { pvalue = ttest.tTest(scores, bg); } catch (Exception e) { // e.printStackTrace(); } if (pvalue != -1.0) System.out.print("\t" + pvalue); System.out.println(); } } } }
From source file:org.obm.sync.solr.jms.DefaultCommandConverter.java
@Inject @VisibleForTesting//www. j a va 2 s . co m public DefaultCommandConverter(LocatorService locatorService, ContactIndexer.Factory contactIndexerFactory, EventIndexer.Factory eventIndexerFactory) { this.locatorService = locatorService; MultiThreadedHttpConnectionManager cnxManager = new MultiThreadedHttpConnectionManager(); cnxManager.getParams().setDefaultMaxConnectionsPerHost(10); cnxManager.getParams().setMaxTotalConnections(100); solrHttpClient = new HttpClient(cnxManager); solrServiceToFactoryMap = new EnumMap<SolrService, IndexerFactory<? extends Serializable>>( SolrService.class); solrServiceToFactoryMap.put(SolrService.EVENT_SERVICE, eventIndexerFactory); solrServiceToFactoryMap.put(SolrService.CONTACT_SERVICE, contactIndexerFactory); }
From source file:org.lunarray.model.generation.vaadin.render.factories.table.vaadin.TablePropertyRenderStrategyFactoryImpl.java
/** * The default constructor.//from w w w. ja v a2 s .c om * * @param tableComponent * The table. */ public TablePropertyRenderStrategyFactoryImpl(final TableComponent tableComponent) { Validate.notNull(tableComponent, "Table component may not be null."); this.tableComponent = tableComponent; this.defaultFactory = new TextOutputPropertyStrategy.Factory(); this.factories = new EnumMap<RenderType, StrategyFactory>(RenderType.class); this.factories.put(RenderType.CHECKBOX, new CheckboxOutputPropertyStrategy.Factory()); }
From source file:org.egov.infra.security.utils.SecureCodeUtils.java
public static File generateSecureCode(String content, BarcodeFormat format, int imgWidth, int imgHeight) { try {/*from w w w . j a va2s . c o m*/ Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class); hints.put(CHARACTER_SET, encoding()); hints.put(MARGIN, 1); BitMatrix secureCodeMatrix = new MultiFormatWriter().encode(content, format, imgWidth, imgHeight, hints); Path secureCodePath = Files.createTempFile(RandomStringUtils.randomAlphabetic(5), PNG_EXTN); MatrixToImageWriter.writeToPath(secureCodeMatrix, PNG_FORMAT_NAME, secureCodePath); return secureCodePath.toFile(); } catch (WriterException | IOException e) { throw new ApplicationRuntimeException("Error occurred while generating Secure Code", e); } }
From source file:io.lavagna.web.api.ApplicationConfigurationController.java
@RequestMapping(value = "/api/application-configuration/", method = RequestMethod.GET) public Map<Key, String> findAll() { Map<Key, String> res = new EnumMap<>(Key.class); for (ConfigurationKeyValue kv : configurationRepository.findAll()) { res.put(kv.getFirst(), kv.getSecond()); }/*from ww w. j ava 2s . c o m*/ return res; }
From source file:io.lavagna.web.api.MilestoneController.java
private Map<ColumnDefinition, Integer> getStatusColors(int projectId) { Map<ColumnDefinition, Integer> statusColors = new EnumMap<>(ColumnDefinition.class); for (BoardColumnDefinition cd : projectService.findColumnDefinitionsByProjectId(projectId)) { statusColors.put(cd.getValue(), cd.getColor()); }/* w ww . j a v a 2 s . com*/ return statusColors; }
From source file:pl.edu.icm.cermine.evaluation.SVMBodyClassificationEvaluator.java
@Override public List<TrainingSample<BxZoneLabel>> getSamples(String inputFile, String ext) throws AnalysisException { Map<BxZoneLabel, BxZoneLabel> map = new EnumMap<BxZoneLabel, BxZoneLabel>(BxZoneLabel.class); map.put(BxZoneLabel.BODY_ACKNOWLEDGMENT, BxZoneLabel.BODY_CONTENT); map.put(BxZoneLabel.BODY_CONFLICT_STMT, BxZoneLabel.BODY_CONTENT); map.put(BxZoneLabel.BODY_EQUATION, BxZoneLabel.BODY_JUNK); map.put(BxZoneLabel.BODY_FIGURE, BxZoneLabel.BODY_JUNK); map.put(BxZoneLabel.BODY_GLOSSARY, BxZoneLabel.BODY_JUNK); map.put(BxZoneLabel.BODY_TABLE, BxZoneLabel.BODY_JUNK); DocumentsIterator it = new DocumentsIterator(inputFile, ext); List<TrainingSample<BxZoneLabel>> samples = BxDocsToTrainingSamplesConverter .getZoneTrainingSamples(it.iterator(), getFeatureVectorBuilder(), map); List<TrainingSample<BxZoneLabel>> tss = ClassificationUtils.filterElements(samples, BxZoneLabelCategory.CAT_BODY); return tss;/*from ww w .jav a2s.c om*/ }
From source file:com.figo.campaignhelper.GenerateActivity.java
Bitmap encodeAsBitmap(String contents) throws WriterException { String contentsToEncode = contents; if (contentsToEncode == null) { return null; }//from w w w. j av a2s . c om Map<EncodeHintType, Object> hints = null; String encoding = guessAppropriateEncoding(contentsToEncode); if (encoding != null) { hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class); hints.put(EncodeHintType.CHARACTER_SET, encoding); } MultiFormatWriter writer = new MultiFormatWriter(); WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); int widthD = display.getWidth(); int heightD = display.getHeight(); int dimension = widthD < heightD ? widthD : heightD; dimension = dimension * 7 / 8; BitMatrix result = writer.encode(contentsToEncode, BarcodeFormat.QR_CODE, dimension, dimension, hints); int width = result.getWidth(); int height = result.getHeight(); int[] pixels = new int[width * height]; for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.WHITE; } } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; }