Search in sources :

Example 1 with ImageSizeEntry

use of com.att.aro.core.bestpractice.pojo.ImageSizeEntry in project VideoOptimzer by attdevsupport.

the class ImageSizeImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    mImageFoundInHtmlOrCss = false;
    ImageSizeResult result = new ImageSizeResult();
    List<ImageSizeEntry> entrylist = new ArrayList<ImageSizeEntry>();
    // 480 * 1.1;
    int deviceScreenSizeX = 528;
    // 800 * 1.1;
    int deviceScreenSizeY = 880;
    // screen size is available when reading trace directory
    if (tracedata.getTraceresult().getTraceResultType() == TraceResultType.TRACE_DIRECTORY) {
        TraceDirectoryResult dirdata = (TraceDirectoryResult) tracedata.getTraceresult();
        deviceScreenSizeX = (dirdata.getDeviceScreenSizeX() * 110) / 100;
        deviceScreenSizeY = (dirdata.getDeviceScreenSizeY() * 110) / 100;
    }
    for (Session session : tracedata.getSessionlist()) {
        HttpRequestResponseInfo lastReq = null;
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.REQUEST) {
                lastReq = req;
            }
            if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
                boolean isBigSize = false;
                List<HtmlImage> htmlImageList = checkThisImageInAllHTMLOrCSS(session, req);
                if (mImageFoundInHtmlOrCss) {
                    mImageFoundInHtmlOrCss = false;
                    if (!htmlImageList.isEmpty()) {
                        for (int index = 0; index < htmlImageList.size(); index++) {
                            HtmlImage htmlImage = htmlImageList.get(index);
                            isBigSize = compareDownloadedImgSizeWithStdImageSize(req, htmlImage, deviceScreenSizeX, deviceScreenSizeY, session);
                            if (isBigSize) {
                                break;
                            }
                        }
                    } else {
                        isBigSize = compareDownloadedImgSizeWithStdImageSize(req, null, deviceScreenSizeX, deviceScreenSizeY, session);
                    }
                    if (isBigSize) {
                        entrylist.add(new ImageSizeEntry(req, lastReq, session.getDomainName()));
                    }
                }
            }
        }
    }
    result.setDeviceScreenSizeRangeX(deviceScreenSizeX);
    result.setDeviceScreenSizeRangeY(deviceScreenSizeY);
    result.setResults(entrylist);
    String text = "";
    if (entrylist.isEmpty()) {
        result.setResultType(BPResultType.PASS);
        text = MessageFormat.format(textResultPass, entrylist.size());
        result.setResultText(text);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), entrylist.size());
        result.setResultText(text);
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), entrylist.size()));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportNumberOfLargeImages(exportNumberOfLargeImages);
    return result;
}
Also used : HtmlImage(com.att.aro.core.bestpractice.pojo.HtmlImage) ImageSizeEntry(com.att.aro.core.bestpractice.pojo.ImageSizeEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) ImageSizeResult(com.att.aro.core.bestpractice.pojo.ImageSizeResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 2 with ImageSizeEntry

use of com.att.aro.core.bestpractice.pojo.ImageSizeEntry in project VideoOptimzer by attdevsupport.

the class BpFileImageSizeTablePanel method getContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
@SuppressWarnings("unchecked")
public DataTable<ImageSizeEntry> getContentTable() {
    if (contentTable == null) {
        contentTable = new DataTable<ImageSizeEntry>(tableModel);
        contentTable.setName(ResourceBundleHelper.getMessageString("file.resize.images.tableName"));
        contentTable.setAutoCreateRowSorter(true);
        contentTable.setGridColor(Color.LIGHT_GRAY);
        contentTable.setRowHeight(ROW_HEIGHT);
        contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
        popupMenu.initialize();
    }
    return contentTable;
}
Also used : ImageSizeEntry(com.att.aro.core.bestpractice.pojo.ImageSizeEntry) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu)

Aggregations

ImageSizeEntry (com.att.aro.core.bestpractice.pojo.ImageSizeEntry)2 HtmlImage (com.att.aro.core.bestpractice.pojo.HtmlImage)1 ImageSizeResult (com.att.aro.core.bestpractice.pojo.ImageSizeResult)1 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 DataTablePopupMenu (com.att.aro.ui.model.DataTablePopupMenu)1 ArrayList (java.util.ArrayList)1