Problem in iterating through huge number of entries ... memory issue

I am having large number of entries in lacs.
I need to check each entry with previous ones , so I need to iterate through the each and every entry previous to current entry.
Here I have put all the entries in arraylist and I am iterating though this arraylist and validating current entry.
As I am using the arraylist for storing all the entries , the system is taking lot of memory because I am putting all in the memory.
Is there anyway to resolve this memory issue?

If you have a hundred thousand entries, to verify all the entries you would need to compare the later entries with the earlier ones such that:
Entry 1 = 100,000 accesses
Entry 2 = 99,999 accesses
Entry 5 = 99,995 accesses
Entry 10 = 99,990 accesses
Entry 99,990 = 10 accesses
Entry 99,995 = 5 accesses
Entry 99,999 = 1 access (only to be compared with the 100,000th entry)
It would then make sense to keep a certain (fixed) amount of entries in memory, those which get accessed the most, then write to file those which get accessed the least frequently. Have a method that can decide, based on the index of the entry, whether to get it from the ArrayList or to read it from the file. That will give you good performance.
BufferedReader would be a good candidate to read the file, because it can skip more bytes at once should you need a line very late in the file. Also consider using RandomAccessFile and seek(entryNumber * ENTRY_SIZE) if your data can be represented with a fixed size in bytes.
s
Edited by Looce at 2009-03-25 20:33:11 GMT [Added BufferedReader advice]

Similar Messages

  • How to find out Number of entries in a Huge Table?

    Hi,
    I would like to know Number of entries in table DFKKOP. when i try to get it through se16, it takes more than 10 minutes in dialogue process so a time out occurs. is there any way to find out number of entries in the table Apart from creating a program for that?
    Please guide me to the solution.
    Thanks,
    Lijo Joseph
    Message was edited by: Lijo Joseph Vazhappilly

    REPORT  YCHATEST                                .
    Data : begin of itab occurs 0.
            include structure tab512.
    data:end of itab.
    data : v_count like sy-index,
           tabname like X030L-TABNAME value 'DFKKOP'.
    CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'
      EXPORTING
        table_name              = tabname
    IMPORTING
       NUMBER_OF_ENTRIES       = v_count
    tables
       entries                 = itab.
    write : v_count.
    Message was edited by: Sekhar

  • Page number instead of number of entries

    Hello
    I have a requirement for changing the number of entries in KM to page numbers.
    So I need to change:
    1-10 11-20 21-24
    to
    1 2 3
    I found a thread on sdn about this requirement, but there wasn't much information. It just said to write your own Collection Renderer.
    I was able to add something between the breadcrumb (showing the map you are on the moment) and page numbers. So I still don't know where the 'page numbers' are added?
    Is there anyone with experience? Or ideas?
    Thanks!
    Christof
    The decompiled Collection Renderer:
    package be.kindengezin.wcm.rendering.collection.cm;
    // FrontEnd Plus GUI for JAD
    // DeCompiled : CollectionListRenderer.class
    import com.sap.tc.logging.Location;
    import com.sap.tc.logging.LogController;
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.CellHAlign;
    import com.sapportals.htmlb.enum.CellVAlign;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.wcm.WcmException;
    import com.sapportals.wcm.control.util.EmptyComponent;
    import com.sapportals.wcm.control.util.FolderSettings;
    import com.sapportals.wcm.control.util.property.*;
    import com.sapportals.wcm.rendering.base.*;
    import com.sapportals.wcm.rendering.collection.LightCollectionRenderer;
    //import com.sapportals.wcm.rendering.collection.cm.PropertyColumnRenderer;
    //import com.sapportals.wcm.rendering.collection.cm.PropertyHeaderRenderer;
    import com.sapportals.wcm.rendering.readymades.EmptyCollectionInfo;
    import com.sapportals.wcm.rendering.resource.IResourceRenderer;
    import com.sapportals.wcm.rendering.util.HtmlRendererUtil;
    import com.sapportals.wcm.repository.*;
    import com.sapportals.wcm.repository.service.IRepositoryServiceFactory;
    import com.sapportals.wcm.repository.service.layout.IDebugContainer;
    import com.sapportals.wcm.repository.service.layout.customizing.*;
    import com.sapportals.wcm.service.propertyconfig.*;
    import com.sapportals.wcm.util.logging.LoggingFormatter;
    import com.sapportals.wcm.util.profiler.IProfiler;
    import com.sapportals.wcm.util.profiler.Profiler;
    import com.sapportals.wdf.WdfException;
    import java.util.*;
    import to.work.PropertyColumnRenderer;
    import to.work.PropertyHeaderRenderer;
    // Referenced classes of package com.sapportals.wcm.rendering.collection.cm:
    //                 PropertyHeaderRenderer, PropertyColumnRenderer
    public class CollectionListRenderer extends LightCollectionRenderer
         protected class HeaderItem
              private int rowSpan;
              private int colSpan;
              private IMetaName labelMetaName;
              private IPropertyColumn column;
              private boolean processed;
              public void setRowSpan(int row)
                   rowSpan = row;
              public int getRowSpan()
                   return rowSpan;
              public void setColSpan(int col)
                   colSpan = col;
              public int getColSpan()
                   return colSpan;
              public void setLabelMetaName(IMetaName column)
                   labelMetaName = column;
              public IMetaName getLabelMetaName()
                   return labelMetaName;
              public void setPropertyColumn(IPropertyColumn column)
                   this.column = column;
              public IPropertyColumn getPropertyColumn()
                   return column;
              public String toString()
                   return "Item:  RowSpan=" + rowSpan + "; ColSpan=" + colSpan + "; PropertyColumn=" + getLabelMetaName();
              public HeaderItem()
                   rowSpan = 0;
                   colSpan = 0;
                   labelMetaName = null;
                   column = null;
                   processed = false;
              public HeaderItem(int rowSpan, int colSpan, IMetaName metaName, IPropertyColumn column)
                   this.rowSpan = 0;
                   this.colSpan = 0;
                   labelMetaName = null;
                   this.column = null;
                   processed = false;
                   this.rowSpan = rowSpan;
                   this.colSpan = colSpan;
                   labelMetaName = metaName;
                   this.column = column;
         private static final String PROFILER_PATH_UI_RENDER = "/KM/FLEXUI/RENDER/UI";
         private static final String PROFILER_PATH_UI_RENDER_ROW = "/KM/FLEXUI/RENDER/UI/ROW ";
         private static final String PROFILER_PATH_UI_RENDER_GETPROPS = "/KM/FLEXUI/RENDER/UI/GETPROPS";
         private static IProfiler s_profiler = Profiler.getInstance();
         private static Location log;
         private static int PAGER_LINKS_DEFAULT = 5;
         private static final CellVAlign VERTICAL_ALIGN;
         private int MaxNumberOfRows;
         private int noOfColumns;
         private static IPropertyName DEFAULT_PROP_NAMES[];
         private IPropertyPosition propertiesPositions[];
         private static final String NEXT_LINE_START_COLUMN = "col";
         private static final String NEXT_LINE_METANAME = "metaName";
         private static final String NEXT_LINE_METANAME_MODIFIERS = "metaNameModifiers";
         private boolean debug;
         private boolean isManualOrdered;
         public CollectionListRenderer()
              MaxNumberOfRows = 10;
              noOfColumns = 0;
              debug = false;
              isManualOrdered = false;
              initParameterSettings();
              set508enabled(true);
         private void initParameterSettings()
              IParameterName supportedParameters[] = {
                   ICollectionRendererParameterNameConst.BREADCRUMBSTYLE, ICollectionRendererParameterNameConst.BREADCRUMBVISIBILITYSTYLE, ICollectionRendererParameterNameConst.SHOWFOLDERTITLE, ICollectionRendererParameterNameConst.SHOWFILESSTYLE, ICollectionRendererParameterNameConst.SORT_ENABLED, ICollectionRendererParameterNameConst.LINKSSTYLE, ICollectionRendererParameterNameConst.SHOWFOLDERSSTYLE, ICollectionRendererParameterNameConst.SHOW_HIDDEN, ICollectionRendererParameterNameConst.COLUMNS, IResourceRendererParameterNameConst.ICONSTYLE,
                   ICollectionRendererParameterNameConst.ROWS, ICollectionRendererParameterNameConst.ROWSPACING, ICollectionRendererParameterNameConst.COLUMNSPACING, ICollectionRendererParameterNameConst.MASSACTIONSTYLE, ICollectionRendererParameterNameConst.UI_GROUP_MASS, IResourceRendererParameterNameConst.ITEMACTIONSTYLE, ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, ICollectionRendererParameterNameConst.ROWBACKGROUNDSTYLE, ICollectionRendererParameterNameConst.PROPERTYCOLUMNS, ICollectionRendererParameterNameConst.BACKGROUNDIMAGEPATH,
                   ICollectionRendererParameterNameConst.BACKGROUNDIMAGESTYLE, ICollectionRendererParameterNameConst.SORT_PROPERTY, ICollectionRendererParameterNameConst.COMPONENTS, ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, ICollectionRendererParameterNameConst.SORT_ORDER, ICollectionRendererParameterNameConst.COLLECTION_ACTIONSTYLE, ICollectionRendererParameterNameConst.UI_GROUP_COLLECTION, ICollectionRendererParameterNameConst.RESOURCE_LIST_FILTER, ICollectionRendererParameterNameConst.RESIZEHEIGHTSTYLE, ICollectionRendererParameterNameConst.RESIZEWIDHTSTYLE,
                   ICollectionRendererParameterNameConst.FILTEREXTENSION, ICollectionRendererParameterNameConst.FILTERMIMETYPE, ICollectionRendererParameterNameConst.FILTERRESOURCETYPE, IResourceRendererParameterNameConst.UI_GROUP_RESOURCE, ICollectionRendererParameterNameConst.PAGER_LINK_COUNT, ICollectionRendererParameterNameConst.EMPTY_COLLECTION_FILE, ICollectionRendererParameterNameConst.EMPTY_COLLECTION_KEY, ICollectionRendererParameterNameConst.EMPTY_COLLECTION_STYLE
              setSupportedParameters(supportedParameters);
              IParameters parameters = getParameters();
              parameters.setParameter(ICollectionRendererParameterNameConst.BREADCRUMBSTYLE, "horizontal");
              parameters.setParameter(ICollectionRendererParameterNameConst.BREADCRUMBVISIBILITYSTYLE, "standard");
              parameters.setParameter(ICollectionRendererParameterNameConst.SHOWFILESSTYLE, "all");
              parameters.setParameter(ICollectionRendererParameterNameConst.LINKSSTYLE, "all");
              parameters.setParameter(ICollectionRendererParameterNameConst.SHOWFOLDERSSTYLE, "all");
              parameters.setParameter(ICollectionRendererParameterNameConst.MASSACTIONSTYLE, "off");
              parameters.setParameter(IResourceRendererParameterNameConst.ITEMACTIONSTYLE, "hover");
              parameters.setParameter(ICollectionRendererParameterNameConst.SHOWFOLDERTITLE, false);
              parameters.setParameter(ICollectionRendererParameterNameConst.GRIDORDERSTYLE, "columnmajor");
              parameters.setParameter(ICollectionRendererParameterNameConst.ROWS, MaxNumberOfRows);
              parameters.setParameter(ICollectionRendererParameterNameConst.ROWSPACING, 0);
              parameters.setParameter(ICollectionRendererParameterNameConst.SORT_ENABLED, true);
              parameters.setParameter(ICollectionRendererParameterNameConst.COLUMNSPACING, 0);
              parameters.setParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "off");
              parameters.setParameter(ICollectionRendererParameterNameConst.ROWBACKGROUNDSTYLE, "TRANSPARENT");
              parameters.setParameter(ICollectionRendererParameterNameConst.COLLECTION_ACTIONSTYLE, "hover");
              parameters.setParameter(ICollectionRendererParameterNameConst.PROPERTYCOLUMNS, "rnd:icon(noTitle/noColumnSpacing),rnd:displayname(contentLink)");
              parameters.setParameter(ICollectionRendererParameterNameConst.RESOURCE_LIST_FILTER, "default");
              parameters.setParameter(ICollectionRendererParameterNameConst.SHOW_HIDDEN, false);
              parameters.setParameter(ICollectionRendererParameterNameConst.RESIZEHEIGHTSTYLE, "compact");
              parameters.setParameter(ICollectionRendererParameterNameConst.RESIZEWIDHTSTYLE, "compact");
              parameters.setParameter(ICollectionRendererParameterNameConst.PAGER_LINK_COUNT, PAGER_LINKS_DEFAULT);
              parameters.setParameter(ICollectionRendererParameterNameConst.EMPTY_COLLECTION_STYLE, "off");
         public int renderListHeader(FormLayout grid, int row)
              throws WcmException
              if(isExactlyValue(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "off"))
                   return row;
              IPropertyPosition position = null;
              IPropertyColumn iterColumns[] = getColumnsList();
              boolean existsResource = getResourceList().size() != 0;
              String propertyHeaderColumnStyle = getParameters().getParameter(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "Table Title Color");
              String headerClassStyle = HtmlRendererUtil.getHeaderClassStyle(propertyHeaderColumnStyle);
              if(headerClassStyle == null)
                   headerClassStyle = "";
              FormLayoutCell cell = null;
              if(existsResource)
                   cell = grid.addComponent(row, 1, new HTMLFragment(""));
                   cell.setStyle(headerClassStyle);
              int rowSpan = 0;
              int columnSpan = 0;
              int line = 1;
              int lineNew = 0;
              int column = 1;
              if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                   column++;
              int startRow = row;
              boolean rowHasTitle = false;
              propertiesPositions = new IPropertyPosition[iterColumns.length];
              PropertyHeaderRenderer sortHeader = new PropertyHeaderRenderer(getProxy(), this, getBundleHandler(), getChildCountMetaName(getParentCollection()), isManualOrdered, getIRS().getSortDefintion(), getResourceContext().getLocale());
              IMetaName metaName = null;
              for(int i = 0; i < iterColumns.length && existsResource; i++)
                   if(iterColumns<i> != null)
                        rowSpan = 0;
                        columnSpan = 0;
                        position = PropertyColumnFactory.getInstance().getPosition(iterColumns<i>);
                        if(position != null)
                             lineNew = position.getRow();
                             if(line != lineNew)
                                  column = position.getColumn();
                                  if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                                       column++;
                                  line = lineNew;
                                  if(rowHasTitle)
                                       row++;
                                       rowHasTitle = false;
                             rowSpan = position.getSpanRow();
                             columnSpan = position.getSpanColumn();
                        propertiesPositions<i> = PropertyColumnFactory.getInstance().getPropertyPosition(row, rowSpan, column, columnSpan);
                        boolean is508Required = false;
                        try
                             is508Required = getProxy().getDynamicPage().getPageContext().requiresSection508Rendering();
                        catch(Exception ex)
                             log.errorT("Could not retrieve 508 mode for proxy <" + getProxy() + ">: " + LoggingFormatter.extractCallstack(ex));
                        metaName = PropertyHeaderRenderer.getMetaNameForTitle(iterColumns<i>, is508Required);
                        if(metaName != null)
                             rowHasTitle = true;
                        if(!getParameters().getParameter(ICollectionRendererParameterNameConst.SORT_ENABLED, true))
                             sortHeader.setSortEnabledParameter(false);
                        if(metaName != null)
                             if(columnSpan != 0)
                                  cell = grid.addComponent(row, 1, sortHeader.createSortLink(metaName));
                                  cell.setColspan(columnSpan);
                             } else
                                  cell = grid.addComponent(row, column, sortHeader.createSortLink(metaName));
                             String padding[] = HtmlRendererUtil.getPropertyPaddingValues(iterColumns<i>, metaName);
                             cell.setHorizontalAlignment(PropertyColumnFactory.getInstance().getHAlign(iterColumns<i>));
                             cell.setVerticalAlignment(PropertyColumnFactory.getInstance().getVAlign(iterColumns<i>));
                             if(padding != null)
                                  cell.setPaddingTop(padding[0]);
                                  cell.setPaddingRight(padding[1]);
                                  cell.setPaddingBottom(padding[2]);
                                  cell.setPaddingLeft(padding[3]);
                        column++;
                        if(columnSpan != 0)
                             column += columnSpan;
                        if(!iterColumns<i>.contains("noColumnSpacing") && column < noOfColumns)
                             cell = grid.addComponent(row, column, EmptyComponent.render());
                             if(!"0".equals(getColumnSpacing()))
                                  cell.setWidth(getColumnSpacing());
                             cell.setVerticalAlignment(VERTICAL_ALIGN);
                             column++;
              if(!rowHasTitle)
                   row--;
              setClassStyleForm(headerClassStyle, grid, startRow, row, noOfColumns);
              return ++row;
         public int renderListFooter(FormLayout grid, int row)
              throws WcmException
              boolean existsResource = getResourceList().size() != 0;
              if(!isExactlyValue(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "off"))
                   String propertyHeaderColumnStyle = getParameters().getParameter(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "Table Title Color");
                   String headerClassStyle = HtmlRendererUtil.getHeaderClassStyle(propertyHeaderColumnStyle);
                   if(headerClassStyle == null)
                        headerClassStyle = "";
                   FormLayoutCell cell = null;
              return row;
         public ILayoutObject getNewInstance()
              return initNewInstance(new CollectionListRenderer());
         private String getChildCountMetaName(IResource res)
              throws WcmException
              if(res == null)
                   return null;
              IResourceRenderer resourceRenderer = getRenderer(res);
              String par = resourceRenderer.getParameters().getParameter(IResourceRendererParameterNameConst.SHOWCHILDCOUNTSTYLE);
              if(par == null)
                   return null;
              String resultMetaNameID = null;
              if(par.equals("folders/files"))
                   resultMetaNameID = "rnd:childcount_both";
              else
              if(par.equals("sum"))
                   resultMetaNameID = "rnd:childcount_sum";
              else
              if(par.equals("only files"))
                   resultMetaNameID = "rnd:childcount_files";
              else
              if(par.equals("only folders"))
                   resultMetaNameID = "rnd:childcount_folders";
              if(resultMetaNameID != null)
                   IMetaName metaName = getPropertyConfigurationService().getMetaModel().searchById(resultMetaNameID);
                   if(metaName != null)
                        return getEncodedSortProperty(metaName);
              return null;
         private String getEncodedSortProperty(IMetaName metaName)
              if(metaName.getComposedOfMetaNames() != null)
                   IMetaNameList metaList = metaName.getComposedOfMetaNames();
                   if(metaList.contains(metaName))
                        return metaName.getId();
                   if(metaList.size() == 1)
                        IMetaName composedMetaName = metaList.get(0);
                        return composedMetaName.getId();
                   } else
                        return metaName.getId();
              } else
                   return metaName.getId();
         public static Vector getIMetaNameTypeText(IPropertyColumn propertyColumn, int col)
              Hashtable metaNameHash = null;
              Vector metaNameVector = null;
              IMetaName currentMetaName = null;
              IPropertyWithModifiersList propertyWithModifiers = propertyColumn.getPropertyWithModifier();
              for(int i = 0; i < propertyWithModifiers.size(); i++)
                   currentMetaName = propertyWithModifiers.get(i).getMetaName();
                   if(currentMetaName != null && "Text".equals(currentMetaName.getType()) && propertyWithModifiers.size() != 1)
                        metaNameHash = new Hashtable();
                        metaNameHash.put("metaName", currentMetaName);
                        metaNameHash.put("col", Integer.toString(col));
                        if(propertyWithModifiers.get(i).getConfigModifierList() != null)
                             metaNameHash.put("metaNameModifiers", propertyWithModifiers.get(i));
                        if(metaNameVector == null)
                             metaNameVector = new Vector();
                        metaNameVector.add(metaNameHash);
              return metaNameVector;
         private static boolean[] isNextLineColumnNeeded(IPropertyColumn propertyColumns[])
              boolean result[] = new boolean[propertyColumns.length];
              IMetaName currentMetaName = null;
              for(int j = 0; j < propertyColumns.length; j++)
                   IPropertyColumn propertyColumn = propertyColumns[j];
                   result[j] = false;
                   IPropertyWithModifiersList propertyWithModifiers = propertyColumn.getPropertyWithModifier();
                   for(int i = 0; i < propertyWithModifiers.size(); i++)
                        currentMetaName = propertyWithModifiers.get(i).getMetaName();
                        if(currentMetaName != null && "Text".equals(currentMetaName.getType()) && propertyWithModifiers.size() != 1)
                             if(log.beDebug())
                                  log.debugT("Found meta name <" + currentMetaName + "> in property column <" + propertyColumn + "> that defines we need a new line column");
                             result[j] = true;
              return result;
         private IPropertyConfigurationService getPropertyConfigurationService()
              throws WcmException
              return (IPropertyConfigurationService)ResourceFactory.getInstance().getServiceFactory().getService("PropertyConfigurationService");
         public final void setColumnsList(IPropertyColumn list[])
              throws WcmException
              getIRS().setPropertyColumns(list);
         public IPropertyColumn[] getColumnsList()
              throws WcmException
              return getIRS().getPropertyColumns();
         private IPropertyColumn[] createCollectionColumns()
              String columnsString = getParameters().getParameter(ICollectionRendererParameterNameConst.PROPERTYCOLUMNS, "rnd:icon(noTitle/noColumnSpacing),rnd:displayname(contentLink)");
              return PropertyColumnFactory.getInstance().parseProperty(columnsString);
         public Component renderUI()
              throws WcmException
              s_profiler.start("/KM/FLEXUI/RENDER/UI", com.sapportals.wcm.util.profiler.IProfiler.Level.MEDIUM);
              try
                   if(getProxy().isDebugEnabled())
                        writeDebugInformation();
                   setColumnsList(createCollectionColumns());
                   FormLayout grid = new FormLayout();
                   grid.setMargin("0", "0", "0", "0");
                   grid.setWidth("");               
                   FormLayoutCell cell = null;
                   grid.setDebugMode(debug);
                   int row = 1;
                   grid.addComponent(++row, 1, new TextView("CH-BOVENALL"));
                   if(!isVisible())
                        FormLayout formlayout = grid;
                        return formlayout;
                   if(getParameter(ICollectionRendererParameterNameConst.SHOWFOLDERTITLE, false))
                        cell = grid.addComponent(row, 1, renderFolderTitle());
                        cell.setColspan(10);
                        cell.setPaddingTop("2");
                        cell.setPaddingBottom("3");
                        row++;
                   IResourceList resourcelist = getResourceList();
                   if(!getParameters().isExactlyValue(ICollectionRendererParameterNameConst.EMPTY_COLLECTION_STYLE, "off") && resourcelist != null && resourcelist.size() == 0)
                        cell = grid.addComponent(row, 1, new EmptyCollectionInfo(getProxy(), getParameters()));
                        cell.setColspan(10);
                        cell.setHorizontalAlignment(CellHAlign.LEFT);
                        row++;
                   noOfColumns = PropertyColumnFactory.getNoOfColumn(getColumnsList(), MaxNumberOfRows);
                   int column = 1;
                   if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                        column++;
                        noOfColumns++;
                   if(getParentCollection() != null)
                        FolderSettings currFolderSettings = new FolderSettings(getParentCollection());
                        isManualOrdered = currFolderSettings.getOrderedFlag();
                   row = renderListHeader(grid, row);
                   boolean widthStrech = getParameters().getParameter(ICollectionRendererParameterNameConst.RESIZEWIDHTSTYLE, "compact").equals("stretch");
                   boolean heightStrech = getParameters().getParameter(ICollectionRendererParameterNameConst.RESIZEHEIGHTSTYLE, "compact").equals("stretch");
                   int maxnumberOfElements = getStartRow() + getParameters().getParameter(ICollectionRendererParameterNameConst.ROWS, MaxNumberOfRows);
                   if(maxnumberOfElements > resourcelist.size())
                        maxnumberOfElements = resourcelist.size();
                   int rowHeightPercent = 0;
                   if(heightStrech && maxnumberOfElements != 0)
                        rowHeightPercent = 100 / maxnumberOfElements;
                   IResourceList renderlist = resourcelist.subList(getStartRow(), maxnumberOfElements);
                   IResourceListIterator iter = renderlist.listIterator();
                   IResource res = null;
                   boolean lightStyleClass = true;
                   String classStyle = "";
                   boolean alternatingMode = isExactlyValue(ICollectionRendererParameterNameConst.ROWBACKGROUNDSTYLE, "ALTERNATING");
                   boolean lineSeparatedMode = isExactlyValue(ICollectionRendererParameterNameConst.ROWBACKGROUNDSTYLE, "LINE_SEPARATED");
                   if(alternatingMode || lineSeparatedMode)
                        grid.addComponent(row, 1, HtmlRendererUtil.importStyles());
                        row++;
                   if(getColumnsList() != null)
                        IPropertyNameList propertynamelist = PropertyColumnFactory.getInstance().getPropertyNameList(getColumnsList());
                        for(int i = 0; i < DEFAULT_PROP_NAMES.length; i++)
                             if(DEFAULT_PROP_NAMES<i> != null)
                                  propertynamelist.add(DEFAULT_PROP_NAMES<i>);
                        s_profiler.start("/KM/FLEXUI/RENDER/UI/GETPROPS", com.sapportals.wcm.util.profiler.IProfiler.Level.MEDIUM);
                        try
                             getProxy().getAmalgamation().readProperties(renderlist, propertynamelist);
                        finally
                             s_profiler.stop("/KM/FLEXUI/RENDER/UI/GETPROPS");
                        IPropertyPosition positions[] = getPositionArray(getColumnsList());
                        boolean nextColumns[] = isNextLineColumnNeeded(getColumnsList());
                        boolean selectionActive = !getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off");
                        List paddings = getPaddingList(getColumnsList(), selectionActive);
                        while(iter.hasNext())
                             res = iter.next();
                             if(alternatingMode)
                                  classStyle = "urCellBgPlain";
                                  if(!lightStyleClass)
                                       classStyle = "urSTbvCellAlt";
                             row = renderFormRow(grid, row, 1, res, classStyle, rowHeightPercent, propertynamelist, positions, nextColumns, paddings);
                             if(lineSeparatedMode && iter.hasNext())
                                  cell = grid.addComponent(row, 1, HtmlRendererUtil.renderLineSeparator("urCellBgPlain", 1));
                                  cell.setColspan(noOfColumns);
                                  row++;
                             lightStyleClass = !lightStyleClass;
                   row = renderListFooter(grid, row);
                   if(widthStrech)
                        grid.setWidth("100%");
                   FormLayout formlayout1 = grid;
                   IParameters parameters = getParameters();
                   formlayout1.addComponent(++row, 1, new TextView("CH-BOVEN "+parameters.getParameter(IParameterName.PAGER_LINK_COUNT).toString()));
                   return formlayout1;
              catch(Exception ex)
                   throw new WcmException(ex);
              finally
                   s_profiler.stop("/KM/FLEXUI/RENDER/UI");
         private static List getPaddingList(IPropertyColumn columnsList[], boolean selectionActive)
              List result = new ArrayList();
              for(int i = 0; i < columnsList.length; i++)
                   String padding[] = null;
                   try
                        padding = PropertyColumnRenderer.getPropertyColumnArrayPadding(columnsList<i>, selectionActive);
                   catch(WdfException e)
                        log.errorT("Could not parse padding for column <" + columnsList<i> + "> " + LoggingFormatter.beautify(e));
                        padding = (new String[] {
                             "0", "0", "0", "0"
                   result.add(padding);
              return result;
         private static IPropertyPosition[] getPositionArray(IPropertyColumn columns[])
              IPropertyPosition result[] = new IPropertyPosition[columns.length];
              for(int i = 0; i < columns.length; i++)
                   result<i> = PropertyColumnFactory.getInstance().getPosition(columns<i>);
              if(log.beDebug())
                   log.debugT("Calculated property position array <" + result + "> for property column array <" + columns + ">");
              return result;
         private int renderFormRow(FormLayout grid, int row, int column, IResource res, String classStyle, int rowHeightPercent, IPropertyNameList propertynamelist,
                   IPropertyPosition positions[], boolean nextColumns[], List paddings)
              throws WcmException
              s_profiler.start("/KM/FLEXUI/RENDER/UI/ROW ", com.sapportals.wcm.util.profiler.IProfiler.Level.MEDIUM);
              try
                   boolean emptyRow = true;
                   try
                        Vector nextLine = new Vector();
                        Vector nextLineColumn = new Vector();
                        Hashtable nextLineElement = new Hashtable();
                        FormLayoutCell cell = null;
                        int nextLineCol = 0;
                        int line = 1;
                        int startRow = row;
                        boolean selectionActive = false;
                        IPropertyPosition position = null;
                        IResourceRenderer renderer = getRenderer(res);
                        renderer.setPropertyNameList(propertynamelist);
                        String padding[] = null;
                        Component comp = new HTMLFragment(" ");
                        if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                             comp = renderItemSelectionMode(res);
                             cell = grid.addComponent(row, column, comp);
                             cell.setVerticalAlignment(VERTICAL_ALIGN);
                             cell.setPaddingRight("2");
                             cell.setPaddingLeft("3");
                             selectionActive = true;
                             column++;
                        int columnSpan = 0;
                        int rowSpan = 0;
                        IMetaName metaName = null;
                        for(int i = 0; i < getColumnsList().length; i++)
                             try
                                  columnSpan = 0;
                                  position = positions<i>;
                                  if(position != null)
                                       int lineNew = position.getRow();
                                       if(line != lineNew)
                                            column = position.getColumn();
                                            if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                                                 column++;
                                            line = lineNew;
                                            if(!emptyRow)
                                                 row++;
                                            emptyRow = true;
                                       columnSpan = position.getSpanColumn();
                                       rowSpan = position.getSpanRow();
                                  comp = PropertyColumnRenderer.renderPropertyColumn(renderer, res, getColumnsList()<i>, false, getProxy());
                                  emptyRow = emptyRow && (comp == null || (comp instanceof EmptyComponent));
                                  if(comp != null)
                                       if(columnSpan != 0)
                                            cell = grid.addComponent(row, column, comp);
                                            cell.setColspan(columnSpan);
                                       } else
                                            cell = grid.addComponent(row, column, comp);
                                       if(rowSpan != 0)
                                            cell.setRowspan(rowSpan);
                                       cell.setVerticalAlignment(PropertyColumnFactory.getInstance().getVAlign(getColumnsList()<i>));
                                       cell.setHorizontalAlignment(PropertyColumnFactory.getInstance().getHAlign(getColumnsList()<i>));
                                       padding = (String[])paddings.get(i);
                                       if(padding != null)
                                            cell.setPaddingTop(padding[0]);
                                            cell.setPaddingRight(padding[1]);
                                            cell.setPaddingBottom(padding[2]);
                                            cell.setPaddingLeft(padding[3]);
                                       selectionActive = false;
                                  if(nextColumns<i>)
                                       nextLineColumn = getIMetaNameTypeText(getColumnsList()<i>, column);
                                       nextLine.addAll(nextLineColumn);
                                  column++;
                             catch(WcmException wcmEx)
                                  log.debugT("Could not rendere row for resource <" + res + "> & columns <" + getColumnsList()<i> + ">" + LoggingFormatter.extractCallstack(wcmEx));
                                  if(columnSpan != 0)
                                       cell = grid.addComponent(row, column, EmptyComponent.render());
                                       cell.setColspan(columnSpan);
                                  } else
                                       cell = grid.addComponent(row, column, EmptyComponent.render());
                                  column++;
                             if(columnSpan != 0)
                                  column += columnSpan;
                             if(!getColumnsList()<i>.contains("noColumnSpacing") && column < noOfColumns)
                                  cell = grid.addComponent(row, column, EmptyComponent.render());
                                  if(!"0".equals(getColumnSpacing()))
                                       cell.setWidth(getColumnSpacing());
                                  column++;
                        boolean emptyComponent = true;
                        for(int k = 0; k < nextLine.size(); k++)
                             nextLineElement = (Hashtable)nextLine.elementAt(k);
                             if(nextLineElement != null)
                                  IPropertyWithModifiers currProp = (IPropertyWithModifiers)nextLineElement.get("metaNameModifiers");
                                  nextLineCol = Integer.parseInt((String)nextLineElement.get("col"));
                                  metaName = (IMetaName)nextLineElement.get("metaName");
                                  renderer.getParameters().setParameter(IResourceRendererParameterNameConst.PROPERTY_MODIFIERS, PropertyColumnFactory.getInstance().getModifierString(currProp.getModifierList()));
                                  comp = PropertyColumnRenderer.renderMetaProperty(renderer, metaName, false, true);
                                  emptyComponent = false;
                                  if(comp != null && (comp instanceof EmptyComponent))
                                       emptyComponent = true;
                                  if(!emptyComponent)
                                       if(!emptyRow)
                                            row++;
                                       cell = grid.addComponent(row, nextLineCol, comp);
                                       cell.setColspan(column);
                                       emptyRow = false;
                        int rowSpace = 0;
                        try
                             rowSpace = Integer.parseInt(getRowSpacing());
                        catch(NumberFormatException nfEx)
                             log.debugT("Could not get an Integer from <" + getRowSpacing() + ">; " + LoggingFormatter.extractCallstack(nfEx));
                             rowSpace = 0;
                        int endRow = row;
                        if(emptyRow)
                             endRow = row - 1;
                        if(rowSpace != 0)
                             String paddingStyle = String.valueOf(rowSpace);
                             if(startRow != endRow)
                                  setHeightPercentageForm(rowHeightPercent, paddingStyle, 1, grid, startRow, noOfColumns);
                                  setHeightPercentageForm(rowHeightPercent, paddingStyle, 1, grid, endRow, noOfColumns);
                             } else
                                  setHeightPercentageForm(rowHeightPercent, paddingStyle, 0, grid, endRow, noOfColumns);
                        if(!"".equals(classStyle))
                             setClassStyleForm(classStyle, grid, startRow, row, noOfColumns);
                   catch(Exception e)
                        throw new WcmException(e);
                   if(!emptyRow)
                        row++;
              finally
                   s_profiler.stop("/KM/FLEXUI/RENDER/UI/ROW ");
              return row;
         private void setHeightPercentageForm(int rowHeightPercent, String padding, int paddingStyle, FormLayout grid, int row, int col)
              FormLayoutCell cell = null;
              FormLayoutRow rows = grid.getRow(row);
              for(int j = 1; j <= col; j++)
                   cell = rows.getCell(j);
                   if(cell != null)
                        if(rowHeightPercent != 0)
                             cell.setWidth(""";height="" + String.valueOf(rowHeightPercent) + "%"");
                        if(paddingStyle == 1)
                             cell.setPaddingTop(padding);
                        else
                        if(paddingStyle == -1)
                             cell.setPaddingBottom(padding);
                        } else
                             cell.setPaddingTop(padding);
                             cell.setPaddingBottom(padding);
         private void setClassStyleForm(String classStyle, FormLayout grid, int startRow, int endRow, int col)
              FormLayoutCell cell = null;
              FormLayoutRow currentRow = null;
              int rowSpan = 0;
              int noCol = col;
              boolean hasRowSpan = false;
              for(int i = startRow; i <= endRow; i++)
                   currentRow = grid.getRow(i);
                   if(currentRow != null)
                        if(hasRowSpan)
                             noCol = col - 1;
                             hasRowSpan = --rowSpan > 0;
                        } else
                             noCol = col;
                        for(int j = 1; j <= noCol; j++)
                             cell = currentRow.getCell(j);
                             if(cell != null && cell.getRowspan() > 1)
                                  hasRowSpan = true;
                                  rowSpan = cell.getRowspan() - 1;
                             if(cell != null)
                                  cell.setStyle(classStyle);
                             } else
                                  cell = grid.addComponent(i, j, EmptyComponent.render());
                                  cell.setStyle(classStyle);
         public HeaderItem[][] genetateMatrixHeader()
              throws WcmException
              if(isExactlyValue(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "off"))
                   return null;
              IPropertyPosition position = null;
              IPropertyColumn iterColumns[] = getColumnsList();
              boolean existsResource = getResourceList().size() != 0;
              if(!existsResource)
                   return null;
              HeaderItem headerMatrix[][] = new HeaderItem[10][20];
              int currentRow = 0;
              int currentColumn = 0;
              int currentRowSpan = 0;
              int currentColumnSpan = 0;
              int nextCol = 0;
              int maxRow = 0;
              int maxCol = 0;
              boolean is508Required = false;
              try
                   is508Required = getProxy().getDynamicPage().getPageContext().requiresSection508Rendering();
              catch(Exception ex)
                   log.errorT("Could not retrieve 508 mode for proxy <" + getProxy() + ">: " + LoggingFormatter.extractCallstack(ex));
              IMetaName metaName = null;
              for(int i = 0; i < iterColumns.length && existsResource; i++)
                   if(iterColumns<i> != null)
                        position = PropertyColumnFactory.getInstance().getPosition(iterColumns<i>);
                        if(position != null)
                             if(currentRow != position.getRow() - 1)
                                  nextCol = 0;
                             currentRow = position.getRow() - 1;
                             currentColumn = (position.getColumn() - 1) + nextCol;
                             currentRowSpan = position.getSpanRow();
                             currentColumnSpan = position.getSpanColumn();
                        } else
                             currentRowSpan = 0;
                             currentColumnSpan = 0;
                   metaName = PropertyHeaderRenderer.getMetaNameForTitle(iterColumns<i>, is508Required);
                   if(metaName != null)
                        headerMatrix[currentRow][currentColumn] = new HeaderItem(currentRowSpan, currentColumnSpan, metaName, iterColumns<i>);
                        nextCol = 1;
                        maxRow = maxRow <= currentRow ? currentRow : maxRow;
                        maxCol = maxCol <= currentColumn ? currentColumn : maxCol;
                   currentColumn++;
                   if(currentColumnSpan != 0)
                        currentColumn += currentColumnSpan;
                   if(!iterColumns<i>.contains("noColumnSpacing"))
                        currentColumn++;
              maxRow++;
              maxCol++;
              if(maxRow > 0 || maxCol > 0)
                   HeaderItem resultMatrix[][] = new HeaderItem[maxRow][maxCol];
                   for(int i = 0; i < maxRow; i++)
                        for(int k = 0; k < maxCol; k++)
                             resultMatrix<i>[k] = headerMatrix<i>[k];
                   return resultMatrix;
              } else
                   return null;
         public int renderListHeader1(FormLayout grid, int row)
              throws WcmException
              if(isExactlyValue(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "off"))
                   return row;
              HeaderItem header[][] = genetateMatrixHeader();
              if(header == null)
                   return row;
              String propertyHeaderColumnStyle = getParameters().getParameter(ICollectionRendererParameterNameConst.PROPERTY_COLUMN_HEADER_STYLE, "Table Title Color");
              String headerClassStyle = HtmlRendererUtil.getHeaderClassStyle(propertyHeaderColumnStyle);
              if(headerClassStyle == null)
                   headerClassStyle = "";
              FormLayoutCell cell = null;
              int columnSpan = 0;
              int column = 1;
              if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                   column++;
              int startRow = row;
              HeaderItem headerItem = null;
              PropertyHeaderRenderer sortHeader = new PropertyHeaderRenderer(getProxy(), this, getBundleHandler(), getChildCountMetaName(getParentCollection()), isManualOrdered, getIRS().getSortDefintion(), getResourceContext().getLocale());
              IMetaName metaName = null;
              int colHeader = 0;
              for(int i = 0; i < header.length; i++)
                   row += i;
                   if(!getParameters().getParameter(ICollectionRendererParameterNameConst.ITEMSELECTIONMODE, "multiple").equals("off"))
                        colHeader = 1;
                   else
                        colHeader = 0;
                   for(int k = 0; k < header[0].length; k++)
                        headerItem = header<i>[k];
                        if(headerItem != null)
                             boolean is508Required = false;
                             try
                                  is508Required = getProxy().getDynamicPage().getPageContext().requiresSection508Rendering();
                             catch(Exception ex)
                                  log.errorT("Could not retrieve 508 mode for proxy <" + getProxy() + ">: " + LoggingFormatter.extractCallstack(ex));
                             metaName = headerItem.getLabelMetaName();
                             if(headerItem.getColSpan() != 0)
                                  cell = grid.addComponent(row, k + colHeader + 1, sortHeader.createSortLink(metaName));
                                  cell.setColspan(headerItem.getColSpan());
                             } else
                                  cell = grid.addComponent(row, k + colHeader + 1, sortHeader.createSortLink(metaName));
                             String padding[] = HtmlRendererUtil.getPropertyPaddingValues(headerItem.getPropertyColumn(), metaName);
                             cell.setHorizontalAlignment(PropertyColumnFacto

    Hello
    My problem is the following on the moment:
    In debug, I get the message the pager can't be created.
    Could not create command with alias KenGPager and classname be.kindengezin.wcm.rendering.component.cm.Pager:java.lang.ClassNotFoundException: be.kindengezin.wcm.rendering.component.cm.Pager
         at com.sapportals.wcm.crt.CrtClassLoaderRegistry.findClass(CrtClassLoaderRegistry.java:176)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at com.sapportals.wcm.rendering.collection.ComponentFactory.createComponent(ComponentFactory.java:447)
         at com.sapportals.wcm.rendering.collection.ComponentFactory.initialize(ComponentFactory.java:489)
         at com.sapportals.wcm.rendering.collection.ComponentFactory.configEvent(ComponentFactory.java:553)
         at com.sapportals.config.event.ConfigEventService.dispatchEvent(ConfigEventService.java:227)
         at com.sapportals.config.event.ConfigEventService.configEvent(ConfigEventService.java:112)
         at com.sapportals.config.event.ConfigEventDispatcher.callConfigListeners(ConfigEventDispatcher.java:308)
         at com.sapportals.config.event.ConfigEventDispatcher.flushEvents(ConfigEventDispatcher.java:251)
         at com.sapportals.config.event.ConfigEventDispatcher.run(ConfigEventDispatcher.java:110)
    My java files start as following:
    package be.kindengezin.wcm.rendering.component.cm;
    import com.sap.tc.logging.Location;
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.TextViewDesign;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.wcm.WcmException;
    import com.sapportals.wcm.control.util.PropertyRendererString;
    import com.sapportals.wcm.rendering.base.*;
    import com.sapportals.wcm.rendering.collection.*;
    import com.sapportals.wcm.rendering.util.EmptyHtmlFragment;
    import com.sapportals.wcm.rendering.util.PagerData;
    import com.sapportals.wcm.repository.*;
    import com.sapportals.wcm.repository.service.IRepositoryServiceFactory;
    import com.sapportals.wcm.repository.service.layout.customizing.IParameterName;
    import com.sapportals.wcm.service.propertyconfig.*;
    import com.sapportals.wcm.util.logging.LoggingFormatter;
    import com.sapportals.wcm.util.name.IName;
    import com.sapportals.wcm.util.resource.ResourceBundles;
    import com.sapportals.wcm.util.uri.RID;
    import java.util.*;
    // Referenced classes of package com.sapportals.wcm.rendering.component.cm:
    //                 LightComponent, PagerComponent, PagerInterval
    public class Pager extends LightComponent
    Edited by: Christof Houben on Oct 6, 2008 3:44 PM

  • Avoid iterating through everything

    Hello all,
    Hope you guys can help me with this problem. I have a program that draws anywhere from 1-300,000 letters on a canvas. Each letter is created from a class called StringState which extends Rectangle. What I would like to do is have each letter respond when the user moves the mouse over the letter by growing bigger. I figured I can just see if the letters bounds contains the point where the mouse moved to and if it does change the letters size and repaint around that letter to update the display. This works great from 1-5000 letters but getting up to 10,000 or even higher creates a very visible lag while the program is iterating through the letters to check if the mouse location intersects the letters bounds. What I was wondering is there a way to get this result without iterating through the entire collection of letters to see if it contains the mouse location? Like can I attach some kind of mouse listener to each letter or something like that? The following program just demonstrates how I create and display the letters I haven't really had a chance to create a demonstration of how they would grow when hovered over. The program i'm working on that actually demonstrates this is very large and hard to trim down to show an example so the following code is actually from a previous question I asked and was provided by Aephyr. Thanks in advance for your guys help :)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.util.List;
    public class PaintSurface implements Runnable, ActionListener {
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new PaintSurface());
         Tableaux tableaux;
         Random random = new Random();
    //        Point mouselocation = new Point(0,0);
         static final int WIDTH = 1000;
         static final int HEIGHT = 1000;
            JFrame frame = new JFrame();
         public void run() {
              tableaux = new Tableaux();
              for (int i=15000; --i>=0;)
                   addRandom();
              frame.add(tableaux, BorderLayout.CENTER);
              JButton add = new JButton("Add");
              add.addActionListener(this);
              frame.add(add, BorderLayout.SOUTH);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(WIDTH, HEIGHT);
              frame.setLocationRelativeTo(null);
    //                frame.addMouseMotionListener(new MouseListener());
              frame.setVisible(true);
         public void actionPerformed(ActionEvent e) {
              addRandom();
         void addRandom() {
              tableaux.add(
                        Character.toString((char)('a'+random.nextInt(26))),
                        UIManager.getFont("Button.font"),
                        random.nextInt(WIDTH), random.nextInt(HEIGHT));
    //        class MouseListener extends MouseAdapter {
    //            public void mouseMoved(MouseEvent e) {
    //                mouselocation = new Point(e.getX(),e.getY());
    //                frame.repaint();
            class StringState extends Rectangle {
                    StringState(String str, Font font, int x, int y, int w, int h) {
                            super(x, y, w, h);
                            string = str;
                            this.font = font;
                    String string;
                    Font font;
            class Tableaux extends JComponent {
                 Tableaux() {
                      this.enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK);
                      lagState = createState("Lag", new Font("Arial",Font.BOLD,20), 0, 0);
                 protected void processMouseMotionEvent(MouseEvent e) {
                      repaint(lagState);
                      lagState.setLocation(e.getX(), e.getY());
                      repaint(lagState);
                      super.processMouseMotionEvent(e);
                 StringState lagState;
                    List<StringState> states = new ArrayList<StringState>();
                    StringState createState(String str, Font font, int x, int y) {
                        FontMetrics metrics = getFontMetrics(font);
                        int w = metrics.stringWidth(str);
                        int h = metrics.getHeight();
                        return new StringState(str, font, x, y-metrics.getAscent(), w, h);
                    public void add(String str, Font font, int x, int y) {
                         StringState state = createState(str, font, x, y);
                            states.add(state);
                            repaint(state);
                    protected void paintComponent(Graphics g) {
                            Rectangle clip = g.getClipBounds();
                            FontMetrics metrics = g.getFontMetrics();
                            for (StringState state : states) {
                                    if (state.intersects(clip)) {
                                            if (!state.font.equals(g.getFont())) {
                                                    g.setFont(state.font);
                                                    metrics = g.getFontMetrics();
                                            g.drawString(state.string, state.x, state.y+metrics.getAscent());
                            if (lagState.intersects(clip)) {
                            g.setColor(Color.red);
                            if (!lagState.font.equals(g.getFont())) {
                                g.setFont(lagState.font);
                                metrics = g.getFontMetrics();
                            g.drawString("Lag", lagState.x, lagState.y+metrics.getAscent());
    }Here is the code that iterates through the letters to see if a letter contains the mouse location:
                if(e.getSource()==canvas&&edit) {
                    for(Letter l : letters) {
                        Rectangle rec = new Rectangle(l.x+l.xoffset,l.y+l.yoffset,l.width,l.height);
                        if(rec.contains(new Point(e.getX(),e.getY()))&&l.resizing==false&&l.defaultSize==l.font.getSize()) {
                            l.resizing = true;
                            new Thread(new ExpandLetter(l)).start();
                        else if(!rec.contains(new Point(e.getX(),e.getY()))&&l.resizing==false){
                            l.font = new Font(l.font.getName(),l.font.getStyle(),l.defaultSize);
                            l.resizeLetter(l.text);
                }However I just learned that this loop itself is taking up a huge amount of memory by saying
    l.font = new Font(l.font.getName(),l.font.getStyle(),l.defaultSize); When I take that line out the lag is reduced by a lot. Also I think that it isn't forgetting the "old" letters font that it is replacing by saying new Font() and after running this loop once my program runs slow and laggy as if it doesn't have enough memory to run fast anymore. Is there something I am doing wrong by initiating a new Font. I would have thought that it wouldn't take up anymore memory because it replaces the old font the the letter "l" has. The loop seems to have some kind of memory leak if someone could point it out to me that would be great. Thanks :)
    Edited by: neptune692 on Feb 16, 2010 8:18 PM

    neptune692 wrote:
    can I attach some kind of mouse listener to each letterTry this:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.*;
    import javax.swing.event.*;
    public class SimplePaintSurface implements Runnable, ActionListener {
        private static final int WIDTH = 1250;
        private static final int HEIGHT = 800;
        private Random random = new Random();
        private JFrame frame = new JFrame("SimplePaintSurface");
        private JPanel tableaux;
        public void run() {
            tableaux = new JPanel(null);
            for (int i = 15000; --i >= 0;) {
                addRandom();
            frame.add(tableaux, BorderLayout.CENTER);
            JButton add = new JButton("Add");
            add.addActionListener(this);
            frame.add(add, BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(WIDTH, HEIGHT);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            tableaux.requestFocusInWindow();
        public void actionPerformed(final ActionEvent e) {
            addRandom();
            tableaux.repaint();
        void addRandom() {
            Letter letter = new Letter(Character.toString((char) ('a' + random.nextInt(26))));
            letter.setBounds(random.nextInt(WIDTH), random.nextInt(HEIGHT), 16, 16);
            tableaux.add(letter);
        public static void main(final String[] args) {
            SwingUtilities.invokeLater(new SimplePaintSurface());
    class Letter extends JLabel {
        Font font1;
        Font font2;
        private final FontRenderContext fontRenderContext1;
        private final FontRenderContext fontRenderContext2;
        public Letter(final String letter) {
            super(letter);
            setFocusable(true);
            setBackground(Color.RED);
            font1 = getFont();
            font2 = font1.deriveFont(48f);
            fontRenderContext1 = getFontMetrics(font1).getFontRenderContext();
            fontRenderContext2 = getFontMetrics(font2).getFontRenderContext();
            MouseInputAdapter mouseHandler = new MouseInputAdapter() {
                @Override
                public void mouseEntered(final MouseEvent e) {
                    Letter.this.setOpaque(true);
                    setFont(font2);
                    Rectangle bounds = getBounds();
                    Rectangle2D stringBounds = font2.getStringBounds(getText(), fontRenderContext2);
                    bounds.width = (int) stringBounds.getWidth();
                    bounds.height = (int) stringBounds.getHeight();
                    setBounds(bounds);
                @Override
                public void mouseExited(final MouseEvent e) {
                    Letter.this.setOpaque(false);
                    setFont(font1);
                    Rectangle bounds = getBounds();
                    Rectangle2D stringBounds = font1.getStringBounds(getText(), fontRenderContext1);
                    bounds.width = (int) stringBounds.getWidth();
                    bounds.height = (int) stringBounds.getHeight();
                    setBounds(bounds);
            addMouseListener(mouseHandler);
    }

  • Number of entries in Adapter

    Hi XI!
    Can anyone tell me how to see the number of entries in a specific Adapter? The problem is that we fired a huge amount of message in an EOIO process into a file adapter. If I select the specific sender, receiver and interface in the RWB and try to show all messages, the system does not come back. I just want to have something like "number of entries" in SE16.
    Thanks and regards Oliver

    Hi Oliver,
    did you try SXMB_MONI?
    If yes, maybe you can try this way:
    Look at the table SXMSPFRAWH. The table entries include the GUID of the sender and receiver. Using the table SXMSPFADDRESS, it is possible to map these GUIDs to the respective interfaces. Aggregated data can be collected from the table SXMSPFAGG, once SAP note 820622 is applied.
    Kind regards,
    Dennis

  • Iterating through RWBTreeOnDisk

    Is there any way to Iterating through RWBTreeOnDisk, My problem is that i have 100 records in RWBTreeOnDisk and i want to fetch only first 20 records, how should i proceed to do the same, instead of getting all the records using applyToKeyAndValue(), i need to fetch particular number of records in the tree.
    Plz suggest me the way to proceed.
    Thanx

    We use sqlite for this sort of application. It gives you the power of sql but acts on files directly rather that via a server. see www.sqlite.org

  • How to find the number of entries in a master data table

    Hi Experts,
    I am trying to find the entries in 0CUSTOMER master data.
    BW>LISTCUBE>Data target: 0CUSTOMER and selected the fields that I need.
    I would like to know how to find the "number of entrees". I tried to run the SUM for a count field, but it is taking forever as there are huge number of records .

    Hi Dev,
    Go to the change/display mode of the info object (0CUSTOMER) in your case. Go to the Master data/Text tab. Here you will find the master data tables according to your settings (P orQ or X or Y). Double click on the table name and it will take you to the SE11 display. From there, you can check the number of records as you do in any transparent table.
    Hope this helps.
    Thanks and Regards
    Subray Hegde

  • Large number of entries in Queue BW0010EC_PCA_1

    Dear BW experts,
    Our BW system 2004s is extracting data from R3 700. I am a Basis guy and observing large number of entries in SMQ1 in R3 system under Queue BW0010EC_PCA_1. I observe in RSA7 similar number of entries for 0EC_PCA_1.
    The number of entries for this queue in SMQ1 everyday are 50000+. The extraction job in BW is running everyday 5:00AM morning in BW but this only clears data which is lying before 2 days (Example on 10.09.2010, it will extract data of 08.09.2010)
    My questions
    1. Is it ok that such large number of entries lying in queue in SMQ1 and they are extracted once a day by a batch job.Then there is no mean of schedular pushing this entries.
    2. Any idea why extraction job only fetches data of 2 days before.any setting somewhere missing.
    Many thanks in advance for your valuable comments

    Hi,
    The entries lying in RSA7 and SMQ1 are one and the same. In SMQ1, BW0010EC_PCA_1 entry means that this data is lying to be sent across to you BW001 client system. Whereas in RSA7, same data is displayed as 0EC_PCA_1.
    1. Is it ok that such large number of entries lying in queue in SMQ1 and they are extracted once a day by a batch job.Then there is no mean of schedular pushing this entries.
    As I can understand from the data thats lying in your R/3 system in SMQ1, this datasource has delta mode as Direct Delta. SAP recommends that if the number of postings for a particular application is greater than 100000 per day, you should have delta mode as Queued Delta. Since in your system it is in some thousands, therefore BI guys would have kept it as direct delta. So, these entries lying in SMQ1 are not problem at all. As for scheduler from BI, it will pick up these entries every morning to clear the queue for the previous data.
    2. Any idea why extraction job only fetches data of 2 days before.any setting somewhere missing.
    I dont think that it is only fetching the data for 2 days before. The delta concept works in such a manner that once you have pulled the delta load from RSA7, this data would still be lying there under Repeat delta section until the next delta load has finished successfully.
    Since in your system, data is pulled only once a day, therefore even though your today's dataload has pulled yesterday's data, it would still be lying in the system till tomorrow's delta load from RSA7 is successful.
    Hope this was helpful.

  • Query using system parameter LEVEL returns incorrect huge number of records

    We migrate our database from Oracle *9.2.0.6* to *11.2.0.1*
    The query below throws "ORA-01788: CONNECT BY clause required in this query block".
    select * from (
    +select a.BOARD_ID, code, description, is_displayable, order_seq,  board_parent_id, short_description, IS_SUB_BOARD_DISPLAYABLE, <font color=blue>LEVEL</font> child_level, sp_board.get_parent_id(a.board_id) top_parent_id, is_top_selected isTopSelected+
    from boards a, ALERT_MESSAGE_BOARD_TARGETS b
    where a.board_id = b.board_id and is_displayable = 'Y' and alert_message_id = 5202) temp
    start with board_parent_id = 0
    connect by prior board_id = board_parent_id
    ORDER SIBLINGS BY order_seq;
    Based from online resources we modified "*_allow_level_without_connect_by*" by executing the statement.
    alter system set "_allow_level_without_connect_by"=true scope=spfile;
    After performing the above, ORA-01788 is resolved.
    The new issue is that the same query above returns *9,015,853 records in 11g* but in *9i it returns 64 records*. 9i returns the correct number of records. And the cause for 11g returning greater number of records is due to system parameter <font color=blue>LEVEL</font> used in the query.
    Why 11g is returning an incorrect huge number of records?
    Any assistance to address this is greatly appreciated. Thanks!

    The problem lies in th query.
    Oracle <font color=blue>LEVEL</font> should not be used inside a subquery. After <font color=blue>LEVEL</font> is moved in the main query, the number of returned records is the same as in 9i.
    select c.BOARD_ID, c.code, c.description, c.is_displayable, c.order_seq, c.board_parent_id, c.short_description, c.IS_SUB_BOARD_DISPLAYABLE, <font color=blue>LEVEL</font> child_level, c.top_parent_id, c.isTopSelected
    from (
    select a.BOARD_ID, code, description, is_displayable, order_seq, board_parent_id, short_description, IS_SUB_BOARD_DISPLAYABLE, sp_board.get_parent_id(a.board_id) top_parent_id, is_top_selected isTopSelected
    from boards a, ALERT_MESSAGE_BOARD_TARGETS b
    where a.board_id = b.board_id and is_displayable = 'Y' and alert_message_id = 5202
    ) c
    start with c.board_parent_id = 0
    connect by prior c.board_id = c.board_parent_id
    ORDER SIBLINGS BY c.order_seq

  • Compensate an invoice through a manual accounting entry in ByD??

    Is it posible in SAP ByDesign to compensate open invoices through manual accounting entries?
    A client uses a non-standar  payment method for supplier invoices, so they make the accounting payments manually through "New document accounting entry".
    "Suppliers            to              other account... "
    In this transaction, we choose the type Manual entry for suppliers-Revaluation/Depreciation, and in the positions we specify the open invoice number and supplier number.
    But in the center Debits-Suppliers, the total balance of the supplier has decreased but the position invoice still remains open.
    How can I compensate this invoices then??
    Greetings

    Hi again Lokesh
    Yes, using New/Charge Credit, I can post a document type:
         Suppliers                        to                        Expenses account
    And after that, being able to compensate/clear the supplier invoice, that's ok.
    But the New/Charge Credit panel, cost allocation allows to add ledger accounts only of groups Expenses or Incomes, and in some cases I would need to use another ledger accounts in this panel.
    And in Fine tunning, accounts determination is limited for account types, so I would need to make too many changes at this point, but well I'll see...
    Many thanks

  • Create huge number of IDOC

    Hi All,
    I am asked to create a file to IDOC scenario in PI. The problem is, the file will have around 200,000 records, 96MB. That means I have to get the 200,000 records from the file and create 200,000 PO IDOC at once. I know this is not possible. Does any one have this experience? How did you solve the problem?
    Thanks a lot!
    Charles

    Few ways to implement this.
    Though the file has huge number of records, you can tweak  or control the number of idocs creating at the reciever side.
    Refer michal blog for edit the occurence of target idoc structure to sent the number of idocs as per the need.
    The specified item was not found.
    https://wiki.sdn.sap.com/wiki/display/XI/File%20to%20Multiple%20IDOC%20Splitting%20without%20BPM
    if your sender side is flat file then in the content conversion you set the parameter Recordsets per message like 100 or so.. so that you create 100 idocs each time from the sender message structure. Refer SDN forum for fcc parameters and sender fcc adapter scenario.
    Refer this thread
    Recordsets per Message in File adapter

  • Concurrent modification exception while iterating through list

    Hi,
    I have a list of objects. I use for each loop in java to iterate through that list of objects and display them.
    The problem is that while iterating other thread can add or remove some objects from that list, and I get ConcurrentModificationException.
    How can I handle this problem. How can I be sure that I am iteration through the updated list.
    Thank you

    Synchonize on the list before iterating through it, and make sure that other code also synchronizes on the list before adding to it or removing from it. Using a list implementation that simply synchronizes all the methods (e.g. Vector) will not do that, you have to do it yourself.

  • Every time I go somewhere online I get a message that a huge number of errors occurred in opening the window. Why?

    Every time I go to a site online I get a message that a huge number of errors occurred going to it. Why?

    I can load that site no problem.
    If you see Develop in the Safari menu bar (top of your screen) click Develop.
    If you see any check ✔ marks, select that item one more time to deselect.
    Then try that site.
    If the Develop menu was not available, go to Safari > Preferences > Extensions
    If there are any installed, turn that OFF, quit and relaunch Safari to test.
    And in Safari > Preferences > Security
    Make sure Enable plug-ins, and Java are enabled and deselect Bllock pop-up windows
    Quit and relaunch Safari.
    If installled, try temporarily disabling anti virus software.

  • Iterating through View Object RowIterator Bug.

    I use this code to loop through the rows of a view object (As described in javadoc of RowIteratior).
    public String checkIterations() {
    String res = "Iterated through : ";
    RowIterator view = this.getDepartmentsView1();
    view.reset();
    Row row;
    while ((row = view.next()) != null) {
    System.out.println("rownum: " + row.getAttribute("RowNum"));
    res += row.getAttribute("RowNum") + " ";
    return res;
    Yet this code never goes through the first row if the executequery has been performed for view object.
    details:
    [http://adfbugs.blogspot.com/2009/07/iterating-through-view-object.html]
    Is this a bug?
    Edited by: mkonio on Jul 28, 2009 11:41 PM

    Thanks Andrejus and Steve.
    Its a development bug
    problem and solution described in:
    Fusion Developer's Guide for Oracle ADF
    9.7.6 What You May Need to Know About Programmatic Row Set Iteration

  • Slow due to huge number of tables

    Hi,
    unfortunately we have a really huge number of tables in the ( Advantage Server ) database.
    About 18,000 + tables
    Firing the acitveX preview thru RDC, or just running a preview in the designer slows down to a crawl.
    Any hints? ( Besides get rid of that many tables )
    Thanks
    Oskar

    Hi Oskar
    The performance of a report is related to:
    External factors:
    1. The amount of time the database server takes to process the SQL query.
        ( Crystal Reports send the SQL query to the database, the database process it, and returns the data set to Crystal Reports. )
    2. Network traffics.
    3. Local computer processor speed.
        ( When Crystal Reports receives the data set, it generates a temp file to further filter the data when necessary, as well as to group, sort, process formulas, ... )
    4. The number of record returned
        ( If a SQL query returns a large number of records, it will take longer to format and display than if was returning a smaller data set.)
    Report design:
    1. Where is the Record Selection evaluated.
        Ensure your Record Selection Formula can be translated in SQL, so the data can be filtered down on the Server, otherwise the filtering will be done in a temp file on the local machine which will be much slower.
    They have many functions that cannot be translated in SQL because they may not have a standard SQL for it.
    For example, control structure like IF THEN ELSE cannot be translated into SQL. It will always be evaluated in Crystal Reports. But if you use an IF THEN ELSE on a parameter, it will convert the result of the condition to SQL, but as soon as uses database fileds in the conditions it will not be translated in SQL.
    2. How many subreports the report contains and in section they are located.
    Minimise the number of subreports used, or avoid using subreports if possible because
    subreports are reports within a report, and if you have a subreport in a details section, and the report returns 100 records, the subreport will be evaluated 100 times, so it will query the database 100 times. It is often the biggest factor why a report takes a long time to preview.
    3. How many records will be returned to the report.
       Large number of records will slow down the preview of the reports. Ensure you only returns the necessary data on the report, by creating a Record Selection Formula, or basing your report
    off a Stored Procedure, or a Command Object that only returns the desired data set.
    4. Do you use the special field "Page N of M", or "TotalPageCount"
       When the special field "Page N of M" or "TotalPageCount" is used on a report, it will have to generate each page of the report before it displays the first page, therfore it will take more time to display the first page of the report.
        If you want to improve the speed of a report, remove the special field "Page N of M" or "Total Page Count" or formula that uses the function "TotalPageCount". If those aren't used when you view a report it only format the page requested. It won't format the whole report.
    5. Link tables on indexed fields whenever possible.
    6. Remove unused tables, unused formulas, unused running totals from the report.
    7. Suppress unnecessary sections.
    8. For summaries, use conditional formulas instead of running totals when possible.
    9. Whenever possible, limit records through selection, not suppression.
    10. Use SQL expressions to convert fields to be used in record selection instead of using formula functions.
    For example, if you need to concatenate 2 fields together, instead of doing it in a formula, you can create a SQL Expression Field. It will concatenate the fields on the database server, instead of doing in Crystal Reports.
    SQL Expression Fields are added to the SELECT clause of the SQL Query send to the database.
    11. Using one command as the datasource can be faster if you return only the desired data set.
          It can be faster if the SQL query written only return the desired data.
    12. Perform grouping on server
       This is only relevant if you only need to return the summary to your report but not the details. It   will be faster as less data will be returned to the reports.
    Regards
    Girish Bhosale

Maybe you are looking for

  • How do we permanently stop MASS_CRM_* and R3AD_* locks from being applied??

    Good afternoon Experts, How do we permanently stop MASS_CRM_* and R3AD_* locks from being applied in CRM? We have several jobs that run weekly to download information from R/3 to CRM. The information only takes a few minutes to download into CRM, how

  • Oracle-Project to closure Process flow

    Hello All, I need ta end to end process flow from defining a project to closing a project. Modules covered are : Oracle Project Costing Oracle Project Billing Oracle Project Management EBS Version : R12.1.3 Thanks in Advance, Yadnesh

  • How to access iTunes after a PC crash

    Recently had my PC crash & IT had to 'wipe' it.  Thus, lost all my iTunes stuff in my documents.  I'm scared to just log back into iTunes since I don't know what I'll find.  I'm assuming all is gone.  Is there any way to retreive what I had on there

  • Ligthtoom Vs Elements as Organizer for Less than 1200 photos?

    I am I guess a semi serious amateur.  If find the editing capapbilites in Elements 7 sufficient for my needs. However, I want to organize my photos, about 1200, and future photos. I know you can organize in Lightroom and then do the editing in Elemen

  • IMac randomly freezes. Spinning pinwheel

    My late 2009 iMac running OS X 10.6.3 and now 10.6.4 has had a problem randomly freezing. The problem is easily remedied by manually shutting down with the power button and then powering the machine back on. However, I am tired of having to do this a