Example usage for java.util Hashtable containsKey

List of usage examples for java.util Hashtable containsKey

Introduction

In this page you can find the example usage for java.util Hashtable containsKey.

Prototype

public synchronized boolean containsKey(Object key) 

Source Link

Document

Tests if the specified object is a key in this hashtable.

Usage

From source file:org.gridchem.client.gui.charts.UsageChart.java

/**
 * Returns a dataset representing the consumption of this project's
 * allocation by each collaborator including the current user.
 * /* www. jav a 2 s  .  com*/
 * @param project
 * @return
 */
private DefaultPieDataset createUserDataset(Hashtable<ProjectBean, List<CollaboratorBean>> projectCollabTable) {

    DefaultPieDataset pds = new DefaultPieDataset();

    Hashtable<String, Double> userUsageTable = new Hashtable<String, Double>();

    for (ProjectBean project : projectCollabTable.keySet()) {
        List<CollaboratorBean> collabs = projectCollabTable.get(project);

        for (CollaboratorBean collab : collabs) {
            String key = collab.getFirstName() + " " + collab.getLastName();
            if (userUsageTable.containsKey(key)) {
                double oldVal = userUsageTable.get(key).doubleValue();
                userUsageTable.remove(key);
                userUsageTable.put(key, new Double(oldVal + collab.getTotalUsage().getUsed()));
            } else {
                userUsageTable.put(key, new Double(collab.getTotalUsage().getUsed()));
            }
        }
    }

    // now put the tallies in the dataset
    for (String key : userUsageTable.keySet()) {
        pds.setValue(key, userUsageTable.get(key).doubleValue());
    }

    return pds;
}

From source file:com.alfaariss.oa.authentication.remote.aselect.logout.LogoutManager.java

private Hashtable<String, String> convertCGI(String sMessage) throws OAException {
    Hashtable<String, String> htResult = new Hashtable<String, String>();
    try {/* w ww  .  j  av  a  2s . co  m*/
        if (sMessage.trim().length() == 0)
            return htResult;

        String[] saMessage = sMessage.split("&");
        for (int i = 0; i < saMessage.length; i++) {
            String sPart = saMessage[i];
            int iIndex = sPart.indexOf('=');
            String sKey = sPart.substring(0, iIndex);
            sKey = sKey.trim();
            String sValue = sPart.substring(iIndex + 1);
            sValue = URLDecoder.decode(sValue.trim(), CHARSET);

            if (htResult.containsKey(sKey)) {
                _logger.error("Key is not unique in message: " + sKey);
                throw new OAException(SystemErrors.ERROR_INTERNAL);
            }

            htResult.put(sKey, sValue);
        }
    } catch (OAException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Internal error during conversion of message: " + sMessage, e);
        throw new OAException(SystemErrors.ERROR_INTERNAL);
    }
    return htResult;
}

From source file:com.alfaariss.oa.profile.aselect.logout.LogoutManager.java

private Hashtable<String, String> convertCGI(String sMessage) throws OAException {
    Hashtable<String, String> htResult = new Hashtable<String, String>();
    try {/*  w w  w  .  j  ava2 s.c  o m*/
        if (sMessage.trim().length() == 0)
            return htResult;

        String[] saMessage = sMessage.split("&");
        for (int i = 0; i < saMessage.length; i++) {
            String sPart = saMessage[i];
            int iIndex = sPart.indexOf('=');
            String sKey = sPart.substring(0, iIndex);
            sKey = sKey.trim();
            String sValue = sPart.substring(iIndex + 1);
            sValue = URLDecoder.decode(sValue.trim(), ASelectProcessor.CHARSET);

            if (htResult.containsKey(sKey)) {
                _logger.error("Key is not unique in message: " + sKey);
                throw new OAException(SystemErrors.ERROR_INTERNAL);
            }

            htResult.put(sKey, sValue);
        }
    } catch (OAException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Internal error during conversion of message: " + sMessage, e);
        throw new OAException(SystemErrors.ERROR_INTERNAL);
    }
    return htResult;
}

From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

JFreeChart labChartRef(String demographicNo, String typeIdName, String typeIdName2, String patientName,
        String chartTitle) {//from   w  w  w  .  j  a v  a  2  s . c  o m
    org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection();
    ArrayList<EctMeasurementsDataBean> list = getList(demographicNo, typeIdName);
    String typeYAxisName = "";
    ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>();
    if (typeIdName.equals("BP")) {
        log.debug("Using BP LOGIC FOR type 1 ");
        EctMeasurementsDataBean sampleLine = list.get(0);
        typeYAxisName = sampleLine.getTypeDescription();
        TimeSeries systolic = new TimeSeries("Systolic", Day.class);
        TimeSeries diastolic = new TimeSeries("Diastolic", Day.class);
        for (EctMeasurementsDataBean mdb : list) { // dataVector) {
            String[] str = mdb.getDataField().split("/");

            systolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[0]));
            diastolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[1]));
        }
        dataset.addSeries(diastolic);
        dataset.addSeries(systolic);
    } else {
        log.debug("Not Using BP LOGIC FOR type 1 ");
        // get the name from the TimeSeries
        EctMeasurementsDataBean sampleLine = list.get(0);
        String typeLegendName = sampleLine.getTypeDisplayName();
        typeYAxisName = sampleLine.getTypeDescription(); // this should be the type of measurement
        TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class);
        for (EctMeasurementsDataBean mdb : list) { //dataVector) {
            newSeries.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(mdb.getDataField()));
            try {
                Hashtable h = getMeasurementsExt(mdb.getId());
                if (h != null && h.containsKey("minimum")) {
                    String min = (String) h.get("minimum");
                    String max = (String) h.get("maximum");
                    double open = Double.parseDouble(min.trim());
                    double high = Double.parseDouble(max.trim());
                    double low = Double.parseDouble(min.trim());
                    double close = Double.parseDouble(max.trim());
                    double volume = 1045;
                    dataItems
                            .add(new OHLCDataItem(mdb.getDateObservedAsDate(), open, high, low, close, volume));
                }
            } catch (Exception et) {
                MiscUtils.getLogger().error("Error", et);
            }
        }
        dataset.addSeries(newSeries);
    }

    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", typeYAxisName, dataset, true,
            true, true);

    XYPlot plot = chart.getXYPlot();
    plot.getDomainAxis().setAutoRange(true);

    log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin()
            + " eee " + plot.getDomainAxis().getLowerMargin());
    plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin() * 6);
    plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin() * 6);
    plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 1.7);

    plot.getDomainAxis().setUpperMargin(0.9);
    plot.getDomainAxis().setLowerMargin(0.9);
    plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4);

    ValueAxis va = plot.getRangeAxis();
    va.setAutoRange(true);
    XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance()
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}",
            new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00"));
    renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator);

    renderer.setBaseItemLabelsVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainCrosshairPaint(Color.GRAY);

    if (renderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer;
        rend.setBaseShapesVisible(true);
        rend.setBaseShapesFilled(true);
    }

    plot.setRenderer(renderer);

    if (dataItems != null && dataItems.size() > 0) {
        OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]);
        XYDataset referenceRangeDataset = new DefaultOHLCDataset("Reference Range", ohlc);
        plot.setRenderer(1, setAxisAndDataSet(1, plot, plot.getRangeAxis(), referenceRangeDataset, Color.GREEN,
                new HighLowRenderer()));
    }

    /////

    return chart;
}

From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

JFreeChart referenceRangeChart(String demographicNo, String typeIdName, String typeIdName2, String patientName,
        String chartTitle) {/*  ww  w. j  a v a  2s.  c  o m*/
    org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection();

    ArrayList<EctMeasurementsDataBean> list = getList(demographicNo, typeIdName);
    ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>();
    String typeYAxisName = "";

    if (typeIdName.equals("BP")) {
        log.debug("Using BP LOGIC FOR type 1 ");
        EctMeasurementsDataBean sampleLine = list.get(0);
        typeYAxisName = sampleLine.getTypeDescription();
        TimeSeries systolic = new TimeSeries("Systolic", Day.class);
        TimeSeries diastolic = new TimeSeries("Diastolic", Day.class);
        for (EctMeasurementsDataBean mdb : list) { // dataVector) {
            String[] str = mdb.getDataField().split("/");

            systolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[0]));
            diastolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[1]));
        }
        dataset.addSeries(diastolic);
        dataset.addSeries(systolic);

    } else {
        log.debug("Not Using BP LOGIC FOR type 1 ");
        // get the name from the TimeSeries
        EctMeasurementsDataBean sampleLine = list.get(0);
        String typeLegendName = sampleLine.getTypeDisplayName();
        typeYAxisName = sampleLine.getTypeDescription(); // this should be the type of measurement
        TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class);
        for (EctMeasurementsDataBean mdb : list) { //dataVector) {
            newSeries.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(mdb.getDataField()));

            try {
                Hashtable h = getMeasurementsExt(mdb.getId());
                if (h != null && h.containsKey("minimum")) {
                    String min = (String) h.get("minimum");
                    String max = (String) h.get("maximum");
                    double open = Double.parseDouble(min.trim());
                    double high = Double.parseDouble(max.trim());
                    double low = Double.parseDouble(min.trim());
                    double close = Double.parseDouble(max.trim());
                    double volume = 1045;
                    dataItems
                            .add(new OHLCDataItem(mdb.getDateObservedAsDate(), open, high, low, close, volume));
                }
            } catch (Exception et) {
                MiscUtils.getLogger().error("Error", et);
            }

        }
        dataset.addSeries(newSeries);
    }

    OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]);
    JFreeChart chart = ChartFactory.createHighLowChart("HighLowChartDemo2", "Time", "Value",
            new DefaultOHLCDataset("DREFERENCE RANGE", ohlc), true);
    XYPlot plot = (XYPlot) chart.getPlot();

    //        HighLowRenderer renderer = (HighLowRenderer) plot.getRenderer();
    //        renderer.
    //        renderer.setOpenTickPaint(Color.green);
    //        renderer.setCloseTickPaint(Color.black);

    plot.setDataset(1, dataset);

    plot.getDomainAxis().setAutoRange(true);

    log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin()
            + " eee " + plot.getDomainAxis().getLowerMargin());
    //plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin()*6);
    //plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin()*6);
    // plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin()*1.7);

    plot.getDomainAxis().setUpperMargin(0.9);
    plot.getDomainAxis().setLowerMargin(0.9);
    plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4);

    ValueAxis va = plot.getRangeAxis();
    va.setAutoRange(true);
    XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance()
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}",
            new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00"));
    renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator);

    renderer.setBaseItemLabelsVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainCrosshairPaint(Color.GRAY);

    if (renderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer;
        rend.setBaseShapesVisible(true);
        rend.setBaseShapesFilled(true);
    }

    plot.setRenderer(renderer);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:com.autentia.intra.bean.account.AccountEntryBean.java

private void calcTotals(List<AccountEntry> res) {
    costs = new BigDecimal(0);
    incomes = new BigDecimal(0);

    costsType = new BigDecimal(0);
    incomesType = new BigDecimal(0);

    Hashtable mapaCajaTotales = new Hashtable();

    for (AccountEntry elem : res) {
        Integer accountAct = elem.getAccount().getId();
        BigDecimal accountValueAct = null;
        if (!mapaCajaTotales.containsKey(accountAct)) {
            mapaCajaTotales.put(accountAct, new BigDecimal(0));
        }/*ww w .  j  av  a 2s  .  c  o  m*/

        accountValueAct = (BigDecimal) mapaCajaTotales.get(accountAct);

        BigDecimal actual = elem.getAmount();
        BigDecimal resul = accountValueAct.add(actual);
        elem.setAmountAccountNow(resul);
        mapaCajaTotales.remove(accountAct);
        mapaCajaTotales.put(accountAct, resul);

        if (actual.signum() >= 0) {
            setIncomes(incomes.add(actual));
        } else {
            setCosts(costs.add(actual));
        }

        if (elem.getType().getGroup().getId() == ConfigurationUtil.getDefault().getCostId()) {
            setCostsType(costsType.add(actual));
        } else {
            setIncomesType(incomesType.add(actual));
        }
    }

    setTotal(incomes.add(costs));
    setTotalType(incomesType.add(costsType));
}

From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAX2Mapper.java

private SaltExtendedMarkable getSContainerMarkable(Object sElem, String schemeName, String span, String sName,
        String sId, String containedId, String containedScheme) {
    if (!this.sContainerMarkables.containsKey(sElem)) {
        this.sContainerMarkables.put(sElem, new Hashtable<Scheme, SaltExtendedMarkableContainer>());
    }/*from  www  .j a  va 2 s  . c  o m*/
    Hashtable<Scheme, SaltExtendedMarkableContainer> associatedMarkables = this.sContainerMarkables.get(sElem);

    SaltExtendedMarkableContainer containerMarkable = null;
    Scheme associatedScheme = getScheme(schemeName);
    if (!associatedMarkables.containsKey(associatedScheme)) {
        SaltExtendedMarkableFactory markableFactory = this.document.getFactory()
                .getMarkableFactory(associatedScheme);
        if (markableFactory == null) {
            markableFactory = new SaltExtendedMarkableFactory(associatedScheme, this.documentBuilder);
            this.document.getFactory().addMarkableFactory(markableFactory);
        }
        containerMarkable = markableFactory.newMarkableContainer(getNewId(), span,
                new ArrayList<MarkableAttribute>(), SaltExtendedMmax2Infos.SALT_INFO_TYPE_SCONTAINER, sName,
                sId, containedId, containedScheme);
        associatedMarkables.put(associatedScheme, containerMarkable);
        document.addMarkable(containerMarkable);
    } else {
        containerMarkable = associatedMarkables.get(associatedScheme);
    }

    return containerMarkable;
}

From source file:com.autentia.tnt.manager.billing.BillManager.java

public List<BillBreakDown> getAllBitacoreBreakDowns(Date start, Date end, Project project) {

    final List<BillBreakDown> desgloses = new ArrayList<BillBreakDown>();

    ActivityDAO activityDAO = ActivityDAO.getDefault();
    ActivitySearch actSearch = new ActivitySearch();
    actSearch.setBillable(new Boolean(true));
    actSearch.setStartStartDate(start);/*from   ww w  . j av  a  2 s .  c o m*/
    actSearch.setEndStartDate(end);

    List<Activity> actividadesTotal = new ArrayList<Activity>();
    Hashtable user_roles = new Hashtable();

    ProjectRoleDAO projectRoleDAO = ProjectRoleDAO.getDefault();
    ProjectRoleSearch prjRolSearch = new ProjectRoleSearch();
    prjRolSearch.setProject(project);
    List<ProjectRole> roles = projectRoleDAO.search(prjRolSearch, new SortCriteria("id", false));
    for (ProjectRole proyRole : roles) {
        actSearch.setRole(proyRole);
        List<Activity> actividades = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        actividadesTotal.addAll(actividades);
    }

    for (Activity act : actividadesTotal) {
        String key = act.getRole().getId().toString() + act.getUser().getId().toString();

        if (!user_roles.containsKey(key)) {
            Hashtable value = new Hashtable();
            value.put("ROLE", act.getRole());
            value.put("USER", act.getUser());
            user_roles.put(key, value);
        }
    }

    Enumeration en = user_roles.keys();

    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        Hashtable pair = (Hashtable) user_roles.get(key);
        actSearch.setBillable(new Boolean(true));
        actSearch.setStartStartDate(start);
        actSearch.setEndStartDate(end);

        ProjectRole pR = (ProjectRole) pair.get("ROLE");
        User u = (User) pair.get("USER");
        actSearch.setRole(pR);
        actSearch.setUser(u);
        List<Activity> actividadesUsuarioRol = activityDAO.search(actSearch,
                new SortCriteria("startDate", false));

        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Imputaciones (usuario - rol): " + u.getName() + " - " + pR.getName());
        brd.setAmount(pR.getCostPerHour());

        IvaApplicator.applyIvaToTaxableObject(start, brd);

        BigDecimal unitsTotal = new BigDecimal(0);
        for (Activity act : actividadesUsuarioRol) {
            BigDecimal unitsActual = new BigDecimal(act.getDuration());
            unitsActual = unitsActual.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
            unitsTotal = unitsTotal.add(unitsActual);
        }
        brd.setUnits(unitsTotal);
        brd.setSelected(true);
        desgloses.add(brd);
    }

    ProjectCostDAO prjCostDAO = ProjectCostDAO.getDefault();
    ProjectCostSearch prjCostSearch = new ProjectCostSearch();
    prjCostSearch.setProject(project);
    List<ProjectCost> costes = prjCostDAO.search(prjCostSearch, new SortCriteria("id", false));
    for (ProjectCost proyCost : costes) {
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Coste: " + proyCost.getName());
        brd.setUnits(new BigDecimal(1));
        brd.setAmount(proyCost.getCost());

        IvaApplicator.applyIvaToTaxableObject(start, brd);

        brd.setSelected(true);
        desgloses.add(brd);
    }

    return desgloses;

}

From source file:edu.stanford.cfuller.imageanalysistools.filter.ConvexHullByLabelFilter.java

/**
 * Applies the convex hull filter to the supplied mask.
 * @param im    The Image to process-- a mask whose regions will be replaced by their filled convex hulls.
 */// www.  j a  v  a2 s. c  o  m
@Override
public void apply(WritableImage im) {

    RelabelFilter RLF = new RelabelFilter();

    RLF.apply(im);

    Histogram h = new Histogram(im);

    java.util.Hashtable<Integer, java.util.Vector<Integer>> xLists = new java.util.Hashtable<Integer, java.util.Vector<Integer>>();
    java.util.Hashtable<Integer, java.util.Vector<Integer>> yLists = new java.util.Hashtable<Integer, java.util.Vector<Integer>>();

    java.util.Vector<Integer> minValues = new java.util.Vector<Integer>(h.getMaxValue() + 1);
    java.util.Vector<Integer> minIndices = new java.util.Vector<Integer>(h.getMaxValue() + 1);

    for (int i = 0; i < h.getMaxValue() + 1; i++) {
        minValues.add(im.getDimensionSizes().get(ImageCoordinate.X));
        minIndices.add(0);
    }

    for (ImageCoordinate i : im) {

        int value = (int) im.getValue(i);

        if (value == 0)
            continue;

        if (!xLists.containsKey(value)) {
            xLists.put(value, new java.util.Vector<Integer>());
            yLists.put(value, new java.util.Vector<Integer>());
        }

        xLists.get(value).add(i.get(ImageCoordinate.X));
        yLists.get(value).add(i.get(ImageCoordinate.Y));

        if (i.get(ImageCoordinate.X) < minValues.get(value)) {
            minValues.set(value, i.get(ImageCoordinate.X));
            minIndices.set(value, xLists.get(value).size() - 1);
        }

    }

    java.util.Vector<Integer> hullPointsX = new java.util.Vector<Integer>();
    java.util.Vector<Integer> hullPointsY = new java.util.Vector<Integer>();

    ImageCoordinate ic = ImageCoordinate.createCoordXYZCT(0, 0, 0, 0, 0);

    for (int k = 1; k < h.getMaxValue() + 1; k++) {
        hullPointsX.clear();
        hullPointsY.clear();

        java.util.Vector<Integer> xList = xLists.get(k);
        java.util.Vector<Integer> yList = yLists.get(k);

        int minIndex = (int) minIndices.get(k);

        //start at the leftmost point

        int currentIndex = minIndex;
        int currentX = xList.get(currentIndex);
        int currentY = yList.get(currentIndex);

        hullPointsX.add(currentX);
        hullPointsY.add(currentY);

        org.apache.commons.math3.linear.RealVector angles = new org.apache.commons.math3.linear.ArrayRealVector(
                xList.size());

        Vector3D currentVector = new Vector3D(0, -1, 0);

        java.util.HashSet<Integer> visited = new java.util.HashSet<Integer>();

        do {

            visited.add(currentIndex);

            int maxIndex = 0;
            double maxAngle = -2 * Math.PI;
            double dist = Double.MAX_VALUE;
            for (int i = 0; i < xList.size(); i++) {
                if (i == currentIndex)
                    continue;
                Vector3D next = new Vector3D(xList.get(i) - xList.get(currentIndex),
                        yList.get(i) - yList.get(currentIndex), 0);

                double angle = Vector3D.angle(currentVector, next);
                angles.setEntry(i, angle);
                if (angle > maxAngle) {
                    maxAngle = angle;
                    maxIndex = i;
                    dist = next.getNorm();
                } else if (angle == maxAngle) {
                    double tempDist = next.getNorm();
                    if (tempDist < dist) {
                        dist = tempDist;
                        maxAngle = angle;
                        maxIndex = i;
                    }
                }
            }

            currentX = xList.get(maxIndex);
            currentY = yList.get(maxIndex);

            currentVector = new Vector3D(xList.get(currentIndex) - currentX, yList.get(currentIndex) - currentY,
                    0);

            hullPointsX.add(currentX);
            hullPointsY.add(currentY);

            currentIndex = maxIndex;

        } while (!visited.contains(currentIndex));

        //hull vertices have now been determined .. need to fill in the lines
        //between them so I can apply a fill filter

        //approach: x1, y1 to x0, y0:
        //start at min x, min y, go to max x, max y
        // if x_i, y_i = x0, y0  + slope to within 0.5 * sqrt(2), then add to hull

        double eps = Math.sqrt(2);

        for (int i = 0; i < hullPointsX.size() - 1; i++) {

            int x0 = hullPointsX.get(i);
            int y0 = hullPointsY.get(i);

            int x1 = hullPointsX.get(i + 1);
            int y1 = hullPointsY.get(i + 1);

            int xmin = (x0 < x1) ? x0 : x1;
            int ymin = (y0 < y1) ? y0 : y1;
            int xmax = (x0 > x1) ? x0 : x1;
            int ymax = (y0 > y1) ? y0 : y1;

            x1 -= x0;
            y1 -= y0;

            double denom = (x1 * x1 + y1 * y1);

            for (int x = xmin; x <= xmax; x++) {
                for (int y = ymin; y <= ymax; y++) {

                    int rel_x = x - x0;
                    int rel_y = y - y0;

                    double projLength = (x1 * rel_x + y1 * rel_y) / denom;

                    double projPoint_x = x1 * projLength;
                    double projPoint_y = y1 * projLength;

                    if (Math.hypot(rel_x - projPoint_x, rel_y - projPoint_y) < eps) {
                        ic.set(ImageCoordinate.X, x);
                        ic.set(ImageCoordinate.Y, y);
                        im.setValue(ic, k);
                    }

                }
            }

        }

    }

    ic.recycle();

    FillFilter ff = new FillFilter();

    ff.apply(im);

}

From source file:org.hdiv.filter.AbstractValidatorHelper.java

/**
 * Checks if repeated values have been received for the parameter
 * <code>parameter</code>./*  w ww.  j  a  va2s . co  m*/
 * 
 * @param target Part of the url that represents the target action
 * @param parameter parameter name
 * @param values Parameter <code>parameter</code> values
 * @param size number of values received for <code>parameter</code>
 * @return True If repeated values have been received for the parameter
 *         <code>parameter</code>.
 */
private boolean hasConfidentialIncorrectValues(String target, String parameter, String[] values, int size) {

    Hashtable receivedValues = new Hashtable();

    for (int i = 0; i < values.length; i++) {

        if (!this.isInRange(target, parameter, values[i], size)) {
            return true;
        }

        if (receivedValues.containsKey(values[i])) {
            this.logger.log(HDIVErrorCodes.REPEATED_VALUES, target, parameter, values[i]);
            return true;
        }

        receivedValues.put(values[i], values[i]);
    }
    return false;
}