Skip to content

Instantly share code, notes, and snippets.

View tckb's full-sized avatar
:octocat:

Chandra (tckb) tckb

:octocat:
View GitHub Profile
@tckb
tckb / GEEmbedSnippet.java
Last active December 14, 2015 16:29
Code snippet to embed Google Earth on a Java Frame
/* This is just a code fragment
Use JNA : https://github.com/twall/jna#readme to get handle# of Java frame
Use 'JaWin to extract java stubs from Google Earth
http://jawinproject.sourceforge.net/
GE Java Stubs:
IApplicationGE.java // main entry point to GE
User32.dll:
Windows USER component that creates and manipulates the standard elements of the Windows user interface.
@tckb
tckb / Vishal.java
Last active December 15, 2015 05:29
private static Map sortByComparator(Map singleCutTable) {
List list = new LinkedList(singleCutTable.entrySet());
// sort list based on comparator
Collections.sort(list, new Comparator() {
public int compare(Object o1, Object o2) {
Map.Entry obj1Entry = (Map.Entry) o1.getValue();
Map.Entry obj2Entry = (Map.Entry) o2.getValue();
@tckb
tckb / AudioDisplay.java
Created October 17, 2013 10:57
Abstract AudioDisplay class defining the set the operations that can be expected from it.
/*
* Copyright (C) 2013 tckb < Chandra [dot] Tungathurthi [at] rwth-aachen.de >
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@tckb
tckb / NTAudioDemo.java
Last active December 25, 2015 18:49
A demo file using NonTrivialAudio.
/*
* Copyright (C) 2013 tckb < Chandra [dot] Tungathurthi [at] rwth-aachen.de >
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
package cam.uk.ebi.sg.ui;
import cam.uk.ebi.sg.main.ImageRenderer;
import cam.uk.ebi.sg.main.OSRA;
import java.io.File;
import java.util.concurrent.Callable;
import javax.swing.ImageIcon;
/**
*
File tokkaloImageFile = Utility.UI.saveFile(frame);
Image img = icon.getImage();
BufferedImage bi = new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_BYTE_ARGB);
Graphics2D g2 = bi.createGraphics();
g2.drawImage(img, 0, 0, null);
g2.dispose();
ImageIO.write(bi, "jpg",tokkaloImageFile);
import java.io.File;
import com.tckb.util.*;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
@tckb
tckb / SaveObject.java
Last active December 31, 2015 20:38
Code fragment
// Code part of tckb-lib
// Author: tckb <[email protected]>
// https://github.com/tckb/jAudIO.pub
public static void saveObjectToFile(File thatFile, Object... thisObject) {
mylogger.log(Level.INFO, "Saving object{0} to file: {1}", new Object[]{thisObject.hashCode(), thatFile.getAbsolutePath()});
ObjectOutputStream stream;
try {
stream = new ObjectOutputStream(new FileOutputStream(thatFile));
public static int getRadius(int[][] distMatrix){
int radius = Integer.MAX_VALUE;
//biggest value in evry column of the matrix = ece
// radius = minium eccentricity of a molecule
for(int r=0;r<distMatrix.length;r++){
int maxDist=0;
for(int c=0;r<distMatrix.length;r++){
if(distMatrix[r][c] > maxDist ){
maxDist = distMatrix[r][c];