Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

In this page you can find the example usage for java.util ArrayList get.

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

public static String getTabsStringFromList(final ArrayList<String> tabs) {
    final StringBuilder resultTabs;

    if (tabs == null || tabs.isEmpty()) {
        resultTabs = new StringBuilder("");
    } else {/*from   w w w .j a v a2  s.co m*/
        resultTabs = new StringBuilder(tabs.size() * 10);
        resultTabs.append(tabs.get(0));
        for (int i = 1; i < tabs.size(); i++) {
            resultTabs.append(LIBRARY_TABS_DELIMITER);
            resultTabs.append(tabs.get(i));
        }
    }

    return resultTabs.toString();
}

From source file:Main.java

public static String joinStrings(String connector, ArrayList<String> strings, StringBuilder recycle) {
    if (strings.size() <= 0) {
        return "";
    }//from   w ww. java2  s . c  o  m
    if (recycle == null) {
        recycle = new StringBuilder();
    } else {
        recycle.setLength(0);
    }
    recycle.append(strings.get(0));
    for (int i = 1; i < strings.size(); i++) {
        recycle.append(connector);
        recycle.append(strings.get(i));
    }
    return recycle.toString();
}

From source file:graphic.Grafico.java

private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico,
        float transparencia, String tipo) {
    DefaultPieDataset data = new DefaultPieDataset();

    for (int i = 0; i < nome.toArray().length; i++) {
        data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString()));
    }//from   ww w  .  ja  v a  2  s  . c o m

    JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true);

    java.awt.Color cor = new java.awt.Color(200, 200, 200);
    chart.setBackgroundPaint(cor);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setLabelLinksVisible(true);
    plot.setNoDataMessage("No existem dados para serem exibidos no grfico");

    plot.setStartAngle(90);
    plot.setDirection(Rotation.CLOCKWISE);

    plot.setForegroundAlpha(transparencia);
    plot.setInteriorGap(0.20);

    ChartPanel chartPanel = new ChartPanel(chart);

    return chartPanel;
}

From source file:Main.java

/**
 * creates a string from an arraylist/*from   w  w w  .j a  va 2  s. c  o m*/
 * 
 * @param alValues the values to be concatenated
 * @param strSeparator the separator between one element and the other
 * @return the string with the values seaparated by the strSeparator
 */
public static String[] getStringArrayFromArrayList(ArrayList<String> alValues) {

    // inits the buffer
    String[] strValues = new String[alValues.size()];

    // cycles on the values of the AL
    for (int j = 0; j < alValues.size(); j++) {

        // appends the j-th vlaur to the buffer
        strValues[j] = alValues.get(j);
    }

    // and returns it
    return strValues;
}

From source file:com.espe.distribuidas.pmaldito.servidorbdd.operaciones.Archivo.java

/**
 * Permite enviar la nueva lista de registros
 *
 * @param campos/* w w w  .  j  a  va2s . co  m*/
 * @param archivo
 */
public static void insetarCampos(ArrayList<String> campos, File archivo) {
    for (int i = 0; i < campos.size(); i++) {
        insertar(campos.get(i), archivo);
    }
}

From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java

public static void ld_pth_pnts(ArrayList<Integer[]> pnts, Path path) {

    int pnt_nmbr = pnts.size();
    Integer[] crt_pnt = pnts.get(0);
    path.moveTo(crt_pnt[0], crt_pnt[1]);

    // Loop through the points of a path
    for (int pnt_mbr = 1; pnt_mbr < pnt_nmbr; pnt_mbr += 1) {

        crt_pnt = pnts.get(pnt_mbr);//www.ja v a  2s  . c  o m
        path.lineTo(crt_pnt[0], crt_pnt[1]);
    }
}

From source file:imperial.modaclouds.monitoring.sda.weka.CreateArff.java

public static double[] convertDoubles(ArrayList<String> strings) {
    double[] ret = new double[strings.size()];
    for (int i = 0; i < strings.size(); i++) {
        ret[i] = Double.valueOf(strings.get(i));
    }/*from w ww  .jav a  2 s . co  m*/
    return ret;
}

From source file:Main.java

public static ArrayList<Integer> shuffleArray(int size) {
    ArrayList<Integer> shuffled = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        shuffled.add(i);// w  w  w  .  ja v  a2  s  .c o  m
    }

    Random rnd = new Random();
    for (int i = size - 1; i > 0; i--) {
        int index = rnd.nextInt(i + 1);
        // Simple swap
        int a = shuffled.get(index);
        shuffled.set(index, shuffled.get(i));
        shuffled.set(i, a);
    }

    return shuffled;
}

From source file:biblioteca.reportes.ChartCreator.java

public static DefaultPieDataset asignarPieDataset(ArrayList<String> Valores) {
    DefaultPieDataset dataSet = new DefaultPieDataset();
    int size = Valores.size();
    size = (size <= 32) ? size : 32;// w  ww  . j a  va2s.  c om
    for (int i = 2; i < size; i += 2) {
        dataSet.setValue(Valores.get(i), Double.parseDouble(Valores.get(i + 1)));
    }
    return dataSet;
}

From source file:com.shmsoft.dmass.print.Html2Pdf.java

/**
 * Bad rendering, perhaps used only for Windows
 *///from w ww.ja v  a 2  s  . co  m
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void convertHtml2Pdf(Reader htmlReader, String outputFile) throws Exception {
    Document pdfDocument = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(pdfDocument, baos);
    pdfDocument.open();
    StyleSheet styles = new StyleSheet();
    styles.loadTagStyle("body", "font", "Times New Roman");

    ImageProvider imageProvider = new ImageProvider() {

        @Override
        public Image getImage(String src, HashMap arg1, ChainedProperties arg2, DocListener arg3) {

            try {
                Image image = Image.getInstance(IOUtils.toByteArray(
                        getClass().getClassLoader().getResourceAsStream(ParameterProcessing.NO_IMAGE_FILE)));
                return image;
            } catch (Exception e) {
                System.out.println("Problem with html->pdf imaging, image provider fault");
            }

            return null;
        }

    };

    HashMap interfaceProps = new HashMap();
    interfaceProps.put("img_provider", imageProvider);

    ArrayList arrayElementList = HTMLWorker.parseToList(htmlReader, styles, interfaceProps);
    for (int i = 0; i < arrayElementList.size(); ++i) {
        Element e = (Element) arrayElementList.get(i);
        pdfDocument.add(e);
    }
    pdfDocument.close();
    byte[] bs = baos.toByteArray();
    File pdfFile = new File(outputFile);
    FileOutputStream out = new FileOutputStream(pdfFile);
    out.write(bs);
    out.close();
}